diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e9cf095f..724339f9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## [0.277.10](https://github.com/rodekruis/IBF-system/compare/v0.277.9...v0.277.10) (2024-12-24) + + +### Bug Fixes + +* add layer to cache ([8bf65ec](https://github.com/rodekruis/IBF-system/commit/8bf65ec35735e99699050c07197d70b2f2ff849c)) +* also call updateLayer if layer not active AB[#32327](https://github.com/rodekruis/IBF-system/issues/32327) ([1983a65](https://github.com/rodekruis/IBF-system/commit/1983a65eac9fb3ceab64674afe863bfa46bbf194)) +* remove waterpoints cache ([5956067](https://github.com/rodekruis/IBF-system/commit/5956067133c0aeccf4fdcae1554cf0e562ac91be)) + + + ## [0.277.9](https://github.com/rodekruis/IBF-system/compare/v0.277.8...v0.277.9) (2024-12-23) @@ -77,18 +88,3 @@ -# [0.277.0](https://github.com/rodekruis/IBF-system/compare/v0.276.9...v0.277.0) (2024-12-02) - - -### Bug Fixes - -* update adm3 areas blantyre city ([ef891ce](https://github.com/rodekruis/IBF-system/commit/ef891ce7674da761519dc7d3a5653120b64f8c26)) -* update blantyre mock data ([26e49b4](https://github.com/rodekruis/IBF-system/commit/26e49b4d9c5f7c091b93a6afb8b770838451e65f)) - - -### Features - -* add blantyre only scenario ([fcda9ce](https://github.com/rodekruis/IBF-system/commit/fcda9ce4122e8e71df085377388191389372f526)) - - - diff --git a/interfaces/IBF-dashboard/src/app/components/matrix/matrix.component.html b/interfaces/IBF-dashboard/src/app/components/matrix/matrix.component.html index 5b20af8ca..842acddda 100644 --- a/interfaces/IBF-dashboard/src/app/components/matrix/matrix.component.html +++ b/interfaces/IBF-dashboard/src/app/components/matrix/matrix.component.html @@ -24,7 +24,7 @@ @if (layer.isLoading) { - + } @else { @if (isCheckBox(layer.group)) { = {}; public state = { bounds: [ @@ -192,7 +197,7 @@ export class MapService { }); }; - private async loadLayers() { + private loadLayers() { this.layers = []; this.layerSubject.next(null); @@ -295,18 +300,12 @@ export class MapService { }; private loadWaterPointsLayer = (layer: IbfLayerMetadata) => { - const layerDataCacheKey = this.getLayerDataCacheKey(layer.name); - if (this.layerDataCache[layerDataCacheKey]) { - this.addWaterPointsLayer(layer, this.layerDataCache[layerDataCacheKey]); - } else { - this.addWaterPointsLayer(layer, null); - this.apiService - .getWaterPoints(this.country.countryCodeISO3) - .subscribe((waterPoints) => { - this.addWaterPointsLayer(layer, waterPoints); - this.layerDataCache[layerDataCacheKey] = waterPoints; - }); - } + this.addWaterPointsLayer(layer, null); + this.apiService + .getWaterPoints(this.country.countryCodeISO3) + .subscribe((waterPoints) => { + this.addWaterPointsLayer(layer, waterPoints); + }); }; private addWaterPointsLayer( @@ -355,8 +354,9 @@ export class MapService { adminLevel: AdminLevel, ) { this.addLayer({ - name: `${IbfLayerGroup.adminRegions}${adminLevel}` as IbfLayerName, - label: `${IbfLayerGroup.adminRegions}${adminLevel}` as IbfLayerLabel, + name: `${IbfLayerGroup.adminRegions}${adminLevel.toString()}` as IbfLayerName, + label: + `${IbfLayerGroup.adminRegions}${adminLevel.toString()}` as IbfLayerLabel, group: IbfLayerGroup.adminRegions, type: IbfLayerType.shape, description: '', @@ -480,7 +480,12 @@ export class MapService { private addLayer(layer: IbfLayer): void { const { name, viewCenter, data } = layer; - if (viewCenter && data && data.features && data.features.length) { + // cache the data if available + const layerDataCacheKey = this.getLayerDataCacheKey(layer.name); + if (data) { + this.layerDataCache[layerDataCacheKey] = data; + } + if (viewCenter && data?.features?.length) { const layerBounds = bbox(data); this.state.bounds = containsNumber(layerBounds) ? ([ @@ -546,32 +551,33 @@ export class MapService { : interactedLayer.show; }; - private updateLayer = (layer: IbfLayer) => (layerData) => { - this.addLayer({ - name: layer.name, - label: layer.label, - type: layer.type, - description: layer.description, - active: this.adminLevelService.activeLayerNames.length - ? this.adminLevelService.activeLayerNames.includes(layer.name) - : layer.active, - viewCenter: false, - data: layerData, - wms: layer.wms, - colorProperty: - layer.group === IbfLayerGroup.adminRegions - ? this.disasterType.actionsUnit - : layer.colorProperty, - colorBreaks: layer.colorBreaks, - numberFormatMap: layer.numberFormatMap, - legendColor: layer.legendColor, - group: layer.group, - order: layer.order, - unit: layer.unit, - dynamic: layer.dynamic, - show: layer.show, - }); - }; + private updateLayer = + (layer: IbfLayer) => (layerData: GeoJSON.FeatureCollection) => { + this.addLayer({ + name: layer.name, + label: layer.label, + type: layer.type, + description: layer.description, + active: this.adminLevelService.activeLayerNames.length + ? this.adminLevelService.activeLayerNames.includes(layer.name) + : layer.active, + viewCenter: false, + data: layerData, + wms: layer.wms, + colorProperty: + layer.group === IbfLayerGroup.adminRegions + ? this.disasterType.actionsUnit + : layer.colorProperty, + colorBreaks: layer.colorBreaks, + numberFormatMap: layer.numberFormatMap, + legendColor: layer.legendColor, + group: layer.group, + order: layer.order, + unit: layer.unit, + dynamic: layer.dynamic, + show: layer.show, + }); + }; public toggleLayer = (layer: IbfLayer): void => { layer.active = !layer.active; @@ -583,7 +589,7 @@ export class MapService { if (layerName === IbfLayerName.waterpoints) { return `${this.country.countryCodeISO3}_${layerName}`; } else { - return `${this.country.countryCodeISO3}_${this.disasterType.disasterType}_${this.timelineState.activeLeadTime}_${this.adminLevel}_${layerName}`; + return `${this.country.countryCodeISO3}_${this.disasterType.disasterType}_${this.timelineState.activeLeadTime}_${this.adminLevel.toString()}_${layerName}`; } } @@ -598,7 +604,8 @@ export class MapService { layer.active = this.isLayerActive(layer, newLayer); layer.show = this.isLayerShown(layer, newLayer); if (this.layerDataCache[layerDataCacheKey]) { - const layerData = this.layerDataCache[layerDataCacheKey]; + const layerData: GeoJSON.FeatureCollection = + this.layerDataCache[layerDataCacheKey]; this.updateLayer(layer)(layerData); } else if (layer.active) { this.getLayerData(layer).subscribe((layerDataResponse) => { @@ -650,9 +657,7 @@ export class MapService { ) .pipe(shareReplay(1)); } else if (layer.group === IbfLayerGroup.adminRegions) { - const adminLevel = Number( - layer.name.substr(layer.name.length - 1), - ) as AdminLevel; + const adminLevel = Number(layer.name.slice(-1)) as AdminLevel; layerData = this.apiService .getAdminRegions( this.country.countryCodeISO3, @@ -753,7 +758,7 @@ export class MapService { getAdminRegionFillColor = ( colorPropertyValue, - colorThreshold, + colorThreshold: { break0: number }, placeCode: string, placeCodeParent: string, ): string => { @@ -856,7 +861,7 @@ export class MapService { }; adminLevelLowerThanDefault = (name: IbfLayerName): boolean => { - return name.substr(name.length - 1) < String(this.adminLevel); + return name.slice(-1) < String(this.adminLevel); }; getAdminRegionColor = (layer: IbfLayer): string => { @@ -865,7 +870,11 @@ export class MapService { : this.state.transparentColor; }; - public getColorThreshold = (adminRegions, colorProperty, colorBreaks) => { + public getColorThreshold = ( + adminRegions: GeoJSON.FeatureCollection, + colorProperty: string, + colorBreaks: ColorBreaks, + ): { break0: number } => { if (colorBreaks) { const colorThresholdWithBreaks = { break0: 0, @@ -878,11 +887,11 @@ export class MapService { }); return colorThresholdWithBreaks; } - const colorPropertyValues = adminRegions.features + const colorPropertyValues: number[] = adminRegions.features .map((feature) => typeof feature.properties[colorProperty] !== 'undefined' ? feature.properties[colorProperty] - : feature.properties.indicators?.[colorProperty], + : feature.properties['indicators']?.[colorProperty], ) .filter((v, i, a) => a.indexOf(v) === i); @@ -926,14 +935,14 @@ export class MapService { public setAdminRegionStyle = (layer: IbfLayer) => { const colorProperty = layer.colorProperty; - const colorThreshold = this.getColorThreshold( + const colorThreshold: { break0: number } = this.getColorThreshold( layer.data, colorProperty, layer.colorBreaks, ); return (adminRegion) => { - const colorPropertyValue = + const colorPropertyValue: string = typeof adminRegion.properties[colorProperty] !== 'undefined' ? adminRegion.properties[colorProperty] : typeof adminRegion.properties.indicators !== 'undefined' @@ -952,7 +961,7 @@ export class MapService { adminRegion.properties.placeCode, ); let color = this.getAdminRegionColor(layer); - let dashArray; + let dashArray: string; if (adminRegion.properties.placeCode?.includes('Disputed')) { dashArray = this.disputedBorderStyle.dashArray; weight = this.disputedBorderStyle.weight; diff --git a/package.json b/package.json index a03ef5e42..16476b199 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "IBF-system", - "version": "0.277.9", + "version": "0.277.10", "private": true, "scripts": { "start:services": "docker compose up -d", diff --git a/tests/e2e/README.md b/tests/e2e/README.md index d2a6bd199..f3ee20926 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -37,7 +37,7 @@ Then, in _this_ folder, run: npm install ``` -The, install Playwright Browsers(-drivers): +Then, install Playwright Browsers(-drivers): ```shell npx playwright install diff --git a/tests/e2e/tests/AggregatesSection/AggregatesHasDynamicTitle.spec.ts b/tests/e2e/tests/AggregatesSection/AggregatesHasDynamicTitle.spec.ts index bc059eee9..d531ce620 100644 --- a/tests/e2e/tests/AggregatesSection/AggregatesHasDynamicTitle.spec.ts +++ b/tests/e2e/tests/AggregatesSection/AggregatesHasDynamicTitle.spec.ts @@ -33,12 +33,8 @@ test.beforeEach(async ({ page }) => { NoTriggerDataSet.UserPassword, ); }); -// The test is skipped because of the bug that was identified during writing of this test -// The bug is that the marker of glofas stations cannot be disabled with the first chebox click (needs several) and it is failing on flood disaster type -// https://github.com/rodekruis/IBF-system/issues/1657 -// When the bug is fixed, the test should be unskipped -// https://app.qase.io/project/IBF?case=12&previewMode=side&suite=7 -test.skip( + +test( qase( 12, 'Aggregates title should be dynamic upon hovering over map district',