LP#626157 Ang2 experiments
authorBill Erickson <berickxx@gmail.com>
Wed, 22 Nov 2017 03:32:37 +0000 (22:32 -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/core/auth.service.ts
Open-ILS/webby-src/src/app/core/store.service.ts
Open-ILS/webby-src/src/app/staff/logout.component.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/nav.component.css
Open-ILS/webby-src/src/app/staff/nav.component.html
Open-ILS/webby-src/src/app/staff/routing.module.ts
Open-ILS/webby-src/src/app/staff/staff.module.ts

index 628831f..d04e765 100644 (file)
@@ -162,10 +162,10 @@ export class EgAuthService {
 
     deleteSession(): void {
         if (this.token()) {
-            // fire and forget
             this.egNet.request(
                 'open-ils.auth',
-                'open-ils.auth.session.delete', this.token());
+                'open-ils.auth.session.delete', this.token())
+            .subscribe(x => console.log('logged out'))
         }
     }
 
index 653d7e8..083def0 100644 (file)
@@ -11,6 +11,13 @@ export class EgStoreService {
     // Base path for cookie-based storage.
     loginSessionBasePath: string;
 
+    loginSessionKeys: string[] = [
+        'eg.auth.token',
+        'eg.auth.time',
+        'eg.auth.token.oc',
+        'eg.auth.time.oc'
+    ];
+
     constructor(private cookieService: CookieService) {}
 
     private parseJson(valJson: string): any {
@@ -89,14 +96,16 @@ export class EgStoreService {
     }
 
     removeSessionItem(key: string): void {
-        this.cookieService.remove(key, {path : this.loginSessionBasePath});
     }
 
     removeLoginSessionItem(key: string): void {
+        this.cookieService.remove(key, {path : this.loginSessionBasePath});
     }
 
     clearLoginSessionItems(): void {
+        this.loginSessionKeys.forEach(
+            key => this.removeLoginSessionItem(key)
+        );
     }
-
 }
 
diff --git a/Open-ILS/webby-src/src/app/staff/logout.component.ts b/Open-ILS/webby-src/src/app/staff/logout.component.ts
new file mode 100644 (file)
index 0000000..51587c6
--- /dev/null
@@ -0,0 +1,20 @@
+import { Component, OnInit } from '@angular/core';
+import { Router } from '@angular/router';
+import { EgAuthService } from '@eg/core/auth.service';
+
+@Component({
+  template : '<div></div>'
+})
+
+export class EgStaffLogoutComponent implements OnInit {
+
+    constructor(
+      private router: Router,
+      private egAuth: EgAuthService,
+    ) {}
+  
+    ngOnInit() {
+        this.egAuth.logout();
+        this.router.navigate(['/staff/login']);
+    }
+}
index 11ae852..288f14b 100644 (file)
@@ -5,6 +5,8 @@
 }
 #staff-navbar.navbar-default .navbar-nav>li>a {
     color: #fff;
+    padding-top: 5px;
+    padding-bottom: 5px;
 }
 #staff-navbar.navbar-default .navbar-nav>li>a:hover {
     color: #ddd;
@@ -22,3 +24,9 @@
     border-top-color: #ddd;
     border-bottom-color: #ddd;
 }
+#staff-navbar .nav-left {
+  margin-right: auto;
+}
+#staff-navbar .nav-right {
+  margin-right: 6px;
+}
index cdb95bf..0907376 100644 (file)
@@ -4,24 +4,28 @@ href="./stuff"
 direct routing
 routerLink="/suff"
 -->
-<nav id="staff-navbar" class="navbar navbar-expand-lg navbar-default">
+<nav id="staff-navbar" class="navbar fixed-top navbar-expand navbar-default">
   <div class="collapse navbar-collapse">
-    <ul class="navbar-nav">
+    <ul class="navbar-nav nav-left">
       <li class="nav-item active">
-        <a i18n class="nav-link" routerLink="/staff">Home</a>
+        <a i18n class="nav-link" routerLink="/staff/splash">Home</a>
       </li>
       <li ngbDropdown class="nav-item dropdown">
         <a ngbDropdownToggle i18n class="nav-link dropdown-toggle">
           Dropdown link
         </a>
         <div class="dropdown-menu" ngbDropdownMenu>
-          <a i18n class="dropdown-item" routerLink="/staff">Action</a>
-          <a i18n class="dropdown-item" routerLink="/staff">Another action</a>
-
+          <a i18n class="dropdown-item" routerLink="/staff">Test Action</a>
           <a i18n class="dropdown-item" 
-            routerLink="/staff/circ/patron/bcsearch/">
-            Checkout
-          </a>
+            routerLink="/staff/circ/patron/bcsearch/">Checkout</a>
+        </div>
+      </li>
+    </ul>
+    <ul class="navbar-nav nav-right">
+      <li ngbDropdown class="nav-item dropdown">
+        <a ngbDropdownToggle i18n class="nav-link dropdown-toggle">Hamburger</a>
+        <div class="dropdown-menu" ngbDropdownMenu>
+          <a i18n class="dropdown-item" routerLink="/staff/logout">Logout</a>
         </div>
       </li>
     </ul>
index 82b08f4..92a2897 100644 (file)
@@ -5,6 +5,7 @@ import { EgStaffCommonDataResolver } from './common-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 = [
@@ -15,6 +16,9 @@ const routes: Routes = [
       {   path: 'login',
           component: EgStaffLoginComponent
       }, {   
+          path: 'logout',
+          component: EgStaffLogoutComponent
+      }, {   
           path : 'splash',
           canActivate : [EgStaffAuthGuard],
           resolve : {commonDataResolver : EgStaffCommonDataResolver},
index 529528d..a468dbb 100644 (file)
@@ -7,6 +7,7 @@ import { EgStaffComponent } from './staff.component';
 import { EgStaffRoutingModule } from './routing.module';
 import { EgStaffNavComponent } from './nav.component';
 import { EgStaffLoginComponent } from './login.component';
+import { EgStaffLogoutComponent } from './logout.component';
 import { EgStaffSplashComponent } from './splash.component';
 
 @NgModule({
@@ -14,7 +15,8 @@ import { EgStaffSplashComponent } from './splash.component';
     EgStaffComponent,
     EgStaffNavComponent,
     EgStaffSplashComponent,
-    EgStaffLoginComponent
+    EgStaffLoginComponent,
+    EgStaffLogoutComponent
   ],
   imports: [
     EgStaffRoutingModule,