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.
feat(front): wip sites_groups component and svc
- Loading branch information
Maxime Vergez
committed
Jan 18, 2023
1 parent
668f14f
commit 87842ae
Showing
7 changed files
with
94 additions
and
14 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
Empty file.
9 changes: 9 additions & 0 deletions
9
frontend/app/components/monitoring-sitesgroups/monitoring-sitesgroups.component.html
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div id="geometry" class="monitoring-map-container"> | ||
<pnx-map height="80vh"> | ||
<pnx-geojson | ||
[geojson]="sitesGroups" | ||
[zoomOnLayer]="true" | ||
[zoomOnFirstTime]="true" | ||
></pnx-geojson> | ||
</pnx-map> | ||
</div> |
49 changes: 49 additions & 0 deletions
49
frontend/app/components/monitoring-sitesgroups/monitoring-sitesgroups.component.ts
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Component, OnInit } from "@angular/core"; | ||
import { SitesService } from "../../services/sites.service"; | ||
import { GeoJSON } from "leaflet"; | ||
|
||
interface SitesGroups { | ||
comments?: string; | ||
data?: any; | ||
geom_geojson: 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 PaginatedSitesGroup { | ||
count: number; | ||
limit: number; | ||
offset: number; | ||
items: SitesGroups[]; | ||
} | ||
|
||
@Component({ | ||
selector: "monitoring-sitesgroups", | ||
templateUrl: "./monitoring-sitesgroups.component.html", | ||
styleUrls: ["./monitoring-sitesgroups.component.css"], | ||
}) | ||
export class MonitoringSitesGroupsComponent implements OnInit { | ||
sitesGroups: GeoJSON; | ||
constructor(private _sites_service: SitesService) {} | ||
ngOnInit() { | ||
console.log("yolo"); | ||
this._sites_service | ||
.getSitesGroups() | ||
.subscribe((data: PaginatedSitesGroup) => { | ||
this.sitesGroups = { | ||
features: data.items.map((group) => { | ||
group["id"] = group.id_sites_group; | ||
group["type"] = "Feature"; | ||
return group; | ||
}), | ||
type: "FeatureCollection", | ||
}; | ||
console.log(this.sitesGroups); | ||
}); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Injectable } from "@angular/core"; | ||
|
||
import { CacheService } from "./cache.service"; | ||
import { ConfigService } from "./config.service"; | ||
import { HttpClient } from "@angular/common/http"; | ||
|
||
|
||
@Injectable() | ||
export class SitesService { | ||
constructor( | ||
private _cacheService: CacheService | ||
) {} | ||
|
||
getSitesGroups() { | ||
return this._cacheService.request("get", `sites_groups`); | ||
} | ||
} |