From 67a256b489820936f6b7c29d094d9fbb9a5569a4 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 21 Nov 2017 22:32:37 -0500 Subject: [PATCH] LP#626157 Ang2 experiments Signed-off-by: Bill Erickson --- Open-ILS/webby-src/src/app/core/auth.service.ts | 4 ++-- Open-ILS/webby-src/src/app/core/store.service.ts | 13 +++++++++++-- .../webby-src/src/app/staff/logout.component.ts | 20 ++++++++++++++++++++ Open-ILS/webby-src/src/app/staff/nav.component.css | 8 ++++++++ .../webby-src/src/app/staff/nav.component.html | 22 +++++++++++++--------- Open-ILS/webby-src/src/app/staff/routing.module.ts | 4 ++++ Open-ILS/webby-src/src/app/staff/staff.module.ts | 4 +++- 7 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 Open-ILS/webby-src/src/app/staff/logout.component.ts diff --git a/Open-ILS/webby-src/src/app/core/auth.service.ts b/Open-ILS/webby-src/src/app/core/auth.service.ts index 628831f75c..d04e76542f 100644 --- a/Open-ILS/webby-src/src/app/core/auth.service.ts +++ b/Open-ILS/webby-src/src/app/core/auth.service.ts @@ -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')) } } diff --git a/Open-ILS/webby-src/src/app/core/store.service.ts b/Open-ILS/webby-src/src/app/core/store.service.ts index 653d7e8d75..083def0c59 100644 --- a/Open-ILS/webby-src/src/app/core/store.service.ts +++ b/Open-ILS/webby-src/src/app/core/store.service.ts @@ -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 index 0000000000..51587c68c2 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/logout.component.ts @@ -0,0 +1,20 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import { EgAuthService } from '@eg/core/auth.service'; + +@Component({ + template : '
' +}) + +export class EgStaffLogoutComponent implements OnInit { + + constructor( + private router: Router, + private egAuth: EgAuthService, + ) {} + + ngOnInit() { + this.egAuth.logout(); + this.router.navigate(['/staff/login']); + } +} diff --git a/Open-ILS/webby-src/src/app/staff/nav.component.css b/Open-ILS/webby-src/src/app/staff/nav.component.css index 11ae8525c9..288f14bbd7 100644 --- a/Open-ILS/webby-src/src/app/staff/nav.component.css +++ b/Open-ILS/webby-src/src/app/staff/nav.component.css @@ -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; +} diff --git a/Open-ILS/webby-src/src/app/staff/nav.component.html b/Open-ILS/webby-src/src/app/staff/nav.component.html index cdb95bf5e1..0907376a27 100644 --- a/Open-ILS/webby-src/src/app/staff/nav.component.html +++ b/Open-ILS/webby-src/src/app/staff/nav.component.html @@ -4,24 +4,28 @@ href="./stuff" direct routing routerLink="/suff" --> -