Skip to content

Commit

Permalink
feat(front): wip sites_groups component and svc
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Vergez committed Jan 18, 2023
1 parent 668f14f commit 87842ae
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 14 deletions.
2 changes: 1 addition & 1 deletion frontend/app/components/modules/modules.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h2 class="title-module mb-4">{{titleModule}}</h2>
<div class="col-md-4 col-sm-12 des-module"> {{description}}</div>
<!-- <div class="w-100 d-none d-sm-block"></div> -->
<div class="btn-module col-md-8 col-sm-12 text-center">
<button class="btn btn-success mr-2" (click)="onAccessSitesClick(modules)" *ngIf="currentUser">
<button class="btn btn-success mr-2" [routerLink]="'sites_groups'" *ngIf="currentUser">
Accès aux sites
</button>
<div class="container py-5 border rounded m-2">
Expand Down
8 changes: 4 additions & 4 deletions frontend/app/components/modules/modules.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ export class ModulesComponent implements OnInit {
this.currentUser["cruved_objects"] = {};
}

onAccessSitesClick(modules) {
console.log("accès aux sites avec droits ")
console.log(modules)
}
// onAccessSitesClick(modules) {
// console.log("accès aux sites avec droits ")
// console.log(modules)
// }

}
Empty file.
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>
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);
});
}
}
23 changes: 14 additions & 9 deletions frontend/app/gnModule.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,22 @@ import { MonitoringPropertiesComponent } from "./components/monitoring-propertie
import { MonitoringDatatableComponent } from "./components/monitoring-datatable/monitoring-datatable.component";

import { MatSlideToggleModule } from "@angular/material/slide-toggle";
import { MatFormFieldModule} from "@angular/material/form-field";
import { MatAutocompleteModule} from "@angular/material/autocomplete";
import { MatSelectModule} from "@angular/material/select";
import { MatInputModule} from "@angular/material/input";



import { MatFormFieldModule } from "@angular/material/form-field";
import { MatAutocompleteModule } from "@angular/material/autocomplete";
import { MatSelectModule } from "@angular/material/select";
import { MatInputModule } from "@angular/material/input";
import { MonitoringSitesGroupsComponent } from "./components/monitoring-sitesgroups/monitoring-sitesgroups.component";
import { SitesService } from "./services/sites.service";

// my module routing
const routes: Routes = [
/** modules */
{ path: "", component: ModulesComponent },

/** module */
{ path: 'module/:moduleCode', component: MonitoringObjectComponent },
{ path: "module/:moduleCode", component: MonitoringObjectComponent },
/** create module */
{ path: 'module', component: MonitoringObjectComponent },
{ path: "module", component: MonitoringObjectComponent },

/** object */
{
Expand All @@ -55,6 +54,10 @@ const routes: Routes = [
path: "create_object/:moduleCode/:objectType",
component: MonitoringObjectComponent,
},
{
path: "sites_groups",
component: MonitoringSitesGroupsComponent,
},
];

@NgModule({
Expand All @@ -69,6 +72,7 @@ const routes: Routes = [
MonitoringListComponent,
MonitoringPropertiesComponent,
MonitoringDatatableComponent,
MonitoringSitesGroupsComponent,
],
imports: [
GN2CommonModule,
Expand All @@ -92,6 +96,7 @@ const routes: Routes = [
DataUtilsService,
ConfigService,
MonitoringObjectService,
SitesService,
],
bootstrap: [ModulesComponent],
schemas: [
Expand Down
17 changes: 17 additions & 0 deletions frontend/app/services/sites.service.ts
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`);
}
}

0 comments on commit 87842ae

Please sign in to comment.