From 8d274971081e0eeac245e82225b35da37d776aa9 Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Wed, 18 Dec 2024 16:06:41 -0800 Subject: [PATCH 1/8] WFNEWS-2419 route back to map page from full details --- .../active-wildfire-map.component.ts | 4 +- .../draggable-panel.component.ts | 39 ++++++---- .../full-details/full-details.component.ts | 71 +++++++++++++++---- 3 files changed, 87 insertions(+), 27 deletions(-) diff --git a/client/wfnews-war/src/main/angular/src/app/components/active-wildfire-map/active-wildfire-map.component.ts b/client/wfnews-war/src/main/angular/src/app/components/active-wildfire-map/active-wildfire-map.component.ts index f28349313c..5995546fd6 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/active-wildfire-map/active-wildfire-map.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/active-wildfire-map/active-wildfire-map.component.ts @@ -490,9 +490,9 @@ export class ActiveWildfireMapComponent implements OnInit, AfterViewInit { } else if ((params['areaRestriction'] && params['areaRestriction'] === 'true') || (params['evacuationAlert'] && params['evacuationAlert'] === 'true') || (params['activeWildfires'] && params['activeWildfires'] === 'true')){ - this.panToLocation(long, lat, 12); + this.panToLocation(long, lat, params['zoom'] ? params['zoom'] : 12); } else if (params['bansProhibitions'] && params['bansProhibitions'] === 'true'){ - this.panToLocation(long, lat, 6); + this.panToLocation(long, lat, params['zoom'] ? params['zoom'] : 6); } else if (params['savedLocation'] && params['savedLocation'] === 'true') { this.panToLocation(long, lat, 8); } else { diff --git a/client/wfnews-war/src/main/angular/src/app/components/draggable-panel/draggable-panel.component.ts b/client/wfnews-war/src/main/angular/src/app/components/draggable-panel/draggable-panel.component.ts index ac018819ed..fe6bdf149a 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/draggable-panel/draggable-panel.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/draggable-panel/draggable-panel.component.ts @@ -74,7 +74,7 @@ export class DraggablePanelComponent implements OnInit, OnChanges, OnDestroy { 'active-wildfires-under-control', 'bcws-activefires-publicview-inactive', 'fire-perimeters', - "active-wildfires-out" + 'active-wildfires-out' ]; convertToDateYear = convertToDateYear; convertToDateTime = convertToDateTime; @@ -90,7 +90,7 @@ export class DraggablePanelComponent implements OnInit, OnChanges, OnDestroy { private previousZoom: number; private marker: any; private markerAnimation; - public snowPlowHelper = snowPlowHelper + public snowPlowHelper = snowPlowHelper; constructor( private publishedIncidentService: PublishedIncidentService, protected cdr: ChangeDetectorRef, @@ -175,8 +175,8 @@ export class DraggablePanelComponent implements OnInit, OnChanges, OnDestroy { if (this.currentIncidentRefs.length === 1 && this.allowBackToIncidentsPanel) { // only show preview detial if it is through openPreviewPanel(). We will always the preview list page by clicking on map, even there is only single item. this.showPanel = true; - showPanel('identify-panel-wrapper') - hidePanel('desktop-preview') + showPanel('identify-panel-wrapper'); + hidePanel('desktop-preview'); const viewer = getActiveMap().$viewer; for (const polygon of this.highlightPolygons) { viewer.map.removeLayer(polygon); @@ -187,8 +187,8 @@ export class DraggablePanelComponent implements OnInit, OnChanges, OnDestroy { // single feature within clicked area this.showPanel = true; - showPanel('identify-panel-wrapper') - hidePanel('desktop-preview') + showPanel('identify-panel-wrapper'); + hidePanel('desktop-preview'); this.identifyItem = this.currentIncidentRefs[0]; let incidentNumber = null; let fireYear = null; @@ -243,8 +243,8 @@ export class DraggablePanelComponent implements OnInit, OnChanges, OnDestroy { // multiple features within clicked area this.identifyItem = null; this.showPanel = true; - showPanel('identify-panel-wrapper') - hidePanel('desktop-preview') + showPanel('identify-panel-wrapper'); + hidePanel('desktop-preview'); this.filteredWildfires = this.currentIncidentRefs.filter((item) => this.wildfireLayerIds.includes(item.layerId), ); @@ -294,8 +294,8 @@ export class DraggablePanelComponent implements OnInit, OnChanges, OnDestroy { ); if (this.weatherStations) { this.showPanel = true; - showPanel('identify-panel-wrapper') - hidePanel('desktop-preview') + showPanel('identify-panel-wrapper'); + hidePanel('desktop-preview'); } } } @@ -587,6 +587,9 @@ return 'Unknown'; location.longitude = Number(this.identifyItem._identifyPoint.longitude); } + // detect current zoom level for routing back from full details page + const currentZoomLevel = getActiveMap().$viewer?.map?._zoom; + switch (this.identifyItem.layerId) { case 'area-restrictions': if (item.properties.NAME) { @@ -596,6 +599,9 @@ return 'Unknown'; id: item.properties.PROT_RA_SYSID, name: item.properties.NAME, source: [ResourcesRoutes.ACTIVEWILDFIREMAP], + sourceLatitude: location.latitude, + sourceLongitude: location.longitude, + sourceZoom: currentZoomLevel }, }); } @@ -607,6 +613,9 @@ return 'Unknown'; type: 'bans-prohibitions', id: item.properties.PROT_BAP_SYSID, source: [ResourcesRoutes.ACTIVEWILDFIREMAP], + sourceLatitude: location.latitude, + sourceLongitude: location.longitude, + sourceZoom: currentZoomLevel }, }); } @@ -636,6 +645,9 @@ return 'Unknown'; name: item.properties.EVENT_NAME, source: [ResourcesRoutes.ACTIVEWILDFIREMAP], eventNumber: item.properties.EVENT_NUMBER, + sourceLatitude: location.latitude, + sourceLongitude: location.longitude, + sourceZoom: currentZoomLevel }, }); break; @@ -651,8 +663,8 @@ return 'Unknown'; if (fireYear && incidentNumber) { this.router.navigate([ResourcesRoutes.PUBLIC_INCIDENT], { queryParams: { - fireYear: fireYear, - incidentNumber: incidentNumber, + fireYear, + incidentNumber, source: [ResourcesRoutes.ACTIVEWILDFIREMAP], }, }); @@ -684,6 +696,9 @@ return 'Unknown'; type: 'bans-prohibitions', id: item.properties.PROT_BAP_SYSID, source: [ResourcesRoutes.ACTIVEWILDFIREMAP], + sourceLatitude: location.latitude, + sourceLongitude: location.longitude, + sourceZoom: currentZoomLevel }, }); } diff --git a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts index 752afe6f79..0b61029b73 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts @@ -15,21 +15,21 @@ export class FullDetailsComponent implements OnInit, OnDestroy { private router: Router, private route: ActivatedRoute, private agolService: AGOLService, - ) {} + ) { } ngOnInit(): void { this.route.queryParams.subscribe((params: ParamMap) => { this.params = params; }); if (document.getElementById('mobile-navigation-bar')) { -document.getElementById('mobile-navigation-bar').style.display = 'none'; -} + document.getElementById('mobile-navigation-bar').style.display = 'none'; + } } ngOnDestroy(): void { if (document.getElementById('mobile-navigation-bar')) { -document.getElementById('mobile-navigation-bar').style.display = 'block'; -} + document.getElementById('mobile-navigation-bar').style.display = 'block'; + } } getTitle() { @@ -48,8 +48,13 @@ document.getElementById('mobile-navigation-bar').style.display = 'block'; back() { try { - if (this.params && this.params['source']) { - if ( + if (this.params?.['source']) { + if ((this.params['source'] === 'map' || this.params['source']?.[0] === 'map') + && (this.params?.['type'] === 'area-restriction' || this.params?.['type'] === 'bans-prohibitions' + || this.params?.['type'].includes('evac')) + ) { + this.backToMap(); + } else if ( this.params['source'] === 'saved-location' && this.params['sourceName'] && this.params['sourceLongitude'] && @@ -75,18 +80,58 @@ document.getElementById('mobile-navigation-bar').style.display = 'block'; }, }); } else { -this.router.navigate(this.params['source']); -} + this.router.navigate(this.params['source']); + } } else { -throw new Error('No previous screen to route too'); -} + throw new Error('No previous screen to route too'); + } } catch (err) { console.error(err); this.router.navigate([ResourcesRoutes.DASHBOARD]); } } - async exit() { - this.router.navigate([ResourcesRoutes.DASHBOARD]); + exit() { + if ((this.params?.['source'] === 'map' || this.params?.['source']?.[0] === 'map') + && (this.params?.['type'] === 'area-restriction' || this.params?.['type'] === 'bans-prohibitions' + || this.params?.['type'].includes('evac')) + ) { + this.backToMap(); + } else { + this.router.navigate([ResourcesRoutes.DASHBOARD]); + } + } + + backToMap() { + // use query params to determine the layer, coordinates and zoom level for routing back to the map + const navigateToMap = (longitude: number, latitude: number, zoom: string, queryParamKey: string) => { + setTimeout(() => { + this.router.navigate([ResourcesRoutes.ACTIVEWILDFIREMAP], { + queryParams: { + longitude, + latitude, + zoom, + [queryParamKey]: true + }, + }); + }, 100); + }; + + if(this.params['type'] && this.params['sourceLongitude'] && this.params['sourceLatitude'] && this.params['sourceZoom']) { + switch (this.params['type']) { + case 'area-restriction': + navigateToMap(this.params['sourceLongitude'], this.params['sourceLatitude'], this.params['sourceZoom'], 'areaRestriction'); + break; + case 'bans-prohibitions': + navigateToMap(this.params['sourceLongitude'], this.params['sourceLatitude'], this.params['sourceZoom'], 'bansProhibitions'); + break; + case 'evac-alert': + case 'evac-order': + navigateToMap(this.params['sourceLongitude'], this.params['sourceLatitude'], this.params['sourceZoom'], 'evacuationAlert'); + break; + } + } else { + throw new Error('Error occurred while routing back to map'); + } } } From d2865506b5994e2212716e6c99102c4253dd1474 Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Wed, 18 Dec 2024 16:09:26 -0800 Subject: [PATCH 2/8] Update comments --- .../src/app/components/full-details/full-details.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts index 0b61029b73..04c09ab5c9 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts @@ -49,6 +49,7 @@ export class FullDetailsComponent implements OnInit, OnDestroy { back() { try { if (this.params?.['source']) { + // use query params to determine the layer, coordinates and zoom level for routing back to the map if ((this.params['source'] === 'map' || this.params['source']?.[0] === 'map') && (this.params?.['type'] === 'area-restriction' || this.params?.['type'] === 'bans-prohibitions' || this.params?.['type'].includes('evac')) @@ -92,6 +93,7 @@ export class FullDetailsComponent implements OnInit, OnDestroy { } exit() { + // use query params to determine the layer, coordinates and zoom level for routing back to the map if ((this.params?.['source'] === 'map' || this.params?.['source']?.[0] === 'map') && (this.params?.['type'] === 'area-restriction' || this.params?.['type'] === 'bans-prohibitions' || this.params?.['type'].includes('evac')) @@ -103,7 +105,6 @@ export class FullDetailsComponent implements OnInit, OnDestroy { } backToMap() { - // use query params to determine the layer, coordinates and zoom level for routing back to the map const navigateToMap = (longitude: number, latitude: number, zoom: string, queryParamKey: string) => { setTimeout(() => { this.router.navigate([ResourcesRoutes.ACTIVEWILDFIREMAP], { From b3bf266e5d35eb7676172b777f511c048b8449a1 Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Wed, 18 Dec 2024 16:09:52 -0800 Subject: [PATCH 3/8] Fix typo --- .../src/app/components/full-details/full-details.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts index 04c09ab5c9..7951cbeb00 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts @@ -84,7 +84,7 @@ export class FullDetailsComponent implements OnInit, OnDestroy { this.router.navigate(this.params['source']); } } else { - throw new Error('No previous screen to route too'); + throw new Error('No previous screen to route to'); } } catch (err) { console.error(err); From 123f36f47cd5c29e4c64f23b9b575020d105e930 Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Wed, 18 Dec 2024 16:42:56 -0800 Subject: [PATCH 4/8] Update comments --- .../components/full-details/full-details.component.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts index 7951cbeb00..2146296a21 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts @@ -49,7 +49,9 @@ export class FullDetailsComponent implements OnInit, OnDestroy { back() { try { if (this.params?.['source']) { - // use query params to determine the layer, coordinates and zoom level for routing back to the map + // If the user accessed the full details page from the map, and if the full details page contains one of area restrictions, + // fire bans, evac orders or evac alerts, use the backToMap function to route back to the map using the same layer and zoom level, + // along with the appropriate coordinates for that type. if ((this.params['source'] === 'map' || this.params['source']?.[0] === 'map') && (this.params?.['type'] === 'area-restriction' || this.params?.['type'] === 'bans-prohibitions' || this.params?.['type'].includes('evac')) @@ -93,7 +95,9 @@ export class FullDetailsComponent implements OnInit, OnDestroy { } exit() { - // use query params to determine the layer, coordinates and zoom level for routing back to the map + // If the user accessed the full details page from the map, and if the full details page contains one of area restrictions, + // fire bans, evac orders or evac alerts, use the backToMap function to route back to the map using the same layer and zoom level, + // along with the appropriate coordinates for that type. if ((this.params?.['source'] === 'map' || this.params?.['source']?.[0] === 'map') && (this.params?.['type'] === 'area-restriction' || this.params?.['type'] === 'bans-prohibitions' || this.params?.['type'].includes('evac')) @@ -104,6 +108,7 @@ export class FullDetailsComponent implements OnInit, OnDestroy { } } + // use query params to determine the layer, coordinates and zoom level for routing back to the map backToMap() { const navigateToMap = (longitude: number, latitude: number, zoom: string, queryParamKey: string) => { setTimeout(() => { From 0bdccd9d9e159b04aa13a6dbd968f3e2ceb8c120 Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Wed, 18 Dec 2024 17:41:25 -0800 Subject: [PATCH 5/8] Route back to previous zoom level for bans, evacs, area restrictions on desktop --- .../area-restriction-preview.component.ts | 5 +++-- .../evacuations-preview.component.ts | 6 ++++-- .../fire-ban-preview/fire-ban-preview.component.ts | 5 +++-- .../incident-header-panel.component.ts | 11 +++++++---- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/client/wfnews-war/src/main/angular/src/app/components/preview-panels/area-restriction-preview/area-restriction-preview.component.ts b/client/wfnews-war/src/main/angular/src/app/components/preview-panels/area-restriction-preview/area-restriction-preview.component.ts index 4a91b603c8..6041881c48 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/preview-panels/area-restriction-preview/area-restriction-preview.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/preview-panels/area-restriction-preview/area-restriction-preview.component.ts @@ -38,13 +38,15 @@ export class AreaRestrictionPreviewComponent { enterFullDetail() { + const currentZoomLevel = getActiveMap().$viewer?.map?._zoom; const url = this.router.serializeUrl( this.router.createUrlTree([ResourcesRoutes.PUBLIC_EVENT], { queryParams: { eventType: 'area-restriction', eventNumber: this.data.PROT_RA_SYSID, eventName: this.data.NAME, - source: [ResourcesRoutes.ACTIVEWILDFIREMAP] + source: [ResourcesRoutes.ACTIVEWILDFIREMAP], + zoom: currentZoomLevel }, }), ); @@ -52,7 +54,6 @@ export class AreaRestrictionPreviewComponent { } zoomIn(level?: number, polygon?: boolean) { - const viewer = getActiveMap().$viewer; this.agolService .getAreaRestrictions( `NAME='${this.data.NAME}'`, diff --git a/client/wfnews-war/src/main/angular/src/app/components/preview-panels/evacuations-preview/evacuations-preview.component.ts b/client/wfnews-war/src/main/angular/src/app/components/preview-panels/evacuations-preview/evacuations-preview.component.ts index 742dc46667..7f4a9fb11a 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/preview-panels/evacuations-preview/evacuations-preview.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/preview-panels/evacuations-preview/evacuations-preview.component.ts @@ -3,7 +3,7 @@ import { Router } from '@angular/router'; import { AGOLService } from '@app/services/AGOL-service'; import { CapacitorService } from '@app/services/capacitor-service'; import { CommonUtilityService } from '@app/services/common-utility.service'; -import { ResourcesRoutes, convertToDateYear, hidePanel, showPanel } from '@app/utils'; +import { ResourcesRoutes, convertToDateYear, hidePanel, showPanel, getActiveMap } from '@app/utils'; import { MapUtilityService } from '../map-share-service'; @Component({ @@ -49,6 +49,7 @@ export class EvacuationsPreviewComponent { } enterFullDetail() { + const currentZoomLevel = getActiveMap().$viewer?.map?._zoom; if (this.data) { const url = this.router.serializeUrl( this.router.createUrlTree([ResourcesRoutes.PUBLIC_EVENT], { @@ -56,7 +57,8 @@ export class EvacuationsPreviewComponent { eventType: this.data.ORDER_ALERT_STATUS, id: this.data.EMRG_OAA_SYSID, eventNumber: this.data.EVENT_NUMBER, - source: [ResourcesRoutes.ACTIVEWILDFIREMAP] + source: [ResourcesRoutes.ACTIVEWILDFIREMAP], + zoom: currentZoomLevel }, }), ); diff --git a/client/wfnews-war/src/main/angular/src/app/components/preview-panels/fire-ban-preview/fire-ban-preview.component.ts b/client/wfnews-war/src/main/angular/src/app/components/preview-panels/fire-ban-preview/fire-ban-preview.component.ts index 4e04195184..392d08258d 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/preview-panels/fire-ban-preview/fire-ban-preview.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/preview-panels/fire-ban-preview/fire-ban-preview.component.ts @@ -38,13 +38,15 @@ export class FireBanPreviewComponent { } enterFullDetail() { + const currentZoomLevel = getActiveMap().$viewer?.map?._zoom; const url = this.router.serializeUrl( this.router.createUrlTree([ResourcesRoutes.PUBLIC_EVENT], { queryParams: { eventType: 'ban', eventNumber: this.data.PROT_BAP_SYSID, eventName: this.data.ACCESS_PROHIBITION_DESCRIPTION, - source: [ResourcesRoutes.ACTIVEWILDFIREMAP] + source: [ResourcesRoutes.ACTIVEWILDFIREMAP], + zoom: currentZoomLevel }, }), ); @@ -52,7 +54,6 @@ export class FireBanPreviewComponent { } zoomIn(level?: number, polygon?: boolean) { - const viewer = getActiveMap().$viewer; this.agolService .getBansAndProhibitionsById( this.data.PROT_BAP_SYSID, diff --git a/client/wfnews-war/src/main/angular/src/app/components/public-incident-page/incident-info-header/incident-header-panel.component.ts b/client/wfnews-war/src/main/angular/src/app/components/public-incident-page/incident-info-header/incident-header-panel.component.ts index 04f4720dfe..4a71ae5ab7 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/public-incident-page/incident-info-header/incident-header-panel.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/public-incident-page/incident-info-header/incident-header-panel.component.ts @@ -84,7 +84,7 @@ export class IncidentHeaderPanelComponent implements AfterViewInit, OnInit { weight: 2, fillOpacity: 0 }) - }) + }); private evacOrdersLayer = esri.featureLayer({ url: this.appConfigService.getConfig()['externalAppConfig']['AGOLevacOrders'].toString(), @@ -107,7 +107,7 @@ export class IncidentHeaderPanelComponent implements AfterViewInit, OnInit { }; } } - }) + }); constructor( @@ -418,7 +418,7 @@ export class IncidentHeaderPanelComponent implements AfterViewInit, OnInit { style: '7734' }) .addTo(this.map); - }) + }); } const icon = L.icon({ iconUrl: '/assets/images/local_fire_department.png', @@ -549,13 +549,16 @@ export class IncidentHeaderPanelComponent implements AfterViewInit, OnInit { backToMap() { + const zoom = this.params?.['zoom']; + const navigateToMap = (longitude: number, latitude: number, queryParamKey: string) => { setTimeout(() => { this.router.navigate([ResourcesRoutes.ACTIVEWILDFIREMAP], { queryParams: { longitude, latitude, - [queryParamKey]: true + [queryParamKey]: true, + zoom }, }); }, 100); From 8ff3d99169f06ed0ad3c2a3f9581306958ef0d98 Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Thu, 19 Dec 2024 09:41:21 -0800 Subject: [PATCH 6/8] Make backToMap logic more readable --- .../full-details/full-details.component.ts | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts index 2146296a21..fabe165c0c 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts @@ -52,10 +52,11 @@ export class FullDetailsComponent implements OnInit, OnDestroy { // If the user accessed the full details page from the map, and if the full details page contains one of area restrictions, // fire bans, evac orders or evac alerts, use the backToMap function to route back to the map using the same layer and zoom level, // along with the appropriate coordinates for that type. - if ((this.params['source'] === 'map' || this.params['source']?.[0] === 'map') - && (this.params?.['type'] === 'area-restriction' || this.params?.['type'] === 'bans-prohibitions' - || this.params?.['type'].includes('evac')) - ) { + const isMapSource = this.params?.['source'] === 'map' || this.params?.['source']?.[0] === 'map'; + const validTypes = ['area-restriction', 'bans-prohibitions']; + const isValidType = validTypes.includes(this.params?.['type']) || this.params?.['type']?.includes('evac'); + + if (isMapSource && isValidType) { this.backToMap(); } else if ( this.params['source'] === 'saved-location' && @@ -98,10 +99,11 @@ export class FullDetailsComponent implements OnInit, OnDestroy { // If the user accessed the full details page from the map, and if the full details page contains one of area restrictions, // fire bans, evac orders or evac alerts, use the backToMap function to route back to the map using the same layer and zoom level, // along with the appropriate coordinates for that type. - if ((this.params?.['source'] === 'map' || this.params?.['source']?.[0] === 'map') - && (this.params?.['type'] === 'area-restriction' || this.params?.['type'] === 'bans-prohibitions' - || this.params?.['type'].includes('evac')) - ) { + const isMapSource = this.params?.['source'] === 'map' || this.params?.['source']?.[0] === 'map'; + const validTypes = ['area-restriction', 'bans-prohibitions']; + const isValidType = validTypes.includes(this.params?.['type']) || this.params?.['type']?.includes('evac'); + + if (isMapSource && isValidType) { this.backToMap(); } else { this.router.navigate([ResourcesRoutes.DASHBOARD]); @@ -123,7 +125,7 @@ export class FullDetailsComponent implements OnInit, OnDestroy { }, 100); }; - if(this.params['type'] && this.params['sourceLongitude'] && this.params['sourceLatitude'] && this.params['sourceZoom']) { + if (this.params['type'] && this.params['sourceLongitude'] && this.params['sourceLatitude'] && this.params['sourceZoom']) { switch (this.params['type']) { case 'area-restriction': navigateToMap(this.params['sourceLongitude'], this.params['sourceLatitude'], this.params['sourceZoom'], 'areaRestriction'); From 92f5ae92d1d92bf3f30c69545af6c5d4b8e4fa89 Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Thu, 19 Dec 2024 12:04:10 -0800 Subject: [PATCH 7/8] Add same functionality for fire danger and handle navigation detection more gracefully --- .../active-wildfire-map.component.ts | 2 ++ .../draggable-panel.component.ts | 5 ++- .../full-details/full-details.component.ts | 34 +++++++++++++------ .../danger-rating-preview.component.ts | 6 ++-- 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/client/wfnews-war/src/main/angular/src/app/components/active-wildfire-map/active-wildfire-map.component.ts b/client/wfnews-war/src/main/angular/src/app/components/active-wildfire-map/active-wildfire-map.component.ts index 5995546fd6..f8c039bfdc 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/active-wildfire-map/active-wildfire-map.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/active-wildfire-map/active-wildfire-map.component.ts @@ -493,6 +493,8 @@ export class ActiveWildfireMapComponent implements OnInit, AfterViewInit { this.panToLocation(long, lat, params['zoom'] ? params['zoom'] : 12); } else if (params['bansProhibitions'] && params['bansProhibitions'] === 'true'){ this.panToLocation(long, lat, params['zoom'] ? params['zoom'] : 6); + } else if (params['dangerRating'] && params['dangerRating'] === 'true'){ + this.panToLocation(long, lat, params['zoom'] ? params['zoom'] : 5); } else if (params['savedLocation'] && params['savedLocation'] === 'true') { this.panToLocation(long, lat, 8); } else { diff --git a/client/wfnews-war/src/main/angular/src/app/components/draggable-panel/draggable-panel.component.ts b/client/wfnews-war/src/main/angular/src/app/components/draggable-panel/draggable-panel.component.ts index fe6bdf149a..026de95d7e 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/draggable-panel/draggable-panel.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/draggable-panel/draggable-panel.component.ts @@ -627,7 +627,10 @@ return 'Unknown'; id: item.properties.DANGER_RATING_DESC, location: JSON.stringify(location), source: [ResourcesRoutes.ACTIVEWILDFIREMAP], - sysid: item.properties.PROT_DR_SYSID + sysid: item.properties.PROT_DR_SYSID, + sourceLatitude: location.latitude, + sourceLongitude: location.longitude, + sourceZoom: currentZoomLevel }, }); break; diff --git a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts index fabe165c0c..9a68786741 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts @@ -52,11 +52,7 @@ export class FullDetailsComponent implements OnInit, OnDestroy { // If the user accessed the full details page from the map, and if the full details page contains one of area restrictions, // fire bans, evac orders or evac alerts, use the backToMap function to route back to the map using the same layer and zoom level, // along with the appropriate coordinates for that type. - const isMapSource = this.params?.['source'] === 'map' || this.params?.['source']?.[0] === 'map'; - const validTypes = ['area-restriction', 'bans-prohibitions']; - const isValidType = validTypes.includes(this.params?.['type']) || this.params?.['type']?.includes('evac'); - - if (isMapSource && isValidType) { + if (this.navigatedfromMapPage() && this.isCurrentlyNavigatedOn()) { this.backToMap(); } else if ( this.params['source'] === 'saved-location' && @@ -98,18 +94,31 @@ export class FullDetailsComponent implements OnInit, OnDestroy { exit() { // If the user accessed the full details page from the map, and if the full details page contains one of area restrictions, // fire bans, evac orders or evac alerts, use the backToMap function to route back to the map using the same layer and zoom level, - // along with the appropriate coordinates for that type. - const isMapSource = this.params?.['source'] === 'map' || this.params?.['source']?.[0] === 'map'; - const validTypes = ['area-restriction', 'bans-prohibitions']; - const isValidType = validTypes.includes(this.params?.['type']) || this.params?.['type']?.includes('evac'); - - if (isMapSource && isValidType) { + // along with the appropriate coordinates for that type + if (this.navigatedfromMapPage() && this.isCurrentlyNavigatedOn()) { this.backToMap(); } else { this.router.navigate([ResourcesRoutes.DASHBOARD]); } } + navigatedfromMapPage() { + if (this.params?.['source'] === 'map' || this.params?.['source']?.[0] === 'map') { + return true; + } else { + return false; + } + } + + isCurrentlyNavigatedOn() { + const fullDetailPageTypes = ['area-restriction', 'bans-prohibitions', 'evac-orders', 'evac-alerts', 'danger-rating']; + if(fullDetailPageTypes.includes(this.params?.['type'])){ + return true; + } else { + return false; + } + } + // use query params to determine the layer, coordinates and zoom level for routing back to the map backToMap() { const navigateToMap = (longitude: number, latitude: number, zoom: string, queryParamKey: string) => { @@ -133,6 +142,9 @@ export class FullDetailsComponent implements OnInit, OnDestroy { case 'bans-prohibitions': navigateToMap(this.params['sourceLongitude'], this.params['sourceLatitude'], this.params['sourceZoom'], 'bansProhibitions'); break; + case 'danger-rating': + navigateToMap(this.params['sourceLongitude'], this.params['sourceLatitude'], this.params['sourceZoom'], 'dangerRating'); + break; case 'evac-alert': case 'evac-order': navigateToMap(this.params['sourceLongitude'], this.params['sourceLatitude'], this.params['sourceZoom'], 'evacuationAlert'); diff --git a/client/wfnews-war/src/main/angular/src/app/components/preview-panels/danger-rating-preview/danger-rating-preview.component.ts b/client/wfnews-war/src/main/angular/src/app/components/preview-panels/danger-rating-preview/danger-rating-preview.component.ts index 2bfec12717..9794864108 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/preview-panels/danger-rating-preview/danger-rating-preview.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/preview-panels/danger-rating-preview/danger-rating-preview.component.ts @@ -5,7 +5,7 @@ import { LocationData } from '@app/components/wildfires-list-header/filter-by-lo import { AGOLService } from '@app/services/AGOL-service'; import { CapacitorService } from '@app/services/capacitor-service'; import { CommonUtilityService } from '@app/services/common-utility.service'; -import { ResourcesRoutes, formatDate, hidePanel, showPanel, displayDangerRatingDescription } from '@app/utils'; +import { ResourcesRoutes, formatDate, hidePanel, showPanel, displayDangerRatingDescription, getActiveMap } from '@app/utils'; @Component({ selector: 'wfnews-danger-rating-preview', @@ -40,6 +40,7 @@ export class DangerRatingPreviewComponent { } enterFullDetail() { + const currentZoomLevel = getActiveMap().$viewer?.map?._zoom; const location = new LocationData(); const url = this.router.serializeUrl( this.router.createUrlTree([ResourcesRoutes.PUBLIC_EVENT], { @@ -48,7 +49,8 @@ export class DangerRatingPreviewComponent { eventNumber: this.data.PROT_DR_SYSID, eventName: this.data.DANGER_RATING_DESC, location: JSON.stringify(location), - source: [ResourcesRoutes.ACTIVEWILDFIREMAP] + source: [ResourcesRoutes.ACTIVEWILDFIREMAP], + zoom: currentZoomLevel }, }), ); From d1a53231ee632ce7065611fc6b8d7acb1057b951 Mon Sep 17 00:00:00 2001 From: Sean Sylver Date: Thu, 19 Dec 2024 12:28:43 -0800 Subject: [PATCH 8/8] Update isCurrentlyNavigatedOn function to be more clear --- .../full-details/full-details.component.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts index 9a68786741..0e93554976 100644 --- a/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts +++ b/client/wfnews-war/src/main/angular/src/app/components/full-details/full-details.component.ts @@ -52,7 +52,8 @@ export class FullDetailsComponent implements OnInit, OnDestroy { // If the user accessed the full details page from the map, and if the full details page contains one of area restrictions, // fire bans, evac orders or evac alerts, use the backToMap function to route back to the map using the same layer and zoom level, // along with the appropriate coordinates for that type. - if (this.navigatedfromMapPage() && this.isCurrentlyNavigatedOn()) { + if (this.navigatedfromMapPage() + && this.isCurrentlyNavigatedOn(['area-restriction', 'bans-prohibitions', 'evac-order', 'evac-alert', 'danger-rating'])) { this.backToMap(); } else if ( this.params['source'] === 'saved-location' && @@ -95,7 +96,8 @@ export class FullDetailsComponent implements OnInit, OnDestroy { // If the user accessed the full details page from the map, and if the full details page contains one of area restrictions, // fire bans, evac orders or evac alerts, use the backToMap function to route back to the map using the same layer and zoom level, // along with the appropriate coordinates for that type - if (this.navigatedfromMapPage() && this.isCurrentlyNavigatedOn()) { + if (this.navigatedfromMapPage() + && this.isCurrentlyNavigatedOn(['area-restriction', 'bans-prohibitions', 'evac-order', 'evac-alert', 'danger-rating'])) { this.backToMap(); } else { this.router.navigate([ResourcesRoutes.DASHBOARD]); @@ -110,13 +112,12 @@ export class FullDetailsComponent implements OnInit, OnDestroy { } } - isCurrentlyNavigatedOn() { - const fullDetailPageTypes = ['area-restriction', 'bans-prohibitions', 'evac-orders', 'evac-alerts', 'danger-rating']; - if(fullDetailPageTypes.includes(this.params?.['type'])){ + isCurrentlyNavigatedOn(pageList) { + if (pageList.includes(this.params?.['type'])) { return true; } else { return false; - } + } } // use query params to determine the layer, coordinates and zoom level for routing back to the map