Skip to content

Commit

Permalink
Merge pull request #1758 from rodekruis/fix.zmb-bugs
Browse files Browse the repository at this point in the history
Fix.zmb bugs
  • Loading branch information
jannisvisser authored Nov 8, 2024
2 parents df0af52 + 67e18a0 commit b7eb1ab
Show file tree
Hide file tree
Showing 102 changed files with 791 additions and 133,890 deletions.
5 changes: 3 additions & 2 deletions interfaces/IBF-dashboard/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = tseslint.config(
'no-relative-import-paths/no-relative-import-paths': 'warn',
'regexp/no-unused-capturing-group': 'warn',
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
'@typescript-eslint/no-unnecessary-condition': 'warn',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/prefer-includes': 'warn',
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'warn',
Expand All @@ -70,7 +70,8 @@ module.exports = tseslint.config(
'@typescript-eslint/no-inferrable-types': 'warn',
'@typescript-eslint/no-extraneous-class': 'warn',
'@typescript-eslint/consistent-type-definitions': 'warn',
'@angular-eslint/prefer-standalone': 'warn',
// Put this to 'off' for now because it automatically tries to fix this in code on save
'@angular-eslint/prefer-standalone': 'off',
'@angular-eslint/prefer-on-push-component-change-detection': 'warn',
'@angular-eslint/component-class-suffix': 'warn',
'@angular-eslint/no-async-lifecycle-method': 'warn',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
AnalyticsPage,
} from 'src/app/analytics/analytics.enum';
import { AnalyticsService } from 'src/app/analytics/analytics.service';
import { LayerControlInfoPopoverComponent } from 'src/app/components/layer-control-info-popover/layer-control-info-popover.component';
import {
Country,
CountryDisasterSettings,
Expand All @@ -25,19 +26,18 @@ import {
AreaStatus,
} from 'src/app/services/aggregates.service';
import { CountryService } from 'src/app/services/country.service';
import { DisasterTypeService } from 'src/app/services/disaster-type.service';
import { EapActionsService } from 'src/app/services/eap-actions.service';
import { EventService } from 'src/app/services/event.service';
import { MapViewService } from 'src/app/services/map-view.service';
import { PlaceCodeService } from 'src/app/services/place-code.service';
import { AdminLevelType } from 'src/app/types/admin-level';
import { EventState } from 'src/app/types/event-state';
import { IbfLayerName } from 'src/app/types/ibf-layer';
import { Indicator, NumberFormat } from 'src/app/types/indicator-group';
import { firstCharOfWordsToUpper } from '../../../shared/utils';
import { DisasterTypeService } from '../../services/disaster-type.service';
import { EapActionsService } from '../../services/eap-actions.service';
import { MapViewService } from '../../services/map-view.service';
import { AdminLevelType } from '../../types/admin-level';
import { MapView } from '../../types/map-view';
import { TriggeredArea } from '../../types/triggered-area';
import { LayerControlInfoPopoverComponent } from '../layer-control-info-popover/layer-control-info-popover.component';
import { MapView } from 'src/app/types/map-view';
import { TriggeredArea } from 'src/app/types/triggered-area';
import { firstCharOfWordsToUpper } from 'src/shared/utils';
@Component({
selector: 'app-aggregates',
templateUrl: './aggregates.component.html',
Expand Down Expand Up @@ -221,9 +221,7 @@ export class AggregatesComponent implements OnInit, OnDestroy {

private getPopoverText(indicator: Indicator): string {
if (
indicator.description &&
indicator.description[this.country.countryCodeISO3] &&
indicator.description[this.country.countryCodeISO3][
indicator.description?.[this.country.countryCodeISO3]?.[
this.disasterType.disasterType
]
) {
Expand Down Expand Up @@ -267,7 +265,7 @@ export class AggregatesComponent implements OnInit, OnDestroy {
headerLabel: this.translateService.instant(
'aggregates-component.national-view',
),
subHeaderLabel: `${this.getAreaCount()} ${
subHeaderLabel: `${this.getEventCount()} ${
this.countryDisasterSettings?.isEventBased
? `${this.translateService.instant(
'aggregates-component.predicted',
Expand Down Expand Up @@ -338,10 +336,8 @@ export class AggregatesComponent implements OnInit, OnDestroy {

private getAdminAreaLabel(singularPlural?: string) {
if (
!this.country ||
!this.country.adminRegionLabels ||
!this.adminLevelService ||
!this.adminLevelService.adminLevel
!this.country?.adminRegionLabels ||
!this.adminLevelService?.adminLevel
) {
return '';
}
Expand Down Expand Up @@ -393,6 +389,7 @@ export class AggregatesComponent implements OnInit, OnDestroy {
public isActiveAreas(): boolean {
return this.areaStatus === AreaStatus.TriggeredOrWarned ? true : false;
}

private getAreaCount(): number {
return (
(this.isActiveAreas()
Expand All @@ -401,6 +398,12 @@ export class AggregatesComponent implements OnInit, OnDestroy {
);
}

private getEventCount(): number {
return this.countryDisasterSettings?.isEventBased
? (this.eventState?.events?.length ?? 0)
: this.getAreaCount();
}

private onTriggeredAreasChange = (triggeredAreas: TriggeredArea[]) => {
if (!triggeredAreas) {
this.triggeredPlaceCodes = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,15 @@ export class BackendMockScenarioComponent implements OnInit, OnDestroy {
text: this.alertButtonNoTriggerLabel,
cssClass: 'no-trigger-scenario-button',
handler: (data) => {
this.mockApiRefresh(data.secret, false, true, false, alert);
this.mockApiRefresh(data.secret, false, true, alert);
return false;
},
},
{
text: this.alertButtonTriggerLabel,
cssClass: 'trigger-scenario-button',
handler: (data) => {
this.mockApiRefresh(data.secret, true, true, false, alert);
alert.dismiss(true);
this.mockApiRefresh(data.secret, true, true, alert);
return false;
},
},
Expand All @@ -153,7 +152,6 @@ export class BackendMockScenarioComponent implements OnInit, OnDestroy {
secret: string,
triggered: boolean,
removeEvents: boolean,
oldEvent: boolean,
alert: HTMLIonAlertElement,
) {
if (secret) {
Expand All @@ -166,11 +164,13 @@ export class BackendMockScenarioComponent implements OnInit, OnDestroy {
this.disasterType,
)
.subscribe({
next: () => this.processMockSuccess(secret, oldEvent, alert),
next: () => {
this.processMockSuccess(alert);
},
error: (response) => {
// Somehow the endpoint returns an error together with the 202 status.. Ignore.
if (response.status === 202) {
this.processMockSuccess(secret, oldEvent, alert);
this.processMockSuccess(alert);
} else {
console.log('response: ', response);
this.presentToast(this.alertErrorApiError);
Expand All @@ -182,11 +182,8 @@ export class BackendMockScenarioComponent implements OnInit, OnDestroy {
}
}

private processMockSuccess(secret, oldEvent, alert) {
private processMockSuccess(alert) {
this.countryService.selectCountry(this.country.countryCodeISO3);
if (oldEvent) {
this.mockApiRefresh(secret, false, false, false, alert);
}
alert.dismiss(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { JoinColumn, ManyToOne } from 'typeorm';

import { DynamicDataPlaceCodeDto } from '../../admin-area-dynamic-data/dto/dynamic-data-place-code.dto';
import indicatorData from '../../admin-area-dynamic-data/dto/example/ETH/malaria/upload-potential_cases-3.json';
import indicatorData from '../../admin-area-dynamic-data/dto/example/ETH/drought/upload-alert_threshold-2.json';
import { UpdateableStaticIndicator } from '../../admin-area-dynamic-data/enum/dynamic-data-unit';
import { AdminLevel } from '../../country/admin-level.enum';
import { CountryEntity } from '../../country/country.entity';
Expand Down
Loading

0 comments on commit b7eb1ab

Please sign in to comment.