From 24c60067a62fc4a5c8a5412fa5988995d2068850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20Lain=C3=A9?= Date: Thu, 3 Oct 2024 12:32:28 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20donn=C3=A9es=20API=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/data/data.service.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/data/data.service.ts b/src/data/data.service.ts index 6bd6345..0fa38ee 100644 --- a/src/data/data.service.ts +++ b/src/data/data.service.ts @@ -119,6 +119,7 @@ export class DataService { && (dateDebut ? moment(d.date, 'YYYY-MM-DD').isSameOrAfter(moment(dateDebut, 'YYYY-MM-DD'), 'day') : true) && (dateFin ? moment(d.date, 'YYYY-MM-DD').isSameOrBefore(moment(dateFin, 'YYYY-MM-DD'), 'day') : true), ); + dataDepartementFiltered = JSON.parse(JSON.stringify(dataDepartementFiltered)); let departementsToFilter = []; if (bassinVersant) { const b = this.bassinsVersants.find(b => b.id === +bassinVersant); @@ -387,6 +388,9 @@ export class DataService { tmp.departements.push({ code: departement.code, niveauGravite: this.findMaxNiveauGravite(d.departements, departement.code), + niveauGraviteSup: this.findMaxNiveauGravite(d.departements, departement.code, 'SUP'), + niveauGraviteSou: this.findMaxNiveauGravite(d.departements, departement.code, 'SOU'), + niveauGraviteAep: this.findMaxNiveauGravite(d.departements, departement.code, 'AEP'), }); }); this.dataDepartement.push(tmp); @@ -409,12 +413,15 @@ export class DataService { } } - findMaxNiveauGravite(restrictions: any[], departementCode: string) { + findMaxNiveauGravite(restrictions: any[], departementCode: string, zoneType?: string) { const restrictionsDepartement = restrictions.find(r => r.departement === departementCode); if (!restrictionsDepartement) { return null; } - const zonesType = ['SUP', 'SOU', 'AEP']; + let zonesType = ['SUP', 'SOU', 'AEP']; + if (zoneType) { + zonesType = zonesType.filter(z => z === zoneType); + } const niveauxGravite = ['crise', 'alerte_renforcee', 'alerte', 'vigilance']; for (const niveauGravite of niveauxGravite) { for (const zoneType of zonesType) {