From f695e3f9da9c3e40af58b3371be58875d5557a30 Mon Sep 17 00:00:00 2001 From: arsforza Date: Fri, 1 Sep 2023 15:53:32 +0200 Subject: [PATCH 01/10] chore: disable @typescript-eslint/no-unused-vars AB#23441 --- interfaces/IBF-dashboard/.eslintrc.json | 1 - .../IBF-dashboard/src/app/auth/auth.guard.ts | 1 + .../IBF-dashboard/src/app/auth/auth.service.ts | 2 +- .../app/components/tooltip/tooltip.component.ts | 2 +- interfaces/IBF-dashboard/src/shared/utils.ts | 14 +++++++------- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/interfaces/IBF-dashboard/.eslintrc.json b/interfaces/IBF-dashboard/.eslintrc.json index 374081753..2970c409a 100644 --- a/interfaces/IBF-dashboard/.eslintrc.json +++ b/interfaces/IBF-dashboard/.eslintrc.json @@ -17,7 +17,6 @@ "plugin:@typescript-eslint/recommended" ], "rules": { - "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/no-explicit-any": "off", "@angular-eslint/no-empty-lifecycle-method": "off", "@angular-eslint/component-class-suffix": "off", diff --git a/interfaces/IBF-dashboard/src/app/auth/auth.guard.ts b/interfaces/IBF-dashboard/src/app/auth/auth.guard.ts index 85fe8b45e..49f07943e 100644 --- a/interfaces/IBF-dashboard/src/app/auth/auth.guard.ts +++ b/interfaces/IBF-dashboard/src/app/auth/auth.guard.ts @@ -30,6 +30,7 @@ export class AuthGuard implements CanActivate { checkLogin(url: string, route: ActivatedRouteSnapshot): boolean { if (this.authService.isLoggedIn()) { + console.log('route: ', route); return true; } diff --git a/interfaces/IBF-dashboard/src/app/auth/auth.service.ts b/interfaces/IBF-dashboard/src/app/auth/auth.service.ts index 0d3f1c853..373ae3823 100644 --- a/interfaces/IBF-dashboard/src/app/auth/auth.service.ts +++ b/interfaces/IBF-dashboard/src/app/auth/auth.service.ts @@ -151,7 +151,7 @@ export class AuthService implements OnDestroy { .subscribe(this.onPasswordChanged, this.onChangePasswordError); } - private onPasswordChanged = async (res) => { + private onPasswordChanged = async () => { const toast = await this.toastController.create({ message: `Password changed successfully`, duration: 5000, diff --git a/interfaces/IBF-dashboard/src/app/components/tooltip/tooltip.component.ts b/interfaces/IBF-dashboard/src/app/components/tooltip/tooltip.component.ts index 8fa7126a0..5e404f8c1 100644 --- a/interfaces/IBF-dashboard/src/app/components/tooltip/tooltip.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/tooltip/tooltip.component.ts @@ -26,6 +26,6 @@ export class TooltipComponent { }); await popover.present(); - const { role } = await popover.onDidDismiss(); + await popover.onDidDismiss(); } } diff --git a/interfaces/IBF-dashboard/src/shared/utils.ts b/interfaces/IBF-dashboard/src/shared/utils.ts index 93bdcd853..a2f942c97 100644 --- a/interfaces/IBF-dashboard/src/shared/utils.ts +++ b/interfaces/IBF-dashboard/src/shared/utils.ts @@ -1,16 +1,16 @@ // sort array ascending const asc = (arr) => arr.sort((a, b) => a - b); -const sum = (arr) => arr.reduce((a, b) => a + b, 0); +// const sum = (arr) => arr.reduce((a, b) => a + b, 0); -const mean = (arr) => sum(arr) / arr.length; +// const mean = (arr) => sum(arr) / arr.length; // sample standard deviation -const std = (arr) => { - const mu = mean(arr); - const diffArr = arr.map((a) => (a - mu) ** 2); - return Math.sqrt(sum(diffArr) / (arr.length - 1)); -}; +// const std = (arr) => { +// const mu = mean(arr); +// const diffArr = arr.map((a) => (a - mu) ** 2); +// return Math.sqrt(sum(diffArr) / (arr.length - 1)); +// }; export const quantile = (arr, q) => { const sorted = asc(arr); From b13076cd1847e534f16450b7edaa5999fc8f5424 Mon Sep 17 00:00:00 2001 From: arsforza Date: Mon, 4 Sep 2023 11:31:16 +0200 Subject: [PATCH 02/10] chore: disable @typescript-eslint/no-explicit-any exception AB#23441 --- interfaces/IBF-dashboard/.eslintrc.json | 1 - .../src/app/analytics/analytics.service.ts | 15 ++++++--- .../areas-of-focus-summary.component.ts | 14 ++++---- .../app/components/matrix/matrix.component.ts | 2 +- .../activation-log/activation.log.page.ts | 12 ++++--- .../src/app/services/aggregates.service.ts | 5 +-- .../src/app/services/api.service.ts | 15 +++++---- .../src/app/services/eap-actions.service.ts | 2 +- .../services/loader.interceptor.service.ts | 12 +++---- .../src/app/services/map.service.ts | 32 ++++++++++++------- .../IBF-dashboard/src/app/types/aggregate.ts | 5 +++ .../src/app/types/area-of-focus.ts | 8 +++++ .../src/app/types/recent-date.ts | 4 +++ 13 files changed, 85 insertions(+), 42 deletions(-) create mode 100644 interfaces/IBF-dashboard/src/app/types/aggregate.ts create mode 100644 interfaces/IBF-dashboard/src/app/types/area-of-focus.ts create mode 100644 interfaces/IBF-dashboard/src/app/types/recent-date.ts diff --git a/interfaces/IBF-dashboard/.eslintrc.json b/interfaces/IBF-dashboard/.eslintrc.json index 2970c409a..42f751c1a 100644 --- a/interfaces/IBF-dashboard/.eslintrc.json +++ b/interfaces/IBF-dashboard/.eslintrc.json @@ -17,7 +17,6 @@ "plugin:@typescript-eslint/recommended" ], "rules": { - "@typescript-eslint/no-explicit-any": "off", "@angular-eslint/no-empty-lifecycle-method": "off", "@angular-eslint/component-class-suffix": "off", "@typescript-eslint/ban-types": "off", diff --git a/interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts b/interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts index c08963ab2..2fb62b1e3 100644 --- a/interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts +++ b/interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts @@ -66,11 +66,14 @@ export class AnalyticsService { } } - logError(error: any, severityLevel?: SeverityLevel): void { + logError(error: Error, severityLevel?: SeverityLevel): void { this.displayOnConsole(error, severityLevel); } - logEvent(name: string, properties?: { [key: string]: any }): void { + logEvent( + name: string, + properties?: { [key: string]: string | number | boolean }, + ): void { if (this.isApplicationInsightsEnabled) { this.applicationInsights.trackEvent({ name }, properties); } else { @@ -89,7 +92,10 @@ export class AnalyticsService { } } - logTrace(message: string, properties?: { [key: string]: any }) { + logTrace( + message: string, + properties?: { [key: string]: string | number | boolean }, + ) { if (this.isApplicationInsightsEnabled) { this.applicationInsights.trackTrace({ message }, properties); } else { @@ -98,9 +104,10 @@ export class AnalyticsService { } private displayOnConsole( - error: any, + error: Error, severityLevel: SeverityLevel = SeverityLevel.Error, ) { + console.log('=== error type: ', typeof error); switch (severityLevel) { case SeverityLevel.Critical: case SeverityLevel.Error: diff --git a/interfaces/IBF-dashboard/src/app/components/areas-of-focus-summary/areas-of-focus-summary.component.ts b/interfaces/IBF-dashboard/src/app/components/areas-of-focus-summary/areas-of-focus-summary.component.ts index b1816dfa9..d87e190ac 100644 --- a/interfaces/IBF-dashboard/src/app/components/areas-of-focus-summary/areas-of-focus-summary.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/areas-of-focus-summary/areas-of-focus-summary.component.ts @@ -9,6 +9,8 @@ import { PlaceCodeService } from 'src/app/services/place-code.service'; import { EventState } from 'src/app/types/event-state'; import { AnalyticsEvent, AnalyticsPage } from '../../analytics/analytics.enum'; import { AnalyticsService } from '../../analytics/analytics.service'; +import { AreaOfFocus } from '../../types/area-of-focus'; +import { TriggeredArea } from '../../types/triggered-area'; import { LayerControlInfoPopoverComponent } from '../layer-control-info-popover/layer-control-info-popover.component'; @Component({ @@ -22,8 +24,8 @@ export class AreasOfFocusSummaryComponent implements OnInit, OnDestroy { private initialEventStateSubscription: Subscription; private manualEventStateSubscription: Subscription; - public areasOfFocus: any[]; - public triggeredAreas: any[]; + public areasOfFocus: AreaOfFocus[]; + public triggeredAreas: TriggeredArea[]; public trigger: boolean; public eventState: EventState; @@ -62,7 +64,7 @@ export class AreasOfFocusSummaryComponent implements OnInit, OnDestroy { this.manualEventStateSubscription.unsubscribe(); } - private onTriggeredAreasChange = (triggeredAreas) => { + private onTriggeredAreasChange = (triggeredAreas: TriggeredArea[]) => { this.triggeredAreas = triggeredAreas; this.calculateEAPActionStatus(this.triggeredAreas); }; @@ -100,14 +102,14 @@ export class AreasOfFocusSummaryComponent implements OnInit, OnDestroy { }; private calculateEAPActionStatus(triggeredAreas): void { - const onEachAreaOfFocus = (areaOfFocus) => { + const onEachAreaOfFocus = (areaOfFocus: AreaOfFocus) => { areaOfFocus.count = 0; areaOfFocus.countChecked = 0; // Look at each triggered area .. triggeredAreas.forEach(this.onEachTriggeredArea(areaOfFocus)); }; - const onAreasOfFocusChange = (areasOfFocus) => { + const onAreasOfFocusChange = (areasOfFocus: AreaOfFocus[]) => { this.areasOfFocus = areasOfFocus; // Start calculation only when last area has eapActions attached to it @@ -128,7 +130,7 @@ export class AreasOfFocusSummaryComponent implements OnInit, OnDestroy { this.eventState = eventState; }; - public async moreInfo(areaOfFocus: any): Promise { + public async moreInfo(areaOfFocus: AreaOfFocus): Promise { const { id, label, description } = areaOfFocus; const popover = await this.popoverController.create({ diff --git a/interfaces/IBF-dashboard/src/app/components/matrix/matrix.component.ts b/interfaces/IBF-dashboard/src/app/components/matrix/matrix.component.ts index 1826a0384..0cbe5bf14 100644 --- a/interfaces/IBF-dashboard/src/app/components/matrix/matrix.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/matrix/matrix.component.ts @@ -66,7 +66,7 @@ export class MatrixComponent implements OnDestroy { } }; - async presentPopover(event: any, layer: IbfLayer): Promise { + async presentPopover(event: Event, layer: IbfLayer): Promise { event.stopPropagation(); const popover = await this.popoverController.create({ diff --git a/interfaces/IBF-dashboard/src/app/pages/dashboard/activation-log/activation.log.page.ts b/interfaces/IBF-dashboard/src/app/pages/dashboard/activation-log/activation.log.page.ts index 537e1ee18..7a7e6884b 100644 --- a/interfaces/IBF-dashboard/src/app/pages/dashboard/activation-log/activation.log.page.ts +++ b/interfaces/IBF-dashboard/src/app/pages/dashboard/activation-log/activation.log.page.ts @@ -9,6 +9,8 @@ import { ApiService } from 'src/app/services/api.service'; import { DisasterTypeService } from '../../../services/disaster-type.service'; import { DisasterTypeKey } from '../../../types/disaster-type-key'; +type ActivationLogRecord = { [key: string]: string | number | boolean }; + @Component({ selector: 'app-activation-log', templateUrl: './activation.log.page.html', @@ -21,7 +23,7 @@ export class ActivationLogPage implements OnInit, OnDestroy { public activationLogs: | { headerData: string[]; - rowsData: any[][]; + rowsData: (string | number | boolean)[][]; } | string; @@ -50,13 +52,15 @@ export class ActivationLogPage implements OnInit, OnDestroy { this.activationLogSubscription.unsubscribe(); } - private onFetchActivationLogs = (data) => { + private onFetchActivationLogs = (data: ActivationLogRecord[]) => { this.activationLogs = this.jsonToCsv(data); }; private jsonToCsv( - items: any[], - ): { headerData: string[]; rowsData: any[] } | string { + items: ActivationLogRecord[], + ): + | { headerData: string[]; rowsData: (string | number | boolean)[][] } + | string { if (items.length === 0) { return ''; } diff --git a/interfaces/IBF-dashboard/src/app/services/aggregates.service.ts b/interfaces/IBF-dashboard/src/app/services/aggregates.service.ts index e018cba8d..21c3e7460 100644 --- a/interfaces/IBF-dashboard/src/app/services/aggregates.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/aggregates.service.ts @@ -10,6 +10,7 @@ import { AdminLevel } from '../types/admin-level'; import { EventState } from '../types/event-state'; import { IbfLayerName } from '../types/ibf-layer'; import { TimelineState } from '../types/timeline-state'; +import { TriggeredArea } from '../types/triggered-area'; import { AdminLevelService } from './admin-level.service'; import { DisasterTypeService } from './disaster-type.service'; import { EapActionsService } from './eap-actions.service'; @@ -30,7 +31,7 @@ export class AggregatesService { public timelineState: TimelineState; private adminLevel: AdminLevel; private defaultAdminLevel: AdminLevel; - public triggeredAreas: any[]; + public triggeredAreas: TriggeredArea[]; private AREA_STATUS_KEY = 'areaStatus'; constructor( @@ -99,7 +100,7 @@ export class AggregatesService { this.eventState = eventState; }; - private onTriggeredAreasChange = (triggeredAreas: any[]) => { + private onTriggeredAreasChange = (triggeredAreas: TriggeredArea[]) => { this.triggeredAreas = triggeredAreas; this.loadMetadataAndAggregates(); }; diff --git a/interfaces/IBF-dashboard/src/app/services/api.service.ts b/interfaces/IBF-dashboard/src/app/services/api.service.ts index f9efbdc2b..c408cd1d8 100644 --- a/interfaces/IBF-dashboard/src/app/services/api.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/api.service.ts @@ -9,8 +9,11 @@ import { JwtService } from 'src/app/services/jwt.service'; import { AdminLevel } from 'src/app/types/admin-level'; import { LeadTime } from 'src/app/types/lead-time'; import { environment } from 'src/environments/environment'; +import { User } from '../models/user/user.model'; +import { Aggregate } from '../types/aggregate'; import { DisasterTypeKey } from '../types/disaster-type-key'; import { IbfLayerName } from '../types/ibf-layer'; +import { RecentDate } from '../types/recent-date'; import { TriggeredArea } from '../types/triggered-area'; import { EventSummary } from './event.service'; @@ -113,7 +116,7 @@ export class ApiService { // API-endpoints: ///////////////////////////////////////////////////////////////////////////// - login(email: string, password: string): Observable { + login(email: string, password: string): Observable { this.log('ApiService : login()'); return this.post( @@ -126,7 +129,7 @@ export class ApiService { ); } - changePassword(password: string): Observable { + changePassword(password: string): Observable { this.log('ApiService : changePassword()'); return this.post('user/change-password', { password, @@ -203,7 +206,7 @@ export class ApiService { getRecentDates( countryCodeISO3: string, disasterType: DisasterTypeKey, - ): Observable { + ): Observable { return this.get( `event/recent-date/${countryCodeISO3}/${disasterType}`, false, @@ -260,7 +263,7 @@ export class ApiService { adminLevel: AdminLevel = AdminLevel.adminLevel1, leadTime: string, eventName: string, - ): Observable { + ): Observable { let params = new HttpParams(); if (eventName) { params = params.append('eventName', eventName); @@ -307,7 +310,7 @@ export class ApiService { countryCodeISO3: string, adminLevel: AdminLevel, indicator: string, - ) { + ): Observable<{ value: number; placeCode: string }[]> { return this.get( `admin-area-data/${countryCodeISO3}/${adminLevel}/${indicator}`, false, @@ -335,7 +338,7 @@ export class ApiService { indicator: string, disasterType: DisasterTypeKey, eventName: string, - ) { + ): Observable<{ value: number; placeCode: string }[]> { let params = new HttpParams(); if (eventName) { params = params.append('eventName', eventName); 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 725eb7162..0600d5e34 100644 --- a/interfaces/IBF-dashboard/src/app/services/eap-actions.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/eap-actions.service.ts @@ -23,7 +23,7 @@ import { TimelineService } from './timeline.service'; providedIn: 'root', }) export class EapActionsService { - private triggeredAreaSubject = new BehaviorSubject([]); + private triggeredAreaSubject = new BehaviorSubject([]); public triggeredAreas: TriggeredArea[]; private country: Country; private disasterType: DisasterType; diff --git a/interfaces/IBF-dashboard/src/app/services/loader.interceptor.service.ts b/interfaces/IBF-dashboard/src/app/services/loader.interceptor.service.ts index 47417a4c6..ce541d32f 100644 --- a/interfaces/IBF-dashboard/src/app/services/loader.interceptor.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/loader.interceptor.service.ts @@ -19,9 +19,9 @@ export class LoaderInterceptorService implements HttpInterceptor { constructor(private loaderService: LoaderService) {} intercept( - request: HttpRequest, + request: HttpRequest, next: HttpHandler, - ): Observable> { + ): Observable> { const requestPath = request.url; const skipRequest = this.requestsToSkip.some((toSkip) => requestPath.includes(toSkip), @@ -29,12 +29,12 @@ export class LoaderInterceptorService implements HttpInterceptor { if (skipRequest) { return next.handle(request).pipe( tap( - (event: HttpEvent) => { + (event: HttpEvent) => { if (event instanceof HttpResponse) { this.onEnd(requestPath); } }, - (error: any) => { + (error: unknown) => { console.log('error: ', error); this.onEnd(requestPath); }, @@ -46,12 +46,12 @@ export class LoaderInterceptorService implements HttpInterceptor { return next.handle(request).pipe( tap( - (event: HttpEvent) => { + (event: HttpEvent) => { if (event instanceof HttpResponse) { this.onEnd(requestPath); } }, - (error: any) => { + (error: unknown) => { console.log('error: ', error); this.onEnd(requestPath); }, diff --git a/interfaces/IBF-dashboard/src/app/services/map.service.ts b/interfaces/IBF-dashboard/src/app/services/map.service.ts index 2a4976c72..9ba03c237 100644 --- a/interfaces/IBF-dashboard/src/app/services/map.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/map.service.ts @@ -31,6 +31,7 @@ import { AdminLevel } from '../types/admin-level'; import { DisasterTypeKey } from '../types/disaster-type-key'; import { EventState } from '../types/event-state'; import { TimelineState } from '../types/timeline-state'; +import { TriggeredArea } from '../types/triggered-area'; import { DisasterTypeService } from './disaster-type.service'; import { EapActionsService } from './eap-actions.service'; @@ -78,7 +79,7 @@ export class MapService { public eventState: EventState; public timelineState: TimelineState; public adminLevel: AdminLevel; - public triggeredAreas: any[]; + public triggeredAreas: TriggeredArea[]; private country: Country; private disasterType: DisasterType; @@ -155,11 +156,11 @@ export class MapService { this.timelineState = timelineState; }; - private onEventStateChange = (eventState: any) => { + private onEventStateChange = (eventState: EventState) => { this.eventState = eventState; }; - private onTriggeredAreasChange = (triggeredAreas: any[]) => { + private onTriggeredAreasChange = (triggeredAreas: TriggeredArea[]) => { this.triggeredAreas = triggeredAreas; this.loadLayers(); }; @@ -242,7 +243,10 @@ export class MapService { } } - private addStationLayer = (layer: IbfLayerMetadata, stations: any) => { + private addStationLayer = ( + layer: IbfLayerMetadata, + stations: GeoJSON.FeatureCollection, + ) => { this.addLayer({ name: IbfLayerName.glofasStations, label: IbfLayerLabel.glofasStations, @@ -280,7 +284,7 @@ export class MapService { private addTyphoonTrackLayer = ( layer: IbfLayerMetadata, - typhoonTrack: any, + typhoonTrack: GeoJSON.FeatureCollection, ) => { this.addLayer({ name: IbfLayerName.typhoonTrack, @@ -328,7 +332,7 @@ export class MapService { private addPointDataLayer = ( layer: IbfLayerMetadata, layerName: IbfLayerName, - pointData: any, + pointData: GeoJSON.FeatureCollection, ) => { this.addLayer({ name: layerName, @@ -361,7 +365,10 @@ export class MapService { } }; - private addWaterPointsLayer(layer: IbfLayerMetadata, waterPoints: any) { + private addWaterPointsLayer( + layer: IbfLayerMetadata, + waterPoints: GeoJSON.FeatureCollection, + ) { const isLoading = waterPoints ? false : true; this.addLayer({ name: IbfLayerName.waterpoints, @@ -398,7 +405,10 @@ export class MapService { } } - private addAdminRegionLayer(adminRegions: any, adminLevel: AdminLevel) { + private addAdminRegionLayer( + adminRegions: GeoJSON.FeatureCollection, + adminLevel: AdminLevel, + ) { this.addLayer({ name: `${IbfLayerGroup.adminRegions}${adminLevel}` as IbfLayerName, label: `${IbfLayerGroup.adminRegions}${adminLevel}` as IbfLayerLabel, @@ -465,7 +475,7 @@ export class MapService { private addAggregateLayer( indicator: Indicator, - adminRegions: any, + adminRegions: GeoJSON.FeatureCollection, active: boolean, ) { this.addLayer({ @@ -751,7 +761,7 @@ export class MapService { eventName: string, ): Observable { // Do api request to get data layer - let admDynamicDataObs: Observable; + let admDynamicDataObs: Observable<{ value: number; placeCode: string }[]>; if (dynamic) { admDynamicDataObs = this.apiService.getAdminAreaDynamicData( countryCodeISO3, @@ -782,7 +792,7 @@ export class MapService { const foundAdmDynamicEntry = admDynamicData.find( (admDynamicEntry): number => { if (area.properties?.placeCode === admDynamicEntry.placeCode) { - return admDynamicEntry; + return admDynamicEntry.value; } }, ); diff --git a/interfaces/IBF-dashboard/src/app/types/aggregate.ts b/interfaces/IBF-dashboard/src/app/types/aggregate.ts new file mode 100644 index 000000000..5f8fdb4bc --- /dev/null +++ b/interfaces/IBF-dashboard/src/app/types/aggregate.ts @@ -0,0 +1,5 @@ +export class Aggregate { + indicator: string; + placecode: string; + value: number; +} diff --git a/interfaces/IBF-dashboard/src/app/types/area-of-focus.ts b/interfaces/IBF-dashboard/src/app/types/area-of-focus.ts new file mode 100644 index 000000000..39552555a --- /dev/null +++ b/interfaces/IBF-dashboard/src/app/types/area-of-focus.ts @@ -0,0 +1,8 @@ +export class AreaOfFocus { + id: string; + label: string; + description: string; + icon: string; + count?: number; + countChecked?: number; +} diff --git a/interfaces/IBF-dashboard/src/app/types/recent-date.ts b/interfaces/IBF-dashboard/src/app/types/recent-date.ts new file mode 100644 index 000000000..ea3cb6e00 --- /dev/null +++ b/interfaces/IBF-dashboard/src/app/types/recent-date.ts @@ -0,0 +1,4 @@ +export class RecentDate { + date: string; + timestamp: string; +} From c1d89ff6175eadde60040d22e107ac4e6be3a98b Mon Sep 17 00:00:00 2001 From: arsforza Date: Mon, 4 Sep 2023 11:33:30 +0200 Subject: [PATCH 03/10] chore: add manual @typescript-eslint/no-explicit-any exceptions AB#23441 --- interfaces/IBF-dashboard/src/app/services/api.service.ts | 3 +++ interfaces/IBF-dashboard/src/app/services/jwt.service.ts | 1 + interfaces/IBF-dashboard/src/test.ts | 1 + interfaces/IBF-dashboard/src/zone-flags.ts | 1 + 4 files changed, 6 insertions(+) diff --git a/interfaces/IBF-dashboard/src/app/services/api.service.ts b/interfaces/IBF-dashboard/src/app/services/api.service.ts index c408cd1d8..18821ec60 100644 --- a/interfaces/IBF-dashboard/src/app/services/api.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/api.service.ts @@ -49,6 +49,7 @@ export class ApiService { return headers; } + // eslint-disable-next-line @typescript-eslint/no-explicit-any get(path: string, anonymous = true, params = null): Observable { const url = `${environment.apiUrl}/${path}`; const security = this.showSecurity(anonymous); @@ -70,6 +71,7 @@ export class ApiService { ); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any post(path: string, body: object, anonymous = false): Observable { const url = `${environment.apiUrl}/${path}`; const security = this.showSecurity(anonymous); @@ -91,6 +93,7 @@ export class ApiService { ); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any put(path: string, body: object, anonymous = false): Observable { const url = `${environment.apiUrl}/${path}`; const security = this.showSecurity(anonymous); diff --git a/interfaces/IBF-dashboard/src/app/services/jwt.service.ts b/interfaces/IBF-dashboard/src/app/services/jwt.service.ts index 240798bad..b70c92c72 100644 --- a/interfaces/IBF-dashboard/src/app/services/jwt.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/jwt.service.ts @@ -20,6 +20,7 @@ export class JwtService { window.localStorage.removeItem(this.tokenKey); } + // eslint-disable-next-line @typescript-eslint/no-explicit-any public decodeToken(rawToken: string): any { return this.jwtHelper.decodeToken(rawToken); } diff --git a/interfaces/IBF-dashboard/src/test.ts b/interfaces/IBF-dashboard/src/test.ts index 713586ad1..802d864ab 100644 --- a/interfaces/IBF-dashboard/src/test.ts +++ b/interfaces/IBF-dashboard/src/test.ts @@ -7,6 +7,7 @@ import { platformBrowserDynamicTesting, } from '@angular/platform-browser-dynamic/testing'; +// eslint-disable-next-line @typescript-eslint/no-explicit-any declare const require: any; // First, initialize the Angular testing environment. diff --git a/interfaces/IBF-dashboard/src/zone-flags.ts b/interfaces/IBF-dashboard/src/zone-flags.ts index e999ae9d1..320ad86bf 100644 --- a/interfaces/IBF-dashboard/src/zone-flags.ts +++ b/interfaces/IBF-dashboard/src/zone-flags.ts @@ -2,4 +2,5 @@ * Prevents Angular change detection from * running with certain Web Component callbacks */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any (window as any).__Zone_disable_customElements = true; From 72e05ee00ff184a7856e06768f9d6080f74b4b18 Mon Sep 17 00:00:00 2001 From: arsforza Date: Mon, 4 Sep 2023 11:38:27 +0200 Subject: [PATCH 04/10] chore: disable @angular-eslint/no-empty-lifecycle-method exception AB#23441 --- interfaces/IBF-dashboard/.eslintrc.json | 1 - .../change-password-popover.component.ts | 6 ++---- .../forgot-password-popover.component.ts | 6 ++---- .../screen-orientation-popover.component.ts | 6 ++---- .../toggle-trigger-popover.component.ts | 6 ++---- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/interfaces/IBF-dashboard/.eslintrc.json b/interfaces/IBF-dashboard/.eslintrc.json index 42f751c1a..25b491952 100644 --- a/interfaces/IBF-dashboard/.eslintrc.json +++ b/interfaces/IBF-dashboard/.eslintrc.json @@ -17,7 +17,6 @@ "plugin:@typescript-eslint/recommended" ], "rules": { - "@angular-eslint/no-empty-lifecycle-method": "off", "@angular-eslint/component-class-suffix": "off", "@typescript-eslint/ban-types": "off", "@typescript-eslint/no-empty-function": "off" diff --git a/interfaces/IBF-dashboard/src/app/components/change-password-popover/change-password-popover.component.ts b/interfaces/IBF-dashboard/src/app/components/change-password-popover/change-password-popover.component.ts index 25ad55c74..27f74e7b2 100644 --- a/interfaces/IBF-dashboard/src/app/components/change-password-popover/change-password-popover.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/change-password-popover/change-password-popover.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild } from '@angular/core'; +import { Component, ViewChild } from '@angular/core'; import { NgForm } from '@angular/forms'; import { PopoverController } from '@ionic/angular'; import { AuthService } from 'src/app/auth/auth.service'; @@ -8,7 +8,7 @@ import { AuthService } from 'src/app/auth/auth.service'; templateUrl: './change-password-popover.component.html', styleUrls: ['./change-password-popover.component.scss'], }) -export class ChangePasswordPopoverComponent implements OnInit { +export class ChangePasswordPopoverComponent { @ViewChild('changePasswordForm') public changePasswordForm: NgForm; @@ -24,8 +24,6 @@ export class ChangePasswordPopoverComponent implements OnInit { private popoverController: PopoverController, ) {} - ngOnInit() {} - public onSubmit() { if (!this.changePasswordForm.form.valid) { return; diff --git a/interfaces/IBF-dashboard/src/app/components/forgot-password-popover/forgot-password-popover.component.ts b/interfaces/IBF-dashboard/src/app/components/forgot-password-popover/forgot-password-popover.component.ts index 0f6fab4cd..8cb3d64e0 100644 --- a/interfaces/IBF-dashboard/src/app/components/forgot-password-popover/forgot-password-popover.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/forgot-password-popover/forgot-password-popover.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component } from '@angular/core'; import { PopoverController } from '@ionic/angular'; import { environment } from 'src/environments/environment'; @@ -7,13 +7,11 @@ import { environment } from 'src/environments/environment'; templateUrl: './forgot-password-popover.component.html', styleUrls: ['./forgot-password-popover.component.scss'], }) -export class ForgotPasswordPopoverComponent implements OnInit { +export class ForgotPasswordPopoverComponent { public emailAddress = environment.supportEmailAddress; constructor(private popoverController: PopoverController) {} - ngOnInit() {} - public closePopover(): void { this.popoverController.dismiss(); } diff --git a/interfaces/IBF-dashboard/src/app/components/screen-orientation-popover/screen-orientation-popover.component.ts b/interfaces/IBF-dashboard/src/app/components/screen-orientation-popover/screen-orientation-popover.component.ts index fe43ade55..49f59ad7e 100644 --- a/interfaces/IBF-dashboard/src/app/components/screen-orientation-popover/screen-orientation-popover.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/screen-orientation-popover/screen-orientation-popover.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { PopoverController } from '@ionic/angular'; @Component({ @@ -6,14 +6,12 @@ import { PopoverController } from '@ionic/angular'; templateUrl: './screen-orientation-popover.component.html', styleUrls: ['./screen-orientation-popover.component.scss'], }) -export class ScreenOrientationPopoverComponent implements OnInit { +export class ScreenOrientationPopoverComponent { @Input() public device: string; constructor(private popoverController: PopoverController) {} - ngOnInit() {} - public closePopover(): void { this.popoverController.dismiss(); } diff --git a/interfaces/IBF-dashboard/src/app/components/toggle-trigger-popover/toggle-trigger-popover.component.ts b/interfaces/IBF-dashboard/src/app/components/toggle-trigger-popover/toggle-trigger-popover.component.ts index 1167f2dff..485ee4322 100644 --- a/interfaces/IBF-dashboard/src/app/components/toggle-trigger-popover/toggle-trigger-popover.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/toggle-trigger-popover/toggle-trigger-popover.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { PopoverController } from '@ionic/angular'; import { TranslateService } from '@ngx-translate/core'; import { DisasterTypeKey } from '../../types/disaster-type-key'; @@ -8,7 +8,7 @@ import { DisasterTypeKey } from '../../types/disaster-type-key'; templateUrl: './toggle-trigger-popover.component.html', styleUrls: ['./toggle-trigger-popover.component.scss'], }) -export class ToggleTriggerPopoverComponent implements OnInit { +export class ToggleTriggerPopoverComponent { @Input() public placeCodeName: string; @@ -26,8 +26,6 @@ export class ToggleTriggerPopoverComponent implements OnInit { private translateService: TranslateService, ) {} - ngOnInit() {} - public getDisasterSpecificText(): string { const key = `chat-component.common.${this.stopNode}.${this.eapNode}.disaster-specific.${this.disasterType}`; const translation = this.translateService.instant(key); From 049934af02ec2855965cebf73a01fe5dc3ec6cf9 Mon Sep 17 00:00:00 2001 From: arsforza Date: Mon, 4 Sep 2023 11:43:10 +0200 Subject: [PATCH 05/10] chore: allow Page as suffix AB#23441 --- interfaces/IBF-dashboard/.eslintrc.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/interfaces/IBF-dashboard/.eslintrc.json b/interfaces/IBF-dashboard/.eslintrc.json index 25b491952..6632456ff 100644 --- a/interfaces/IBF-dashboard/.eslintrc.json +++ b/interfaces/IBF-dashboard/.eslintrc.json @@ -17,7 +17,12 @@ "plugin:@typescript-eslint/recommended" ], "rules": { - "@angular-eslint/component-class-suffix": "off", + "@angular-eslint/component-class-suffix": [ + "error", + { + "suffixes": ["Page", "Component"] + } + ], "@typescript-eslint/ban-types": "off", "@typescript-eslint/no-empty-function": "off" } From 53c935a9685f2febed8d056b809a0e79dadef6c8 Mon Sep 17 00:00:00 2001 From: arsforza Date: Mon, 4 Sep 2023 13:17:22 +0200 Subject: [PATCH 06/10] chore: disable @typescript-eslint/ban-types exception AB#23441 --- interfaces/IBF-dashboard/.eslintrc.json | 1 - .../src/app/components/chat/chat.component.ts | 10 +++++++--- .../IBF-dashboard/src/app/models/country.model.ts | 8 +++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/interfaces/IBF-dashboard/.eslintrc.json b/interfaces/IBF-dashboard/.eslintrc.json index 6632456ff..b4aac7498 100644 --- a/interfaces/IBF-dashboard/.eslintrc.json +++ b/interfaces/IBF-dashboard/.eslintrc.json @@ -23,7 +23,6 @@ "suffixes": ["Page", "Component"] } ], - "@typescript-eslint/ban-types": "off", "@typescript-eslint/no-empty-function": "off" } }, diff --git a/interfaces/IBF-dashboard/src/app/components/chat/chat.component.ts b/interfaces/IBF-dashboard/src/app/components/chat/chat.component.ts index 94430ce0f..9cf5441f9 100644 --- a/interfaces/IBF-dashboard/src/app/components/chat/chat.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/chat/chat.component.ts @@ -546,9 +546,13 @@ export class ChatComponent implements OnInit, OnDestroy { const prefixKey = 'prefix'; const prefix = this.disasterTypeSettings.monthlyForecastInfo[prefixKey]; - return this.disasterTypeSettings.monthlyForecastInfo[ - currentMonth - ].map((forecast) => + const currentMonthforecastInfo = this.disasterTypeSettings + .monthlyForecastInfo[currentMonth]; + if (typeof currentMonthforecastInfo === 'string') { + return []; + } + + return currentMonthforecastInfo.map((forecast) => this.translateService.instant(`${prefix}.${forecast}`), ); }, diff --git a/interfaces/IBF-dashboard/src/app/models/country.model.ts b/interfaces/IBF-dashboard/src/app/models/country.model.ts index d37f08293..96225ef41 100644 --- a/interfaces/IBF-dashboard/src/app/models/country.model.ts +++ b/interfaces/IBF-dashboard/src/app/models/country.model.ts @@ -6,7 +6,7 @@ export class Country { countryDisasterSettings: CountryDisasterSettings[]; countryName: string; adminRegionLabels: AdminRegionLabels; - countryLogos: {}; + countryLogos: { [disasterType: string]: string[] }; disasterTypes: DisasterType[]; notificationInfo: NotificationInfo; } @@ -17,12 +17,14 @@ export class CountryDisasterSettings { defaultAdminLevel: AdminLevel; activeLeadTimes: LeadTime[]; droughtForecastSeasons: DroughtForecastSeasons; - droughtAreas: {}; + droughtAreas: { [area: string]: string[] }; eapLink: string; showMonthlyEapActions: boolean; droughtEndOfMonthPipeline?: boolean; eapAlertClasses?: EapAlertClasses; - monthlyForecastInfo?: {}; + monthlyForecastInfo?: { + [key: string]: string[] | string; + }; enableEarlyActions?: boolean; enableStopTrigger?: boolean; } From 494f11fccd72c9a3c331df18d7a32f586f1820d7 Mon Sep 17 00:00:00 2001 From: arsforza Date: Mon, 4 Sep 2023 13:25:32 +0200 Subject: [PATCH 07/10] chore: disable @typescript-eslint/no-empty-function exception AB#23441 --- interfaces/IBF-dashboard/.eslintrc.json | 3 +-- .../IBF-dashboard/src/app/analytics/analytics.service.ts | 2 +- interfaces/IBF-dashboard/src/app/app.component.ts | 2 +- .../app/components/dialogue-turn/dialogue-turn.component.ts | 2 -- .../disclaimer-toolbar/disclaimer-toolbar.component.ts | 2 -- .../src/app/components/ibf-button/ibf-button.component.ts | 2 -- .../src/app/components/map-controls/map-controls.component.ts | 4 +--- .../src/app/components/timestamp/timestamp.component.ts | 2 -- .../components/tooltip-popover/tooltip-popover.component.ts | 2 -- interfaces/IBF-dashboard/src/app/services/api.service.ts | 2 +- .../IBF-dashboard/src/app/services/disaster-type.service.ts | 2 -- interfaces/IBF-dashboard/src/app/services/loader.service.ts | 2 -- .../IBF-dashboard/src/app/services/place-code.service.ts | 2 -- 13 files changed, 5 insertions(+), 24 deletions(-) diff --git a/interfaces/IBF-dashboard/.eslintrc.json b/interfaces/IBF-dashboard/.eslintrc.json index b4aac7498..e97292393 100644 --- a/interfaces/IBF-dashboard/.eslintrc.json +++ b/interfaces/IBF-dashboard/.eslintrc.json @@ -22,8 +22,7 @@ { "suffixes": ["Page", "Component"] } - ], - "@typescript-eslint/no-empty-function": "off" + ] } }, { diff --git a/interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts b/interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts index 2fb62b1e3..3ad0d428e 100644 --- a/interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts +++ b/interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts @@ -13,7 +13,7 @@ import { CountryService } from '../services/country.service'; providedIn: 'root', }) export class AnalyticsService { - private log = DEBUG_LOG ? console.log : () => {}; + private log = DEBUG_LOG ? console.log : () => undefined; applicationInsights: ApplicationInsights; isApplicationInsightsEnabled: boolean; diff --git a/interfaces/IBF-dashboard/src/app/app.component.ts b/interfaces/IBF-dashboard/src/app/app.component.ts index b0f12180c..4d76777cd 100644 --- a/interfaces/IBF-dashboard/src/app/app.component.ts +++ b/interfaces/IBF-dashboard/src/app/app.component.ts @@ -32,7 +32,7 @@ export class AppComponent implements OnDestroy { initializeApp() { this.translateService.setDefaultLang(this.defaultLanguage); this.translateService.use(this.defaultLanguage); - this.platform.ready().then(() => {}); + this.platform.ready(); } ngOnDestroy() { diff --git a/interfaces/IBF-dashboard/src/app/components/dialogue-turn/dialogue-turn.component.ts b/interfaces/IBF-dashboard/src/app/components/dialogue-turn/dialogue-turn.component.ts index f25268880..d12a2bb73 100644 --- a/interfaces/IBF-dashboard/src/app/components/dialogue-turn/dialogue-turn.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/dialogue-turn/dialogue-turn.component.ts @@ -49,8 +49,6 @@ export class DialogueTurnComponent implements OnInit { animate = false; - constructor() {} - ngOnInit() { this.isSelf = this.actor === Actor.self; this.isSystem = this.actor === Actor.system; diff --git a/interfaces/IBF-dashboard/src/app/components/disclaimer-toolbar/disclaimer-toolbar.component.ts b/interfaces/IBF-dashboard/src/app/components/disclaimer-toolbar/disclaimer-toolbar.component.ts index 5836da4d2..d402954fe 100644 --- a/interfaces/IBF-dashboard/src/app/components/disclaimer-toolbar/disclaimer-toolbar.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/disclaimer-toolbar/disclaimer-toolbar.component.ts @@ -8,6 +8,4 @@ import { environment } from '../../../environments/environment'; }) export class DisclaimerToolbarComponent { public environmentConfiguration = environment.configuration; - - constructor() {} } diff --git a/interfaces/IBF-dashboard/src/app/components/ibf-button/ibf-button.component.ts b/interfaces/IBF-dashboard/src/app/components/ibf-button/ibf-button.component.ts index 880e7b4de..759caffed 100644 --- a/interfaces/IBF-dashboard/src/app/components/ibf-button/ibf-button.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/ibf-button/ibf-button.component.ts @@ -32,8 +32,6 @@ export class IbfButtonComponent implements OnInit { public style = ''; - constructor() {} - ngOnInit() { this.style += ` display: block; diff --git a/interfaces/IBF-dashboard/src/app/components/map-controls/map-controls.component.ts b/interfaces/IBF-dashboard/src/app/components/map-controls/map-controls.component.ts index eedc6f1ff..308ae7aec 100644 --- a/interfaces/IBF-dashboard/src/app/components/map-controls/map-controls.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/map-controls/map-controls.component.ts @@ -5,6 +5,4 @@ import { Component } from '@angular/core'; templateUrl: './map-controls.component.html', styleUrls: ['./map-controls.component.scss'], }) -export class MapControlsComponent { - constructor() {} -} +export class MapControlsComponent {} diff --git a/interfaces/IBF-dashboard/src/app/components/timestamp/timestamp.component.ts b/interfaces/IBF-dashboard/src/app/components/timestamp/timestamp.component.ts index ba27b0e31..003ea97d3 100644 --- a/interfaces/IBF-dashboard/src/app/components/timestamp/timestamp.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/timestamp/timestamp.component.ts @@ -15,8 +15,6 @@ export class TimestampComponent implements OnInit { public displayDate: string; public displayTime: string; - constructor() {} - ngOnInit() { this.displayDate = this.timestamp?.toFormat(this.dateFormat); this.displayTime = this.timestamp?.toFormat(this.timeFormat); diff --git a/interfaces/IBF-dashboard/src/app/components/tooltip-popover/tooltip-popover.component.ts b/interfaces/IBF-dashboard/src/app/components/tooltip-popover/tooltip-popover.component.ts index 926c5f2c5..8ccd7db26 100644 --- a/interfaces/IBF-dashboard/src/app/components/tooltip-popover/tooltip-popover.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/tooltip-popover/tooltip-popover.component.ts @@ -8,6 +8,4 @@ import { Component, Input } from '@angular/core'; export class TooltipPopoverComponent { @Input() public value: string; - - constructor() {} } diff --git a/interfaces/IBF-dashboard/src/app/services/api.service.ts b/interfaces/IBF-dashboard/src/app/services/api.service.ts index 18821ec60..9361db2f8 100644 --- a/interfaces/IBF-dashboard/src/app/services/api.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/api.service.ts @@ -21,7 +21,7 @@ import { EventSummary } from './event.service'; providedIn: 'root', }) export class ApiService { - private log = DEBUG_LOG ? console.log : () => {}; + private log = DEBUG_LOG ? console.log : () => undefined; constructor(private jwtService: JwtService, private http: HttpClient) {} diff --git a/interfaces/IBF-dashboard/src/app/services/disaster-type.service.ts b/interfaces/IBF-dashboard/src/app/services/disaster-type.service.ts index 4de72d66b..f12782faf 100644 --- a/interfaces/IBF-dashboard/src/app/services/disaster-type.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/disaster-type.service.ts @@ -10,8 +10,6 @@ export class DisasterTypeService { private disasterTypeSubject = new BehaviorSubject(null); public disasterType: DisasterType; - constructor() {} - getDisasterTypeSubscription = (): Observable => { return this.disasterTypeSubject.asObservable(); }; diff --git a/interfaces/IBF-dashboard/src/app/services/loader.service.ts b/interfaces/IBF-dashboard/src/app/services/loader.service.ts index d7bd55093..5d8447b0f 100644 --- a/interfaces/IBF-dashboard/src/app/services/loader.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/loader.service.ts @@ -8,8 +8,6 @@ export class LoaderService { private loaderSubject = new BehaviorSubject(false); private queue = []; - constructor() {} - getLoaderSubscription(): Observable { return this.loaderSubject.asObservable(); } diff --git a/interfaces/IBF-dashboard/src/app/services/place-code.service.ts b/interfaces/IBF-dashboard/src/app/services/place-code.service.ts index 4bb2d3bdf..0966419ad 100644 --- a/interfaces/IBF-dashboard/src/app/services/place-code.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/place-code.service.ts @@ -9,8 +9,6 @@ export class PlaceCodeService { private placeCodeSubject = new BehaviorSubject(null); private placeCodeHoverSubject = new BehaviorSubject(null); - constructor() {} - getPlaceCodeSubscription(): Observable { return this.placeCodeSubject.asObservable(); } From b3dfb156d5a31860d3736d6349e40a59251a1e84 Mon Sep 17 00:00:00 2001 From: arsforza Date: Mon, 4 Sep 2023 13:26:48 +0200 Subject: [PATCH 08/10] fix: rm console.log AB#17794 --- interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts b/interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts index 3ad0d428e..cca8b18ae 100644 --- a/interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts +++ b/interfaces/IBF-dashboard/src/app/analytics/analytics.service.ts @@ -107,7 +107,6 @@ export class AnalyticsService { error: Error, severityLevel: SeverityLevel = SeverityLevel.Error, ) { - console.log('=== error type: ', typeof error); switch (severityLevel) { case SeverityLevel.Critical: case SeverityLevel.Error: From 86516d5558ac477e776e04c1b60d7e9cbbba4479 Mon Sep 17 00:00:00 2001 From: arsforza Date: Mon, 4 Sep 2023 15:24:22 +0200 Subject: [PATCH 09/10] chore: enable noPropertyAccessFromIndexSignature AB#17794 --- .../src/app/components/map/map.component.ts | 8 ++++---- .../dashboard/activation-log/activation.log.page.ts | 4 ++-- .../IBF-dashboard/src/app/services/country.service.ts | 4 ++-- .../src/app/services/map-legend.service.ts | 2 +- .../IBF-dashboard/src/app/services/map.service.ts | 8 +++++--- interfaces/IBF-dashboard/tsconfig.json | 10 +++++----- 6 files changed, 19 insertions(+), 17 deletions(-) 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 37588bd0e..dbe76e4fa 100644 --- a/interfaces/IBF-dashboard/src/app/components/map/map.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/map/map.component.ts @@ -236,7 +236,7 @@ export class MapComponent implements AfterViewInit, OnDestroy { let zoomExtraOffset: number; if (this.placeCode) { adminRegionsFiltered.features = adminRegionsLayer.data?.features.filter( - (area) => area?.properties?.placeCode === this.placeCode, + (area) => area?.properties?.['placeCode'] === this.placeCode, ); zoomExtraOffset = 0.1; } else { @@ -750,7 +750,7 @@ export class MapComponent implements AfterViewInit, OnDestroy { feature, ): string { feature = activeAggregateLayer.data?.features.find( - (f) => f.properties?.placeCode === feature.properties.placeCode, + (f) => f.properties?.['placeCode'] === feature.properties.placeCode, ); return ( '' + @@ -857,10 +857,10 @@ export class MapComponent implements AfterViewInit, OnDestroy { const dates = layer.data?.features .filter( (f) => - DateTime.fromISO(f.properties?.timestampOfTrackpoint) <= + DateTime.fromISO(f.properties?.['timestampOfTrackpoint']) <= DateTime.fromISO(this.lastModelRunDate), ) - .map((t) => DateTime.fromISO(t.properties?.timestampOfTrackpoint)); + .map((t) => DateTime.fromISO(t.properties?.['timestampOfTrackpoint'])); this.closestPointToTyphoon = Math.max.apply(null, dates); } diff --git a/interfaces/IBF-dashboard/src/app/pages/dashboard/activation-log/activation.log.page.ts b/interfaces/IBF-dashboard/src/app/pages/dashboard/activation-log/activation.log.page.ts index 7a7e6884b..ec57d15a5 100644 --- a/interfaces/IBF-dashboard/src/app/pages/dashboard/activation-log/activation.log.page.ts +++ b/interfaces/IBF-dashboard/src/app/pages/dashboard/activation-log/activation.log.page.ts @@ -36,8 +36,8 @@ export class ActivationLogPage implements OnInit, OnDestroy { private disasterTypeService: DisasterTypeService, ) { this.activatedRoute.queryParams.subscribe((params) => { - this.countryCodeISO3 = params.countryCodeISO3; - this.disasterType = params.disasterType as DisasterTypeKey; + this.countryCodeISO3 = params?.['countryCodeISO3']; + this.disasterType = params?.['disasterType'] as DisasterTypeKey; }); } diff --git a/interfaces/IBF-dashboard/src/app/services/country.service.ts b/interfaces/IBF-dashboard/src/app/services/country.service.ts index 2057465e8..f1fdc6bc4 100644 --- a/interfaces/IBF-dashboard/src/app/services/country.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/country.service.ts @@ -19,10 +19,10 @@ export class CountryService { private activatedRoute: ActivatedRoute, ) { this.activatedRoute.queryParams.subscribe((params) => { - if (params.countryCodeISO3) { + if (params?.['countryCodeISO3']) { this.apiService.getCountries(null, true).subscribe((countries) => { this.countries = countries; - this.selectCountry(params.countryCodeISO3); + this.selectCountry(params?.['countryCodeISO3']); }); } else { this.authService.getAuthSubscription().subscribe(this.onUserChange); diff --git a/interfaces/IBF-dashboard/src/app/services/map-legend.service.ts b/interfaces/IBF-dashboard/src/app/services/map-legend.service.ts index d160cff42..82daf4e46 100644 --- a/interfaces/IBF-dashboard/src/app/services/map-legend.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/map-legend.service.ts @@ -141,7 +141,7 @@ export class MapLegendService { element += this.layerTitle(layer.label, layer.unit); const noDataEntryFound = layer.data?.features.find( - (f) => f.properties?.indicators[layer.name] === null, + (f) => f.properties?.['indicators'][layer.name] === null, ); element += `
`; if (noDataEntryFound) { diff --git a/interfaces/IBF-dashboard/src/app/services/map.service.ts b/interfaces/IBF-dashboard/src/app/services/map.service.ts index 9ba03c237..ec056d22f 100644 --- a/interfaces/IBF-dashboard/src/app/services/map.service.ts +++ b/interfaces/IBF-dashboard/src/app/services/map.service.ts @@ -791,13 +791,15 @@ export class MapService { for (const area of adminRegions?.features || []) { const foundAdmDynamicEntry = admDynamicData.find( (admDynamicEntry): number => { - if (area.properties?.placeCode === admDynamicEntry.placeCode) { + if ( + area.properties?.['placeCode'] === admDynamicEntry.placeCode + ) { return admDynamicEntry.value; } }, ); - area.properties.indicators = {}; - area.properties.indicators[layerName] = foundAdmDynamicEntry + area['properties']['indicators'] = {}; + area['properties']['indicators'][layerName] = foundAdmDynamicEntry ? foundAdmDynamicEntry.value : null; updatedFeatures.push(area); diff --git a/interfaces/IBF-dashboard/tsconfig.json b/interfaces/IBF-dashboard/tsconfig.json index 5eddcbc9f..a75664e68 100644 --- a/interfaces/IBF-dashboard/tsconfig.json +++ b/interfaces/IBF-dashboard/tsconfig.json @@ -12,7 +12,7 @@ "forceConsistentCasingInFileNames": true, "strict": false, "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": false, + "noPropertyAccessFromIndexSignature": true, "noImplicitReturns": false, "noFallthroughCasesInSwitch": true, "sourceMap": true, @@ -29,9 +29,9 @@ ] }, "angularCompilerOptions": { - "enableI18nLegacyMessageIdFormat": false, - "strictInjectionParameters": false, - "strictInputAccessModifiers": false, - "strictTemplates": false, + "enableI18nLegacyMessageIdFormat": true, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true, } } From ed31a34e6ad9bb398381397f929fd64ea24c5db1 Mon Sep 17 00:00:00 2001 From: arsforza Date: Mon, 18 Sep 2023 14:33:54 +0200 Subject: [PATCH 10/10] fix: production build AB#23656 --- .../src/app/components/chat/chat.component.html | 4 ++-- .../src/app/components/chat/chat.component.ts | 3 +++ .../dialogue-turn/dialogue-turn.component.ts | 6 +----- .../event-speech-bubble.component.html | 14 +++++++------- .../components/timestamp/timestamp.component.ts | 2 +- interfaces/IBF-dashboard/src/app/types/chat.ts | 4 ++++ .../IBF-dashboard/src/app/types/eap-action.ts | 1 + .../IBF-dashboard/src/app/types/indicator-group.ts | 1 + 8 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 interfaces/IBF-dashboard/src/app/types/chat.ts diff --git a/interfaces/IBF-dashboard/src/app/components/chat/chat.component.html b/interfaces/IBF-dashboard/src/app/components/chat/chat.component.html index b1afe72ef..d86dc998a 100644 --- a/interfaces/IBF-dashboard/src/app/components/chat/chat.component.html +++ b/interfaces/IBF-dashboard/src/app/components/chat/chat.component.html @@ -158,7 +158,7 @@ diff --git a/interfaces/IBF-dashboard/src/app/components/chat/chat.component.ts b/interfaces/IBF-dashboard/src/app/components/chat/chat.component.ts index 9cf5441f9..634b4bddd 100644 --- a/interfaces/IBF-dashboard/src/app/components/chat/chat.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/chat/chat.component.ts @@ -26,6 +26,7 @@ import { EventState } from 'src/app/types/event-state'; import { TimelineState } from 'src/app/types/timeline-state'; import { AggregatesService } from '../../services/aggregates.service'; import { TimelineService } from '../../services/timeline.service'; +import { Actor } from '../../types/chat'; import { Indicator } from '../../types/indicator-group'; import { LeadTimeTriggerKey, LeadTimeUnit } from '../../types/lead-time'; import { TriggeredArea } from '../../types/triggered-area'; @@ -78,6 +79,8 @@ export class ChatComponent implements OnInit, OnDestroy { private lastModelRunDateFormat = 'cccc, dd LLLL HH:mm'; public isWarn = false; + public actor = Actor; + constructor( private eapActionsService: EapActionsService, public authService: AuthService, diff --git a/interfaces/IBF-dashboard/src/app/components/dialogue-turn/dialogue-turn.component.ts b/interfaces/IBF-dashboard/src/app/components/dialogue-turn/dialogue-turn.component.ts index d12a2bb73..963ace3d3 100644 --- a/interfaces/IBF-dashboard/src/app/components/dialogue-turn/dialogue-turn.component.ts +++ b/interfaces/IBF-dashboard/src/app/components/dialogue-turn/dialogue-turn.component.ts @@ -1,10 +1,6 @@ import { Component, Input, OnInit } from '@angular/core'; import { DateTime } from 'luxon'; - -enum Actor { - system = 'system', - self = 'self', -} +import { Actor } from '../../types/chat'; @Component({ selector: 'app-dialogue-turn', 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 f6dd21d57..639773630 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 @@ -1,10 +1,10 @@ @@ -190,9 +190,9 @@

- +

+