All files / src/app/sys-check sys-check-routing.module.ts

40% Statements 4/10
0% Branches 0/3
0% Functions 0/2
33.33% Lines 3/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80                                      1x                                     1x                                                                               1x  
// eslint-disable-next-line max-classes-per-file
import { Injectable, NgModule } from '@angular/core';
import {
  Routes,
  RouterModule,
  Router,
  ActivatedRouteSnapshot,
  RouterStateSnapshot
} from '@angular/router';
import { Observable } from 'rxjs';
import { SysCheckComponent } from './sys-check.component';
import { WelcomeComponent } from './welcome/welcome.component';
import { NetworkCheckComponent } from './network-check/network-check.component';
import { SysCheckDataService } from './sys-check-data.service';
import { QuestionnaireComponent } from './questionnaire/questionnaire.component';
import { ReportComponent } from './report/report.component';
import { UnitCheckComponent } from './unit-check/unit-check.component';
 
@Injectable()
export class SysCheckChildCanActivateGuard  {
  constructor(
    private router: Router,
    private ds: SysCheckDataService
  ) {
  }
 
  canActivate(
    next: ActivatedRouteSnapshot,
    state: RouterStateSnapshot
  ): Observable<boolean> | Promise<boolean> | boolean {
    Iif (this.ds.checkConfig && this.ds.loadConfigComplete) {
      return true;
    }
    this.router.navigate(['/']); //TODO not ideal for not-logged in users (see commitmsg for more)
    return false;
  }
}
 
const routes: Routes = [
  {
    path: ':workspace-id/:sys-check-name',
    component: SysCheckComponent,
    children: [
      {
        path: '',
        redirectTo: 'w',
        pathMatch: 'full'
      },
      {
        path: 'w',
        component: WelcomeComponent
      },
      {
        path: 'n',
        component: NetworkCheckComponent,
        canActivate: [SysCheckChildCanActivateGuard]
      },
      {
        path: 'q',
        component: QuestionnaireComponent,
        canActivate: [SysCheckChildCanActivateGuard]
      },
      {
        path: 'r',
        component: ReportComponent,
        canActivate: [SysCheckChildCanActivateGuard]
      },
      {
        path: 'u',
        component: UnitCheckComponent,
        canActivate: [SysCheckChildCanActivateGuard]
      }]
  }];
 
@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class SysCheckRoutingModule { }