Skip to content

Commit

Permalink
Fixed loading of url with parameters at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapok committed Mar 11, 2024
1 parent 361e52f commit 2c311fc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 0 additions & 1 deletion doc/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Following list of features and improvements ordered by priority is under develop
* Fix the duplicate load needed when accessing the page as pwa - Clear browser cache
* Fix wrong time format message in console created by plotly - requires more customization and additional reference to d3, wan't fix
* Main menu overlaps the tabs, when text is wrapped on two rows (and some other responsiveness glitches)
* Shared link to dashboard does not load the profile

## Improvements / Features

Expand Down
15 changes: 12 additions & 3 deletions projects/planner/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { CanActivateFn, Router, RouterModule, Routes, UrlTree } from '@angular/router';
import {
ActivatedRouteSnapshot,
CanActivateFn,
Router,
RouterModule,
Routes,
UrlTree
} from '@angular/router';
import { Location } from '@angular/common';
import { AppSettingsComponent } from './app-settings/app-settings.component';
import { DashboardComponent } from './dashboard/dashboard.component';
Expand All @@ -15,10 +22,12 @@ import { DiffComponent } from './diff/diff.component';
import { RedundanciesComponent } from './redundancies/redundancies.component';
import { GasBlenderComponent } from './gas-blender/gas-blender.component';

const canActivateDashboard: CanActivateFn = (): boolean | UrlTree => {
const canActivateDashboard: CanActivateFn = (route: ActivatedRouteSnapshot): boolean | UrlTree => {
const router = inject(Router);
const viewStates = inject(ViewStates);
if (viewStates.redirectToView) {

// the only view with params is dashboard with only one dive
if (route.queryParamMap.keys.length === 0 && viewStates.redirectToView) {
const target = `/${viewStates.lastView}`;
const location = inject(Location);
location.go(target);
Expand Down
6 changes: 4 additions & 2 deletions projects/planner/src/app/shared/startUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ export class DashboardStartUp {
this.urlSerialization.fromUrl(query);
// cant do in constructor, since the state may be changed
this.viewStore.saveMainView();
// in case it fails we need to reset the parameters
this.updateQueryParams();
}

// in case it fails we need to reset the parameters
// or in case of navigation to dashboard with only one dive
this.updateQueryParams();
}

public stopDisclaimer(): void {
Expand Down

0 comments on commit 2c311fc

Please sign in to comment.