diff --git a/interfaces/IBF-dashboard/src/app/components/event-speech-bubble/event-speech-bubble.component.html b/interfaces/IBF-dashboard/src/app/components/event-speech-bubble/event-speech-bubble.component.html index e839f9f4d..c0f02e568 100644 --- a/interfaces/IBF-dashboard/src/app/components/event-speech-bubble/event-speech-bubble.component.html +++ b/interfaces/IBF-dashboard/src/app/components/event-speech-bubble/event-speech-bubble.component.html @@ -172,8 +172,8 @@ >{{ area.actionsValue | percent: '.0-0' }} - - {{ - area.severityLevel + - {{ + area.alertClass }}
@@ -226,8 +226,8 @@ >{{ area.actionsValue | percent: '.0-0' }} - - {{ - area.severityLevel + - {{ + area.alertClass }} diff --git a/interfaces/IBF-dashboard/src/app/services/eap-actions.service.ts b/interfaces/IBF-dashboard/src/app/services/eap-actions.service.ts index 004a855b4..cb7228dd6 100644 --- a/interfaces/IBF-dashboard/src/app/services/eap-actions.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/eap-actions.service.ts @@ -145,7 +145,7 @@ export class EapActionsService { if (this.getActiveLeadtime()) { this.triggeredAreas.forEach((area) => { this.formatDates(area); - this.mapSeverityLevel(area); + this.mapTriggerValueToAlertClass(area); this.filterEapActionsByMonth(area); area.eapActions.forEach((action) => { if (Object.keys(action.month).length) { @@ -183,8 +183,8 @@ export class EapActionsService { ).toFormat('cccc, dd LLLL'); }; - private mapSeverityLevel = (triggeredArea: TriggeredArea) => { - // If no match is found, then no severity level will be shown + private mapTriggerValueToAlertClass = (triggeredArea: TriggeredArea) => { + // If no match is found, then no alert class will be shown if (this.countryDisasterSettings.eapAlertClasses) { for (const alertClass of Object.keys( this.countryDisasterSettings.eapAlertClasses, @@ -193,7 +193,7 @@ export class EapActionsService { triggeredArea.triggerValue === this.countryDisasterSettings.eapAlertClasses[alertClass].value ) { - triggeredArea.severityLevel = this.countryDisasterSettings.eapAlertClasses[ + triggeredArea.alertClass = this.countryDisasterSettings.eapAlertClasses[ alertClass ].label; } diff --git a/interfaces/IBF-dashboard/src/app/types/triggered-area.ts b/interfaces/IBF-dashboard/src/app/types/triggered-area.ts index cd98743dd..978954d36 100644 --- a/interfaces/IBF-dashboard/src/app/types/triggered-area.ts +++ b/interfaces/IBF-dashboard/src/app/types/triggered-area.ts @@ -16,5 +16,5 @@ export class TriggeredArea { stopped: boolean; stoppedDate: string; submitDisabled: boolean; - severityLevel?: string; + alertClass?: string; } diff --git a/package.json b/package.json index 21b50d53b..d0ee18c40 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,5 @@ "pre-push": "^0.1.1", "prettier": "^2.6.2", "puppeteer": "^8.0.0" - }, - "pre-commit": "lint" + } } diff --git a/services/API-service/src/api/event/dto/event-place-code.dto.ts b/services/API-service/src/api/event/dto/event-place-code.dto.ts index 5f2c115e5..c3b3dd32e 100644 --- a/services/API-service/src/api/event/dto/event-place-code.dto.ts +++ b/services/API-service/src/api/event/dto/event-place-code.dto.ts @@ -51,6 +51,9 @@ export class ActivationLogDto { @ApiProperty({ example: 100 }) public exposureValue: number; + @ApiProperty({ example: 'Maximum alert' }) + public alertClass: string; + @ApiProperty({ example: '57084ea4-cac9-4f29-b955-fe9f08beb588' }) public databaseId: string; @@ -66,6 +69,7 @@ export class ActivationLogDto { this.manuallyStopped = null; this.exposureIndicator = null; this.exposureValue = null; + this.alertClass = null; this.databaseId = null; } } diff --git a/services/API-service/src/api/event/event.service.ts b/services/API-service/src/api/event/event.service.ts index 7ef67e74a..06c907b86 100644 --- a/services/API-service/src/api/event/event.service.ts +++ b/services/API-service/src/api/event/event.service.ts @@ -210,6 +210,18 @@ export class EventService { ).triggerUnit; } + private async getCountryDisasterSettings( + countryCodeISO3: string, + disasterType: DisasterType, + ) { + return ( + await this.countryRepository.findOne({ + where: { countryCodeISO3: countryCodeISO3 }, + relations: ['countryDisasterSettings'], + }) + ).countryDisasterSettings.find((d) => d.disasterType === disasterType); + } + public async getTriggeredAreas( countryCodeISO3: string, disasterType: DisasterType, @@ -223,12 +235,7 @@ export class EventService { ); const triggerUnit = await this.getTriggerUnit(disasterType); const defaultAdminLevel = ( - await this.countryRepository.findOne({ - where: { countryCodeISO3: countryCodeISO3 }, - relations: ['countryDisasterSettings'], - }) - ).countryDisasterSettings.find( - (d) => d.disasterType === disasterType, + await this.getCountryDisasterSettings(countryCodeISO3, disasterType) ).defaultAdminLevel; const whereFiltersDynamicData = { @@ -415,6 +422,7 @@ export class EventService { 'case when event.closed = true then event."endDate" end as "endDate"', 'disaster."actionsUnit" as "exposureIndicator"', 'event."actionsValue" as "exposureValue"', + `CASE event."triggerValue" WHEN 1 THEN 'maximum' WHEN 0.7 THEN 'medium' WHEN 0.3 THEN 'minimum' END as "triggerValue"`, 'event."eventPlaceCodeId" as "databaseId"', ]) .leftJoin('event.adminArea', 'area')