forked from PnX-SI/gn_module_monitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display group site child into table and uder properties Use routing and id params to display property of groups site Create service site Add logic to check routing and child route to display reactive component properties and table Reviewed-by: andriacap [Refs ticket]: #4
- Loading branch information
Showing
7 changed files
with
217 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,31 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { Observable } from "rxjs"; | ||
import { map } from "rxjs/operators"; | ||
// import { GeoJSON } from "geojson"; | ||
|
||
import { CacheService } from "./cache.service"; | ||
import { ConfigService } from "./config.service"; | ||
import { HttpClient } from "@angular/common/http"; | ||
import { GeoJSON } from "leaflet"; | ||
interface SitesGroups{ | ||
comments?: string; | ||
data?: any; | ||
// geometry: any; | ||
id_sites_group: number; | ||
nb_sites: number; | ||
nb_visits: number; | ||
sites_group_code: string; | ||
sites_group_description?: string; | ||
sites_group_name: string; | ||
uuid_sites_group: string; | ||
} | ||
|
||
interface SitesGroupsExtended extends Omit<GeoJSON.Feature, "P"|"type"> { | ||
// properties:Omit<SitesGroups,"geometry">; | ||
properties:SitesGroups | ||
type:string; | ||
} | ||
|
||
interface Page { | ||
count: number; | ||
limit: number; | ||
page: number; | ||
} | ||
|
||
interface PaginatedSitesGroup extends Page{ | ||
items: SitesGroupsExtended[]; | ||
} | ||
interface CustomGeoJson { | ||
type: "FeatureCollection"; | ||
features: SitesGroupsExtended[]; | ||
} | ||
import { IGeomService, JsonData, ISite } from "../interfaces/geom"; | ||
import { Paginated } from "../interfaces/page"; | ||
import { MonitoringSite } from "../class/monitoring-site"; | ||
|
||
@Injectable() | ||
export class SitesService { | ||
constructor( | ||
private _cacheService: CacheService | ||
) {} | ||
|
||
getSitesGroups(page=1, limit=10, params={}) { | ||
return this._cacheService.request("get", `sites_groups`, {queryParams: {page, limit, ...params}}); | ||
} | ||
|
||
setFormatToGeoJson(data:PaginatedSitesGroup):CustomGeoJson{ | ||
return { | ||
features: data.items.map((group) => { | ||
let { | ||
geometry, | ||
properties, | ||
..._ | ||
} = group; | ||
let result = {"geometry":geometry,"properties":properties,"type":"Feature"} | ||
console.log("result",result) | ||
console.log(group) | ||
return result; | ||
}), | ||
type: "FeatureCollection", | ||
}; | ||
export class SitesService implements IGeomService { | ||
constructor(private _cacheService: CacheService) {} | ||
|
||
get( | ||
page: number = 1, | ||
limit: number = 10, | ||
params: JsonData = {} | ||
): Observable<Paginated<MonitoringSite>> { | ||
return this._cacheService | ||
.request<Observable<Paginated<ISite>>>("get", `sites`, { | ||
queryParams: { page, limit, ...params }, | ||
}) | ||
.pipe( | ||
map((response: Paginated<ISite>) => ({ | ||
...response, | ||
items: response.items.map((item: ISite) => item as MonitoringSite), | ||
})) | ||
); | ||
} | ||
|
||
getDataTable(data:CustomGeoJson) { | ||
return data.features.map((groupSite) => { | ||
let { | ||
comments, | ||
data, | ||
uuid_sites_group, | ||
id_sites_group, | ||
sites_group_description, | ||
...dataTable | ||
} = groupSite.properties; | ||
return dataTable; | ||
}); | ||
} | ||
|
||
} |
Oops, something went wrong.