Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSO documentation + integration tests #1918

Merged
merged 6 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions interfaces/IBF-dashboard/src/app/components/map/map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,42 +741,6 @@ export class MapComponent implements AfterViewInit, OnDestroy {
);
}

private createDefaultPopupAdminRegions(
activeAggregateLayer: IbfLayer,
feature,
): string {
feature = activeAggregateLayer.data?.features.find(
(f) => f.properties?.['placeCode'] === feature.properties.placeCode,
);
return (
'<strong>' +
feature.properties.name +
(feature.properties.placeCode.includes('Disputed')
? ' (Disputed borders)'
: '') +
'</strong>' +
(feature.properties.nameParent
? ` (${feature.properties.nameParent})`
: '') +
'<br/>' +
(!activeAggregateLayer
? ''
: activeAggregateLayer.label +
': ' +
this.numberFormat(
typeof feature.properties[activeAggregateLayer.colorProperty] !==
'undefined'
? feature.properties[activeAggregateLayer.colorProperty]
: feature.properties.indicators[
activeAggregateLayer.colorProperty
],
activeAggregateLayer,
) +
' ' +
(activeAggregateLayer.unit || ''))
);
}

private createAdminRegionsLayer(layer: IbfLayer): GeoJSON {
if (!layer.data) {
return;
Expand Down
41 changes: 8 additions & 33 deletions interfaces/IBF-dashboard/src/app/services/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ export class MapService {
public layers = [] as IbfLayer[];
private triggeredAreaColor = 'var(--ion-color-ibf-outline-red)';
private nonTriggeredAreaColor = 'var(--ion-color-ibf-no-alert-primary)';
private disputedBorderStyle: {
weight: number;
dashArray: string;
color: string;
} = {
weight: 2,
dashArray: '5 5',
color: null,
};
private layerDataCache: Record<string, GeoJSON.FeatureCollection> = {};

public state = {
Expand Down Expand Up @@ -255,40 +246,35 @@ export class MapService {
layer: IbfLayerMetadata,
layerActive: boolean,
) => {
const layerName =
layer.name === IbfLayerName.redCrescentBranches
? IbfLayerName.redCrossBranches
: layer.name;
if (this.country) {
if (layerActive) {
this.apiService
.getPointData(
this.country.countryCodeISO3,
layerName,
layer.name,
this.disasterType.disasterType,
)
.subscribe((pointData) => {
this.addPointDataLayer(layer, layerName, pointData);
this.addPointDataLayer(layer, pointData);
});
} else {
this.addPointDataLayer(layer, layerName, null);
this.addPointDataLayer(layer, null);
}
}
};

private addPointDataLayer = (
layer: IbfLayerMetadata,
layerName: IbfLayerName,
pointData: GeoJSON.FeatureCollection,
) => {
this.addLayer({
name: layerName,
name: layer.name,
label: layer.label,
type: IbfLayerType.point,
group: IbfLayerGroup.point,
description: this.getPopoverText(layer),
active: this.adminLevelService.activeLayerNames.length
? this.adminLevelService.activeLayerNames.includes(layerName)
? this.adminLevelService.activeLayerNames.includes(layer.name)
: this.getActiveState(layer),
show: true,
data: pointData,
Expand Down Expand Up @@ -632,14 +618,10 @@ export class MapService {
.pipe(shareReplay(1));
} else if (layer.type === IbfLayerType.point) {
// NOTE: any non-standard point layers should be placed above this 'else if'!
const layerName =
layer.name === IbfLayerName.redCrescentBranches
? IbfLayerName.redCrossBranches
: layer.name;
layerData = this.apiService
.getPointData(
this.country.countryCodeISO3,
layerName,
layer.name,
this.disasterType.disasterType,
)
.pipe(shareReplay(1));
Expand Down Expand Up @@ -943,20 +925,13 @@ export class MapService {
colorThreshold,
);
const fillOpacity = this.getAdminRegionFillOpacity(layer);
let weight = this.getAdminRegionWeight(layer, placeCode);
let color = this.getAdminRegionColor(layer);
let dashArray: string;
if (placeCode?.includes('Disputed')) {
dashArray = this.disputedBorderStyle.dashArray;
weight = this.disputedBorderStyle.weight;
color = this.disputedBorderStyle.color;
}
const weight = this.getAdminRegionWeight(layer, placeCode);
const color = this.getAdminRegionColor(layer);
return {
fillColor,
fillOpacity,
weight,
color,
dashArray,
};
}
};
Expand Down
2 changes: 0 additions & 2 deletions interfaces/IBF-dashboard/src/app/types/ibf-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ export enum IbfLayerName {
rainfall = 'rainfall',
rainfallExtent = 'rainfall_extent',
rainfallForecast = 'rainfall_forecast',
redCrescentBranches = 'red_crescent_branches',
jannisvisser marked this conversation as resolved.
Show resolved Hide resolved
redCrossBranches = 'red_cross_branches',
roads = 'roads',
roof_type = 'roof_type',
Expand Down Expand Up @@ -142,7 +141,6 @@ export enum IbfLayerLabel {
population = 'Population',
populationTotal = 'Total Population',
rainfallExtent = 'Rainfall extent',
redCrescentBranches = 'Red Crescent branches',
redCrossBranches = 'Red Cross branches',
typhoonTrack = 'Typhoon track',
waterpoints = 'Waterpoints',
Expand Down
43 changes: 43 additions & 0 deletions services/API-service/module-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Module Dependencies Graph

```mermaid
graph LR
EapActionsModule-->UserModule
UserModule-->LookupModule
WaterpointsModule-->UserModule
WaterpointsModule-->CountryModule
CountryModule-->UserModule
AdminAreaModule-->UserModule
AdminAreaModule-->EventModule
EventModule-->UserModule
EventModule-->CountryModule
EventModule-->EapActionsModule
EventModule-->TyphoonTrackModule
TyphoonTrackModule-->UserModule
AdminAreaModule-->CountryModule
AdminAreaDynamicDataModule-->UserModule
AdminAreaDynamicDataModule-->EventModule
AdminAreaDynamicDataModule-->CountryModule
AdminAreaDynamicDataModule-->AdminAreaModule
MetadataModule-->UserModule
MetadataModule-->CountryModule
MetadataModule-->EventModule
PointDataModule-->UserModule
PointDataModule-->WhatsappModule
WhatsappModule-->LookupModule
WhatsappModule-->EventModule
WhatsappModule-->NotificationContentModule
NotificationContentModule-->EventModule
NotificationContentModule-->AdminAreaDynamicDataModule
NotificationContentModule-->AdminAreaDataModule
AdminAreaDataModule-->UserModule
NotificationContentModule-->AdminAreaModule
LinesDataModule-->UserModule
NotificationModule-->UserModule
NotificationModule-->EventModule
NotificationModule-->AdminAreaDynamicDataModule
NotificationModule-->WhatsappModule
NotificationModule-->NotificationContentModule
NotificationModule-->TyphoonTrackModule
CronjobModule-->AdminAreaDynamicDataModule
```
49 changes: 49 additions & 0 deletions services/API-service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions services/API-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"mailchimp-api-v3": "^1.15.0",
"mjml": "^4.15.3",
"mysql": "^2.15.0",
"nestjs-spelunker": "^1.3.1",
"pg": "^8.13.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0",
Expand Down
9 changes: 8 additions & 1 deletion services/API-service/src/api/country/country.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common';
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';

import { In, Repository } from 'typeorm';
Expand Down Expand Up @@ -222,6 +222,13 @@ export class CountryService {
where: { countryCodeISO3: notificationInfoCountry.countryCodeISO3 },
relations: ['notificationInfo'],
});
if (!existingCountry) {
// It is not ideal to throw an error halfway, but it's at least better than the 500 error that currently would occur
throw new HttpException(
`Country with code ${notificationInfoCountry.countryCodeISO3} not found. If multiple countries passed, then earlier countries have processed correctly, later countries have not.`,
HttpStatus.NOT_FOUND,
);
}

if (existingCountry.notificationInfo) {
existingCountry.notificationInfo = await this.createNotificationInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ export class IndicatorDto {
@ApiProperty({
example: {
UGA: {
floods:
'This layer represents the locations of the local branches, the source of this data comes from the National Society and may need updating.<br /><br />Source link: Egyptian Red Crescent Society (ERCS). Year: 2020.',
floods: 'description',
},
},
})
Expand Down
3 changes: 1 addition & 2 deletions services/API-service/src/api/metadata/dto/add-layers.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ export class LayerDto {
@ApiProperty({
example: {
UGA: {
'heavy-rain':
'This layer represents the locations of the local branches, the source of this data comes from the National Society and may need updating.<br /><br />Source link: Egyptian Red Crescent Society (ERCS). Year: 2020.',
'heavy-rain': 'description',
},
},
})
Expand Down
Loading
Loading