Skip to content

Commit dff7dc5

Browse files
authored
Create inventory sub pages (#40)
* dev * attempt to get type in service * directory refactor and dynamic sidenav * directory refactor * base for inv nav * enter to check terms/conditions * profile grid dev * selection order functional * clp fxnal * groups delete & edit modal fxnal * groups crud fxnal * summary page * move tabs to page component * bug fixes * dev * clp fixes * cross cycle and map dev * map load inventory * use text-secondary * map renderes, needs controls * map functional, needs labels / popover * label filtering fxnal * styles * prettier * lint * no inventory warning * inv pages fxnal with empty cycle /org * refactor streams inv list * refactor streams inv clp * refactor streams list map * prettier * styles
1 parent 13e0ed8 commit dff7dc5

94 files changed

Lines changed: 2885 additions & 216 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"luxon": "^3.5.0",
6060
"material-icons": "^1.13.14",
6161
"ol": "^10.5.0",
62+
"ol-ext": "^4.0.31",
6263
"perfect-scrollbar": "^1.5.6",
6364
"pnpm": "^10.6.2",
6465
"rxjs": "~7.8.1",
@@ -79,6 +80,7 @@
7980
"@tailwindcss/typography": "^0.5.16",
8081
"@types/chroma-js": "^2.4.5",
8182
"@types/decompress": "^4.2.7",
83+
"@types/geojson": "^7946.0.16",
8284
"@types/jasmine": "~5.1.5",
8385
"@types/lodash-es": "^4.17.12",
8486
"@types/luxon": "^3.4.2",

pnpm-lock.yaml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/images/map_pin.webp

562 Bytes
Loading
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { HttpErrorResponse } from '@angular/common/http'
2+
import { HttpClient } from '@angular/common/http'
3+
import { inject, Injectable } from '@angular/core'
4+
import type { Observable } from 'rxjs'
5+
import { catchError, Subject, takeUntil } from 'rxjs'
6+
import { ErrorService } from '@seed/services/error/error.service'
7+
import { UserService } from '../user'
8+
import type { AnalysisSummary } from './analysis.types'
9+
10+
@Injectable({ providedIn: 'root' })
11+
export class AnalysisService {
12+
private _httpClient = inject(HttpClient)
13+
private _errorService = inject(ErrorService)
14+
private _userService = inject(UserService)
15+
private readonly _unsubscribeAll$ = new Subject<void>()
16+
17+
orgId: number
18+
19+
constructor() {
20+
this._userService.currentOrganizationId$.pipe(takeUntil(this._unsubscribeAll$)).subscribe((organizationId) => {
21+
this.orgId = organizationId
22+
})
23+
}
24+
25+
summary(orgId: number, cycleId: number): Observable<AnalysisSummary> {
26+
const url = `/api/v3/analyses/stats/?cycle_id=${cycleId}&organization_id=${orgId}`
27+
return this._httpClient.get<AnalysisSummary>(url).pipe(
28+
catchError((error: HttpErrorResponse) => {
29+
return this._errorService.handleError(error, 'Error fetching analysis summary')
30+
}),
31+
)
32+
}
33+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export type AnalysisSummary = {
2+
'column_settings fields and counts': Record<string, number>;
3+
number_extra_data_fields: number;
4+
status: string;
5+
total_records: number;
6+
}

src/@seed/api/analysis/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './analysis.types'
2+
export * from './analysis.service'

src/@seed/api/column/column.service.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ export class ColumnService {
3232
getPropertyColumns(organizationId: number): Observable<Column[]> {
3333
const url = `/api/v3/columns/?inventory_type=property&display_units=true&organization_id=${organizationId}`
3434
return this._httpClient.get<ColumnsResponse>(url).pipe(
35+
// Why were the related fields filtered ? should be done in components to preserve the api response
36+
// map((cr) => {
37+
// const cols = cr.columns.filter((c) => c.table_name === 'PropertyState')
38+
// this._propertyColumns.next(cols)
39+
// return cols
40+
// }),
3541
map((cr) => {
36-
const cols = cr.columns.filter((c) => c.table_name === 'PropertyState')
42+
const cols = cr.columns
3743
this._propertyColumns.next(cols)
3844
return cols
3945
}),
@@ -48,10 +54,15 @@ export class ColumnService {
4854
const url = `/api/v3/columns/?inventory_type=taxlot&display_units=true&organization_id=${organizationId}`
4955
return this._httpClient.get<ColumnsResponse>(url).pipe(
5056
map((cr) => {
51-
const cols = cr.columns.filter((c) => c.table_name === 'TaxLotState')
57+
const cols = cr.columns
5258
this._taxLotColumns.next(cols)
5359
return cols
5460
}),
61+
// map((cr) => {
62+
// const cols = cr.columns.filter((c) => c.table_name === 'TaxLotState')
63+
// this._taxLotColumns.next(cols)
64+
// return cols
65+
// }),
5566
catchError((error: HttpErrorResponse) => {
5667
// TODO need to figure out error handling
5768
return this._errorService.handleError(error, 'Error fetching columns')
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import type { HttpErrorResponse } from '@angular/common/http'
2+
import { HttpClient } from '@angular/common/http'
3+
import { inject, Injectable } from '@angular/core'
4+
import { BehaviorSubject, catchError, map, type Observable, Subject, takeUntil, tap } from 'rxjs'
5+
import { ErrorService } from '@seed/services'
6+
import { SnackBarService } from 'app/core/snack-bar/snack-bar.service'
7+
import { OrganizationService } from '../organization'
8+
import type { InventoryGroup, InventoryGroupResponse, InventoryGroupsResponse } from './groups.types'
9+
10+
@Injectable({ providedIn: 'root' })
11+
export class GroupsService {
12+
private _errorService = inject(ErrorService)
13+
private _groups = new BehaviorSubject<unknown>([])
14+
private _httpClient = inject(HttpClient)
15+
private _organizationService = inject(OrganizationService)
16+
private _snackBar = inject(SnackBarService)
17+
private readonly _unsubscribeAll$ = new Subject<void>()
18+
19+
groups$ = this._groups.asObservable()
20+
orgId: number
21+
22+
constructor() {
23+
this._organizationService.currentOrganization$
24+
.pipe(takeUntil(this._unsubscribeAll$))
25+
.subscribe(({ org_id }) => this.orgId = org_id)
26+
}
27+
28+
list(orgId: number): Observable<InventoryGroup[]> {
29+
const url = `/api/v3/inventory_groups/?organization_id=${orgId}`
30+
return this._httpClient.get<InventoryGroupsResponse>(url).pipe(
31+
map(({ data }) => {
32+
this._groups.next(data)
33+
return data
34+
}),
35+
catchError((error: HttpErrorResponse) => {
36+
return this._errorService.handleError(error, 'Error fetching groups')
37+
}),
38+
)
39+
}
40+
41+
create(orgId: number, data: InventoryGroup): Observable<InventoryGroup> {
42+
const url = `/api/v3/inventory_groups/?organization_id=${orgId}`
43+
return this._httpClient.post<InventoryGroupResponse>(url, data).pipe(
44+
map(({ data }) => {
45+
this._snackBar.success('Group created successfully')
46+
return data
47+
}),
48+
catchError((error: HttpErrorResponse) => {
49+
return this._errorService.handleError(error, 'Error updating group')
50+
}),
51+
)
52+
}
53+
54+
update(orgId: number, id: number, data: InventoryGroup): Observable<InventoryGroup> {
55+
const url = `/api/v3/inventory_groups/${id}/?organization_id=${orgId}`
56+
return this._httpClient.put<InventoryGroupResponse>(url, data).pipe(
57+
map(({ data }) => {
58+
this._snackBar.success('Group updated successfully')
59+
return data
60+
}),
61+
catchError((error: HttpErrorResponse) => {
62+
return this._errorService.handleError(error, 'Error updating group')
63+
}),
64+
)
65+
}
66+
67+
delete(orgId: number, id: number): Observable<unknown> {
68+
const url = `/api/v3/inventory_groups/${id}/?organization_id=${orgId}`
69+
return this._httpClient.delete(url).pipe(
70+
tap(() => { this._snackBar.success('Group deleted successfully') }),
71+
catchError((error: HttpErrorResponse) => {
72+
return this._errorService.handleError(error, 'Error deleting group')
73+
}),
74+
)
75+
}
76+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { InventoryDisplayType } from 'app/modules/inventory'
2+
3+
export type InventoryGroupsResponse = {
4+
status: string;
5+
data: InventoryGroup[];
6+
}
7+
8+
export type InventoryGroupResponse = {
9+
status: string;
10+
data: InventoryGroup;
11+
}
12+
13+
export type InventoryGroup = {
14+
access_level_instance: number;
15+
access_level_instance_data: Record<string, unknown>;
16+
id: number;
17+
inventory_list: number[];
18+
inventory_type: InventoryDisplayType;
19+
name: string;
20+
organization: number;
21+
systems: Record<string, unknown>[];
22+
views_list: number[];
23+
}

src/@seed/api/groups/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './groups.service'
2+
export * from './groups.types'

0 commit comments

Comments
 (0)