Skip to content

Commit

Permalink
Add same functionality for fire danger and handle navigation detectio…
Browse files Browse the repository at this point in the history
…n more gracefully
  • Loading branch information
ssylver93 committed Dec 19, 2024
1 parent 8ff3d99 commit 92f5ae9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' &&
Expand Down Expand Up @@ -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) => {
Expand All @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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], {
Expand All @@ -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
},
}),
);
Expand Down

0 comments on commit 92f5ae9

Please sign in to comment.