LP#626157 Ang2 experiments
authorBill Erickson <berickxx@gmail.com>
Wed, 22 Nov 2017 16:06:46 +0000 (11:06 -0500)
committerBill Erickson <berickxx@gmail.com>
Mon, 11 Dec 2017 17:39:51 +0000 (12:39 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/webby-src/src/app/base-resolver.service.ts [deleted file]
Open-ILS/webby-src/src/app/base-routing.module.ts [deleted file]
Open-ILS/webby-src/src/app/base.module.ts
Open-ILS/webby-src/src/app/resolver.service.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/routing.module.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/auth-guard.service.ts
Open-ILS/webby-src/src/app/staff/routing.module.ts

diff --git a/Open-ILS/webby-src/src/app/base-resolver.service.ts b/Open-ILS/webby-src/src/app/base-resolver.service.ts
deleted file mode 100644 (file)
index e1e8b73..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-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.
-    }
-}
diff --git a/Open-ILS/webby-src/src/app/base-routing.module.ts b/Open-ILS/webby-src/src/app/base-routing.module.ts
deleted file mode 100644 (file)
index 7280e37..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-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 {}
index 27dca35..553e8aa 100644 (file)
@@ -10,7 +10,7 @@ import { NgbModule }     from '@ng-bootstrap/ng-bootstrap';
 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.
diff --git a/Open-ILS/webby-src/src/app/resolver.service.ts b/Open-ILS/webby-src/src/app/resolver.service.ts
new file mode 100644 (file)
index 0000000..e1e8b73
--- /dev/null
@@ -0,0 +1,23 @@
+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.
+    }
+}
diff --git a/Open-ILS/webby-src/src/app/routing.module.ts b/Open-ILS/webby-src/src/app/routing.module.ts
new file mode 100644 (file)
index 0000000..8085267
--- /dev/null
@@ -0,0 +1,27 @@
+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 {}
index f2c276a..d54ec41 100644 (file)
@@ -27,7 +27,7 @@ export class EgStaffAuthGuard implements CanActivate, CanActivateChild {
                 err => {
                     this.egAuth.redirectUrl = state.url;
                     this.router.navigate(['/staff/login']);
-                    resolve(false);
+                    resolve(false); // cannot activate
                 }
             );
         });
index df2d784..615c3e3 100644 (file)
@@ -18,21 +18,25 @@ const routes: Routes = [{
     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'
     }]
   }]
 }];