+++ /dev/null
-import { Injectable } from '@angular/core';
-import { Observable } from 'rxjs/Observable';
-import { Router, Resolve, RouterStateSnapshot,
- ActivatedRouteSnapshot } from '@angular/router';
-
-import { EgIdlService } from '@eg/core/idl.service';
-
-@Injectable()
-export class EgBaseResolver implements Resolve<any> {
-
- constructor(private router: Router, private egIdl: EgIdlService) {}
-
- resolve(
- route: ActivatedRouteSnapshot,
- state: RouterStateSnapshot): Observable<any> {
-
- console.debug('EgBaseResolver:resolve()');
-
- this.egIdl.parseIdl();
-
- return Observable.empty(); // Nothing to report.
- }
-}
+++ /dev/null
-import { NgModule } from '@angular/core';
-import { RouterModule, Routes } from '@angular/router';
-import { EgBaseResolver } from './base-resolver.service';
-import { WelcomeComponent } from './welcome.component';
-
-/**
- * Avoid adding bulk to the base module by lazy-loading sub-modules.
- * When lazy loading, no module references should be directly imported.
- * The refs are encoded in the loadChildren attribute of each route.
- */
-const routes: Routes = [
- { path: '',
- component: WelcomeComponent
- }, {
- path: 'staff',
- resolve : {startup : EgBaseResolver},
- loadChildren: './staff/staff.module#EgStaffModule'
- }
-];
-
-@NgModule({
- imports: [ RouterModule.forRoot(routes) ],
- exports: [ RouterModule ],
- providers: [ EgBaseResolver ]
-})
-
-export class EgBaseRoutingModule {}
import { CookieModule } from 'ngx-cookie'; // import CookieMonster
import { EgBaseComponent } from './base.component';
-import { EgBaseRoutingModule } from './base-routing.module';
+import { EgBaseRoutingModule } from './routing.module';
import { WelcomeComponent } from './welcome.component';
// Import and 'provide' globally required services.
--- /dev/null
+import { Injectable } from '@angular/core';
+import { Observable } from 'rxjs/Observable';
+import { Router, Resolve, RouterStateSnapshot,
+ ActivatedRouteSnapshot } from '@angular/router';
+
+import { EgIdlService } from '@eg/core/idl.service';
+
+@Injectable()
+export class EgBaseResolver implements Resolve<any> {
+
+ constructor(private router: Router, private egIdl: EgIdlService) {}
+
+ resolve(
+ route: ActivatedRouteSnapshot,
+ state: RouterStateSnapshot): Observable<any> {
+
+ console.debug('EgBaseResolver:resolve()');
+
+ this.egIdl.parseIdl();
+
+ return Observable.empty(); // Nothing to report.
+ }
+}
--- /dev/null
+import { NgModule } from '@angular/core';
+import { RouterModule, Routes } from '@angular/router';
+import { EgBaseResolver } from './resolver.service';
+import { WelcomeComponent } from './welcome.component';
+
+/**
+ * Avoid requiring all apps to load all JS by lazy-loading sub-modules.
+ * When lazy loading, no module references should be directly imported.
+ * The refs are encoded in the loadChildren attribute of each route.
+ */
+const routes: Routes = [
+ { path: '',
+ component: WelcomeComponent
+ }, {
+ path: 'staff',
+ resolve : {startup : EgBaseResolver},
+ loadChildren: './staff/staff.module#EgStaffModule'
+ }
+];
+
+@NgModule({
+ imports: [ RouterModule.forRoot(routes) ],
+ exports: [ RouterModule ],
+ providers: [ EgBaseResolver ]
+})
+
+export class EgBaseRoutingModule {}
err => {
this.egAuth.redirectUrl = state.url;
this.router.navigate(['/staff/login']);
- resolve(false);
+ resolve(false); // cannot activate
}
);
});
path: 'logout',
component: EgStaffLogoutComponent
}, {
- // Every path below here requires a valid authtoken.
path: '',
+ // Require a valid authtoken to access child paths
canActivate : [EgStaffAuthGuard],
+ // Load data common to all staff UI's before loading child paths.
resolve: {dataResolver: EgStaffDataResolver},
+ // EgStaffComponent houses the navbar and the page content shell.
component: EgStaffComponent,
children: [{
- path: '',
- redirectTo: 'splash'
- pathMatch: 'full',
- }, {
- path: 'splash',
- component: EgStaffSplashComponent
- }, {
- path: 'circ',
- loadChildren : '@eg/staff/circ/circ.module#EgCircModule'
+ path: '',
+ redirectTo: 'splash', // must be to sibling path
+ pathMatch: 'full',
+ }, {
+ path: 'splash',
+ component: EgStaffSplashComponent
+ }, {
+ // Lazy-load collections of sub-modules (circ, cat, etc.)
+ // with loadChildren
+ path: 'circ',
+ loadChildren : '@eg/staff/circ/circ.module#EgCircModule'
}]
}]
}];