From 54c3b1c7ed46c11a9d9e2e03d5430889784bc9cf Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 22 Nov 2017 10:46:37 -0500 Subject: [PATCH] LP#626157 Ang2 experiments Signed-off-by: Bill Erickson --- ...esolver.service.ts => data-resolver.service.ts} | 15 ++++-- Open-ILS/webby-src/src/app/staff/routing.module.ts | 54 ++++++++++++---------- .../webby-src/src/app/staff/splash.component.html | 5 +- .../webby-src/src/app/staff/splash.component.ts | 1 + 4 files changed, 46 insertions(+), 29 deletions(-) rename Open-ILS/webby-src/src/app/staff/{common-data-resolver.service.ts => data-resolver.service.ts} (53%) diff --git a/Open-ILS/webby-src/src/app/staff/common-data-resolver.service.ts b/Open-ILS/webby-src/src/app/staff/data-resolver.service.ts similarity index 53% rename from Open-ILS/webby-src/src/app/staff/common-data-resolver.service.ts rename to Open-ILS/webby-src/src/app/staff/data-resolver.service.ts index 6908cf08db..1819802f9b 100644 --- a/Open-ILS/webby-src/src/app/staff/common-data-resolver.service.ts +++ b/Open-ILS/webby-src/src/app/staff/data-resolver.service.ts @@ -4,10 +4,10 @@ import { Router, Resolve, RouterStateSnapshot, import { EgAuthService } from '@eg/core/auth.service'; /** - * Check auth token and load data required by all staff components. + * Load post-authentication data required by all staff UI's */ @Injectable() -export class EgStaffCommonDataResolver implements Resolve> { +export class EgStaffDataResolver implements Resolve> { constructor( private router: Router, @@ -18,10 +18,19 @@ export class EgStaffCommonDataResolver implements Resolve> { route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise { - console.debug('EgStaffCommonDataResolver:resolve()'); + console.debug('EgStaffDataResolver:resolve()'); // TODO verify workstation + let wsPath = '/staff/admin/workstation'; + + if (false) { // WS is invalid + if (this.router.url != wsPath) { + console.debug('re-routing to workstation admin page'); + this.router.navigate([wsPath]); + } + } + return Promise.resolve(true); } } diff --git a/Open-ILS/webby-src/src/app/staff/routing.module.ts b/Open-ILS/webby-src/src/app/staff/routing.module.ts index 92a2897f33..df2d784d51 100644 --- a/Open-ILS/webby-src/src/app/staff/routing.module.ts +++ b/Open-ILS/webby-src/src/app/staff/routing.module.ts @@ -1,44 +1,48 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { EgStaffResolver } from './resolver.service'; -import { EgStaffCommonDataResolver } from './common-data-resolver.service'; +import { EgStaffDataResolver } from './data-resolver.service'; import { EgStaffAuthGuard } from './auth-guard.service'; import { EgStaffComponent } from './staff.component'; import { EgStaffLoginComponent } from './login.component'; import { EgStaffLogoutComponent } from './logout.component'; import { EgStaffSplashComponent } from './splash.component'; -const routes: Routes = [ - { path: '', +const routes: Routes = [{ + path: '', + resolve: {staffResolver : EgStaffResolver}, + children: [{ + path: 'login', + component: EgStaffLoginComponent + }, { + path: 'logout', + component: EgStaffLogoutComponent + }, { + // Every path below here requires a valid authtoken. + path: '', + canActivate : [EgStaffAuthGuard], + resolve: {dataResolver: EgStaffDataResolver}, component: EgStaffComponent, - resolve : {staffResolver : EgStaffResolver}, - children : [ - { path: 'login', - component: EgStaffLoginComponent - }, { - path: 'logout', - component: EgStaffLogoutComponent - }, { - path : 'splash', - canActivate : [EgStaffAuthGuard], - resolve : {commonDataResolver : EgStaffCommonDataResolver}, - component: EgStaffSplashComponent - }, { - path : 'circ', - canActivate : [EgStaffAuthGuard], - resolve : {commonDataResolver : EgStaffCommonDataResolver}, - loadChildren : '@eg/staff/circ/circ.module#EgCircModule' - } - ], - } -]; + children: [{ + path: '', + redirectTo: 'splash' + pathMatch: 'full', + }, { + path: 'splash', + component: EgStaffSplashComponent + }, { + path: 'circ', + loadChildren : '@eg/staff/circ/circ.module#EgCircModule' + }] + }] +}]; @NgModule({ imports: [ RouterModule.forChild(routes) ], exports: [ RouterModule ], providers: [ EgStaffResolver, - EgStaffCommonDataResolver, + EgStaffDataResolver, EgStaffAuthGuard ] }) diff --git a/Open-ILS/webby-src/src/app/staff/splash.component.html b/Open-ILS/webby-src/src/app/staff/splash.component.html index 14cf389d87..2e6b23ad8b 100644 --- a/Open-ILS/webby-src/src/app/staff/splash.component.html +++ b/Open-ILS/webby-src/src/app/staff/splash.component.html @@ -1,3 +1,6 @@ - +
+
+
+
Staff Splash Page diff --git a/Open-ILS/webby-src/src/app/staff/splash.component.ts b/Open-ILS/webby-src/src/app/staff/splash.component.ts index 64a54a3a0a..101f464a48 100644 --- a/Open-ILS/webby-src/src/app/staff/splash.component.ts +++ b/Open-ILS/webby-src/src/app/staff/splash.component.ts @@ -10,6 +10,7 @@ export class EgStaffSplashComponent implements OnInit { constructor(private route: ActivatedRoute) {} ngOnInit() { + console.log('EgStaffSplashComponent:ngOnInit()'); } } -- 2.11.0