diff --git a/setup-wizard/src/app/app-routing.module.ts b/setup-wizard/src/app/app-routing.module.ts index c27caee53..1abc13060 100644 --- a/setup-wizard/src/app/app-routing.module.ts +++ b/setup-wizard/src/app/app-routing.module.ts @@ -1,14 +1,17 @@ import { NgModule } from '@angular/core'; import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; - +import { CanActivateHome, CanActivateRecover } from './guards/guards' const routes: Routes = [ { path: 'wizard', - loadChildren: () => import('./pages/home/home.module').then( m => m.HomePageModule) + loadChildren: () => import('./pages/home/home.module').then( m => m.HomePageModule), + canActivate: [CanActivateHome], + }, { path: 'recover', - loadChildren: () => import('./pages/recover/recover.module').then( m => m.RecoverPageModule) + loadChildren: () => import('./pages/recover/recover.module').then( m => m.RecoverPageModule), + canActivate: [CanActivateRecover] }, ]; diff --git a/setup-wizard/src/app/guards/guards.ts b/setup-wizard/src/app/guards/guards.ts new file mode 100644 index 000000000..f7f076d99 --- /dev/null +++ b/setup-wizard/src/app/guards/guards.ts @@ -0,0 +1,32 @@ +import { Injectable } from '@angular/core' +import { CanActivate } from '@angular/router' +import { StateService } from '../services/state.service' + +@Injectable({ + providedIn: 'root', +}) +export class CanActivateHome implements CanActivate { + + constructor ( + private readonly stateService: StateService + ) {} + + canActivate (): boolean { + console.log(!!this.stateService.recoveryDrive) + return !!this.stateService.recoveryDrive ? false : true + } +} + +@Injectable({ + providedIn: 'root', +}) +export class CanActivateRecover implements CanActivate { + + constructor ( + private readonly stateService: StateService + ) {} + + canActivate (): boolean { + return this.stateService.dataDrive ? true : false + } +} diff --git a/setup-wizard/src/app/pages/home/home.page.html b/setup-wizard/src/app/pages/home/home.page.html index 38db8b19d..b4ec3e492 100644 --- a/setup-wizard/src/app/pages/home/home.page.html +++ b/setup-wizard/src/app/pages/home/home.page.html @@ -28,7 +28,7 @@
-
+

No recovery drives found

Please connect a recovery drive to your embassy and refresh the page.

@@ -26,7 +26,7 @@
-
-

Recovering Your Embassy

- -

Progress: {{ 100 * stateService.dataProgress }}%

+
+

Recovery Progress: {{ 100 * stateService.dataProgress }}%

+