Skip to content

Commit

Permalink
merge backoffice
Browse files Browse the repository at this point in the history
Merge branch 'backoffice' into champs-libres-dev
  • Loading branch information
nobohan committed Sep 6, 2021
2 parents 12dd56b + b8ac8d3 commit c5f36d3
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 13 deletions.
45 changes: 44 additions & 1 deletion frontend/src/app/dashboard/dashboard.component.html
@@ -1,6 +1,27 @@
<div class="container">
<h1>Tableau de bord</h1>
<div *ngIf="programLine">


<div *ngIf="programPoint">
<h2>{{programPoint.features[0].properties.title}}</h2>
<div *ngIf="sitePoint">
<div class="">{{ sitePoint.count }} arbres répertoriés</div>
<div>
<details>
<summary>
Liste des arbres répertoriés
</summary>
<ul>
<li *ngFor="let s of sitePoint.features">
{{ s.properties.name }}
</li>
</ul>
</details>
</div>
</div>
</div>

<div *ngIf="programLine">
<h2>{{programLine.features[0].properties.title}}</h2>
<div *ngIf="siteLine">
<div class="">{{ siteLine.count }} haies répertoriées</div>
Expand All @@ -19,6 +40,28 @@ <h2>{{programLine.features[0].properties.title}}</h2>
</div>
</div>
</div>

<div *ngIf="programPolygon">
<h2>{{programPolygon.features[0].properties.title}}</h2>
<div *ngIf="sitePolygon">
<div class="">{{ sitePolygon.count }} zones naturelles répertoriées</div>
<div>
<details>
<summary>
Liste des zones répertoriées
</summary>
<ul>
<li *ngFor="let s of sitePolygon.features">
{{ s.properties.name }}
</li>
</ul>
</details>
</div>
</div>
</div>



</div>


58 changes: 46 additions & 12 deletions frontend/src/app/dashboard/dashboard.component.ts
Expand Up @@ -4,15 +4,21 @@ import { AppConfig } from '../../conf/app.config';
import { Title } from '@angular/platform-browser';
import { GncProgramsService } from '../api/gnc-programs.service';
import { FeatureCollection, Geometry } from 'geojson';
import { Program } from '../programs/programs.models';

@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.css'],
})
export class DashboardComponent implements OnInit {
programs: Program[];
sitePoint: FeatureCollection;
siteLine: FeatureCollection;
sitePolygon: FeatureCollection;
programPoint: FeatureCollection;
programLine: FeatureCollection;
programPolygon: FeatureCollection;
sumLineLength: number;
constructor(
private router: Router,
Expand All @@ -23,21 +29,49 @@ export class DashboardComponent implements OnInit {
ngOnInit(): void {
this.titleService.setTitle(`${AppConfig.appName} - tableau de bord`);

// TODO récupérer le programme (pour la forme, il est connu)

this.programService.getProgram(1).subscribe((program) => {
this.programLine = program;
//this.count= sites.count;
console.log('this.programLine:', this.programLine);
});
this.programService.getAllPrograms().subscribe((programs) => {
this.programs = programs;
console.log('this.programs: ', this.programs);

for (let p of this.programs) {
console.log(p);
this.programService.getProgram(p.id_program).subscribe((program) => {
if ( program.features[0].properties.short_desc.includes('arbres') ) {
this.programPoint = program;
console.log('this.programPoint:', this.programPoint);

this.programService.getProgramSites(p.id_program).subscribe((site) => {
this.sitePoint = site;
console.log('this.sitePoint:', this.sitePoint);
});
}

if ( program.features[0].properties.short_desc.includes('haies') ) {
this.programLine = program;
console.log('this.programLine:', this.programLine);

this.programService.getProgramSites(p.id_program).subscribe((site) => {
this.siteLine = site;
console.log('this.siteLines:', this.siteLine);
this.sumLineLength = this.computeTotalLength(this.siteLine);
});
}

if ( program.features[0].properties.short_desc.includes('zones') ) {
this.programPolygon = program;
console.log('this.programZones:', this.programPolygon);

this.programService.getProgramSites(p.id_program).subscribe((site) => {
this.sitePolygon = site;
console.log('this.sitePolygon:', this.sitePolygon);
});
}

});
}

// Récupérer tous les sites du programme
this.programService.getProgramSites(1).subscribe((site) => {
this.siteLine = site;
console.log('this.siteLines:', this.siteLine);
this.sumLineLength = this.computeTotalLength(this.siteLine);
});
// TODO remettre les features sur une carte
}

computeTotalLength(featureCollection: FeatureCollection): number {
Expand Down

0 comments on commit c5f36d3

Please sign in to comment.