From c5170e01d40d0326fe7491e3b5d967b7cd123aa3 Mon Sep 17 00:00:00 2001 From: jannisvisser Date: Wed, 20 Mar 2024 21:47:46 +0100 Subject: [PATCH] fix: own leadTime per station AB#27137 --- .../app/components/admin-level/admin-level.component.ts | 2 +- .../glofas-station-popup-content.component.ts | 5 +---- .../src/app/components/map/map.component.ts | 2 +- .../src/app/services/point-marker.service.ts | 9 ++++++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/interfaces/IBF-dashboard/src/app/components/admin-level/admin-level.component.ts b/interfaces/IBF-dashboard/src/app/components/admin-level/admin-level.component.ts index 058cbf91a..ed24be225 100644 --- a/interfaces/IBF-dashboard/src/app/components/admin-level/admin-level.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/admin-level/admin-level.component.ts @@ -277,6 +277,6 @@ export class AdminLevelComponent implements OnInit, OnDestroy { } public disableNationalView(): boolean { - return this.eventState.events.length === 1; + return this.eventState?.events?.length === 1; } } diff --git a/interfaces/IBF-dashboard/src/app/components/leaflet-popup/glofas-station-popup-content/glofas-station-popup-content.component.ts b/interfaces/IBF-dashboard/src/app/components/leaflet-popup/glofas-station-popup-content/glofas-station-popup-content.component.ts index b2549880d..5b9c43aab 100644 --- a/interfaces/IBF-dashboard/src/app/components/leaflet-popup/glofas-station-popup-content/glofas-station-popup-content.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/leaflet-popup/glofas-station-popup-content/glofas-station-popup-content.component.ts @@ -1,5 +1,4 @@ import { Component, Input, OnInit } from '@angular/core'; -import { TranslateService } from '@ngx-translate/core'; import { EapAlertClass, EapAlertClasses } from '../../../models/country.model'; import { Station } from '../../../models/poi.model'; import { LeadTime } from '../../../types/lead-time'; @@ -28,8 +27,6 @@ export class GlofasStationPopupContentComponent implements OnInit { value: 0, }; - constructor(private translate: TranslateService) {} - ngOnInit(): void { if (!this.data) { return; @@ -80,6 +77,6 @@ export class GlofasStationPopupContentComponent implements OnInit { const [value, unit] = this.data.leadTime.split('-'); - return `${value} ${unit}${Number(value) > 1 ? 's' : ''}`; + return `${value} ${unit}${Number(value) === 1 ? '' : 's'}`; } } diff --git a/interfaces/IBF-dashboard/src/app/components/map/map.component.ts b/interfaces/IBF-dashboard/src/app/components/map/map.component.ts index 9286e8b03..51c484011 100644 --- a/interfaces/IBF-dashboard/src/app/components/map/map.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/map/map.component.ts @@ -453,7 +453,7 @@ export class MapComponent implements AfterViewInit, OnDestroy { geoJsonPoint.properties as Station, latlng, this.countryDisasterSettings, - this.timelineState.activeLeadTime, + this.eventState?.events, ); } case IbfLayerName.redCrossBranches: diff --git a/interfaces/IBF-dashboard/src/app/services/point-marker.service.ts b/interfaces/IBF-dashboard/src/app/services/point-marker.service.ts index 93f03894b..893909931 100644 --- a/interfaces/IBF-dashboard/src/app/services/point-marker.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/point-marker.service.ts @@ -44,7 +44,7 @@ import { } from '../models/country.model'; import { IbfLayerName } from '../types/ibf-layer'; import { LeadTime } from '../types/lead-time'; -import { EventService } from './event.service'; +import { EventService, EventSummary } from './event.service'; @Injectable({ providedIn: 'root', @@ -119,10 +119,13 @@ export class PointMarkerService { markerProperties: Station, markerLatLng: LatLng, countryDisasterSettings: CountryDisasterSettings, - activeLeadTime: LeadTime, + events: EventSummary[], ): Marker { - const markerTitle = markerProperties.stationName; + const activeLeadTime = events.find( + (e) => e.eventName === markerProperties.stationCode, // TODO: this counds on eventName being equal to stationCode! + )?.firstLeadTime as LeadTime; + const markerTitle = markerProperties.stationName; const markerIcon: IconOptions = { ...LEAFLET_MARKER_ICON_OPTIONS_BASE, iconUrl: `assets/markers/glofas-station-${