From 2c93d1809cc63ad239fb9a65958701f78bd5b88e Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Sun, 26 Nov 2017 09:20:17 -0500 Subject: [PATCH] LP#626157 Ang2 experiments Signed-off-by: Bill Erickson --- Open-ILS/webby-src/src/app/base.module.ts | 26 +++--- Open-ILS/webby-src/src/app/core/auth.service.ts | 4 +- .../app/staff/admin/workstation/admin-ws.module.ts | 13 +-- .../admin/workstation/workstations.component.html | 64 ++++++++++++-- .../admin/workstation/workstations.component.ts | 18 ++-- .../webby-src/src/app/staff/login.component.html | 98 +++++++++++++++++----- .../webby-src/src/app/staff/login.component.ts | 14 +++- Open-ILS/webby-src/src/app/staff/nav.component.css | 35 ++++---- .../webby-src/src/app/staff/nav.component.html | 20 +++-- .../webby-src/src/app/staff/resolver.service.ts | 2 +- .../webby-src/src/app/staff/staff.component.html | 5 +- .../webby-src/src/app/staff/staff.component.ts | 3 +- Open-ILS/webby-src/src/app/staff/staff.module.ts | 21 +++-- Open-ILS/webby-src/src/index.html | 5 +- 14 files changed, 235 insertions(+), 93 deletions(-) diff --git a/Open-ILS/webby-src/src/app/base.module.ts b/Open-ILS/webby-src/src/app/base.module.ts index 553e8aa0cc..a464f61bc0 100644 --- a/Open-ILS/webby-src/src/app/base.module.ts +++ b/Open-ILS/webby-src/src/app/base.module.ts @@ -3,22 +3,22 @@ * It provides the root router and a simple welcome page for * users that end up here accidentally. */ -import { BrowserModule } from '@angular/platform-browser'; -import { NgModule } from '@angular/core'; -import { Router } from '@angular/router'; // Debugging -import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; -import { CookieModule } from 'ngx-cookie'; // import CookieMonster +import {BrowserModule} from '@angular/platform-browser'; +import {NgModule} from '@angular/core'; +import {Router} from '@angular/router'; // Debugging +import {NgbModule} from '@ng-bootstrap/ng-bootstrap'; +import {CookieModule} from 'ngx-cookie'; // import CookieMonster -import { EgBaseComponent } from './base.component'; -import { EgBaseRoutingModule } from './routing.module'; -import { WelcomeComponent } from './welcome.component'; +import {EgBaseComponent} from './base.component'; +import {EgBaseRoutingModule} from './routing.module'; +import {WelcomeComponent} from './welcome.component'; // Import and 'provide' globally required services. -import { EgEventService } from '@eg/core/event.service'; -import { EgIdlService } from '@eg/core/idl.service'; -import { EgNetService } from '@eg/core/net.service'; -import { EgAuthService } from '@eg/core/auth.service'; -import { EgStoreService } from '@eg/core/store.service'; +import {EgEventService} from '@eg/core/event.service'; +import {EgIdlService} from '@eg/core/idl.service'; +import {EgNetService} from '@eg/core/net.service'; +import {EgAuthService} from '@eg/core/auth.service'; +import {EgStoreService} from '@eg/core/store.service'; @NgModule({ declarations: [ 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 ec97f377bd..3e78d87ab2 100644 --- a/Open-ILS/webby-src/src/app/core/auth.service.ts +++ b/Open-ILS/webby-src/src/app/core/auth.service.ts @@ -196,13 +196,11 @@ export class EgAuthService { return; } - console.debug(`Verifying workstation ${this.user().wsid()}`); - this.egStore.getItem('eg.workstation.all') .then(workstations => { if (!workstations) workstations = []; - var ws = workstations.filter( + let ws = workstations.filter( w => {return w.id == this.user().wsid()})[0]; if (ws) { diff --git a/Open-ILS/webby-src/src/app/staff/admin/workstation/admin-ws.module.ts b/Open-ILS/webby-src/src/app/staff/admin/workstation/admin-ws.module.ts index 43eb5de3b9..743ef8595f 100644 --- a/Open-ILS/webby-src/src/app/staff/admin/workstation/admin-ws.module.ts +++ b/Open-ILS/webby-src/src/app/staff/admin/workstation/admin-ws.module.ts @@ -1,8 +1,9 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import { EgAdminWsRoutingModule } from './routing.module'; -import { EgWorkstationsComponent } from './workstations.component'; +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {FormsModule} from '@angular/forms'; +import {EgAdminWsRoutingModule} from './routing.module'; +import {EgWorkstationsComponent} from './workstations.component'; + @NgModule({ declarations: [ @@ -11,7 +12,7 @@ import { EgWorkstationsComponent } from './workstations.component'; imports: [ EgAdminWsRoutingModule, CommonModule, - FormsModule + FormsModule, ] }) diff --git a/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations.component.html b/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations.component.html index becc93002f..ebb2b8f307 100644 --- a/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations.component.html +++ b/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations.component.html @@ -1,6 +1,60 @@ +
+
+ Workstation {{removingWs}} is no longer valid. Removing registration. +
+
+ Please register a workstation. +
+
+
+ Register a New Workstation For This Browser +
+
+ + + +
+
+ Workstations Registered With This Browser +
+
+
+
+ +
+
+
-
-
-
-
- WORKSTATIONS ADMIN diff --git a/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations.component.ts b/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations.component.ts index aebfa067ad..bf7717da95 100644 --- a/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations.component.ts +++ b/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations.component.ts @@ -1,7 +1,8 @@ -import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; -import { EgNetService } from '@eg/core/net.service'; -import { EgAuthService } from '@eg/core/auth.service'; +import {Component, OnInit} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; +import {EgNetService} from '@eg/core/net.service'; +import {EgStoreService} from '@eg/core/store.service'; +import {EgAuthService} from '@eg/core/auth.service'; @Component({ templateUrl: 'workstations.component.html' @@ -9,16 +10,23 @@ import { EgAuthService } from '@eg/core/auth.service'; export class EgWorkstationsComponent implements OnInit { + workstations: Object[] = []; + removingWs: boolean = false; + constructor( private route: ActivatedRoute, private egNet: EgNetService, - private egAuth: EgAuthService + private egAuth: EgAuthService, + private egStore: EgStoreService ) {} ngOnInit() { console.log('EgWorkstationsComponent:ngOnInit()'); + this.egStore.getItem('eg.workstation.all').then( + res => this.workstations = res + ); } } diff --git a/Open-ILS/webby-src/src/app/staff/login.component.html b/Open-ILS/webby-src/src/app/staff/login.component.html index 73a6b38d24..ae74776af8 100644 --- a/Open-ILS/webby-src/src/app/staff/login.component.html +++ b/Open-ILS/webby-src/src/app/staff/login.component.html @@ -1,38 +1,90 @@ -
-
-
- Sign In + + +
+
+ Sign In +
+
+ +
+ + +
+ +
+ + +
- -
-
-
+ + +
diff --git a/Open-ILS/webby-src/src/app/staff/login.component.ts b/Open-ILS/webby-src/src/app/staff/login.component.ts index 78865752d0..599562d91a 100644 --- a/Open-ILS/webby-src/src/app/staff/login.component.ts +++ b/Open-ILS/webby-src/src/app/staff/login.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit, Renderer } from '@angular/core'; import { Location } from '@angular/common'; import { Router } from '@angular/router'; import { EgAuthService, EgAuthWsState } from '@eg/core/auth.service'; +import { EgStoreService } from '@eg/core/store.service'; // TODO: testing @Component({ templateUrl : './login.component.html' @@ -23,7 +24,8 @@ export class EgStaffLoginComponent implements OnInit { private router: Router, private ngLocation: Location, private renderer: Renderer, - private egAuth: EgAuthService + private egAuth: EgAuthService, + private egStore: EgStoreService ) {} ngOnInit() { @@ -35,6 +37,12 @@ export class EgStaffLoginComponent implements OnInit { this.renderer.selectRootElement('#username').focus(); // load browser-local workstation data + + // TODO: insert for testing. + this.egStore.setItem( + 'eg.workstation.all', + [{name:'BR1-skiddoo',id:1,owning_lib:4}] + ); } handleSubmit() { @@ -45,6 +53,7 @@ export class EgStaffLoginComponent implements OnInit { this.egAuth.login(this.args).then( ok => { this.egAuth.redirectUrl = null; + if (this.egAuth.workstationState == EgAuthWsState.NOT_FOUND_SERVER) { // User is logged in without a workstation. // Redirect them to the WS admin page. @@ -54,7 +63,8 @@ export class EgStaffLoginComponent implements OnInit { // Force reload of the app after a successful login. // This allows the route resolver to re-run with a // valid auth token and workstation. - window.location.href = this.ngLocation.prepareExternalUrl(url); + window.location.href = + this.ngLocation.prepareExternalUrl(url); } }, notOk => { 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 288f14bbd7..96946d5c91 100644 --- a/Open-ILS/webby-src/src/app/staff/nav.component.css +++ b/Open-ILS/webby-src/src/app/staff/nav.component.css @@ -1,32 +1,39 @@ -#staff-navbar.navbar-default { +#staff-navbar { background: -webkit-linear-gradient(#00593d, #007a54); background-color: #007a54; color: #fff; + font-size: 14px; } -#staff-navbar.navbar-default .navbar-nav>li>a { +#staff-navbar .navbar-expander { + margin-right: auto; +} +#staff-navbar .navbar-nav>li>a { color: #fff; padding-top: 5px; - padding-bottom: 5px; + padding-bottom: 1px; +} +#staff-navbar .nav-item { + margin-right: 10px; } -#staff-navbar.navbar-default .navbar-nav>li>a:hover { +#staff-navbar .navbar-nav>li>a:hover { color: #ddd; + cursor: pointer; } -#staff-navbar.navbar-default .navbar-nav > .open > a, -#staff-navbar.navbar-default .navbar-nav > .open > a:focus, -#staff-navbar.navbar-default .navbar-nav > .open > a:hover { +#staff-navbar .navbar-nav > .open > a, +#staff-navbar .navbar-nav > .open > a:focus, +#staff-navbar .navbar-nav > .open > a:hover { background-color: #7a7a7a; } -#staff-navbar.navbar-default .navbar-nav>.dropdown>a .caret { +#staff-navbar .navbar-nav>.dropdown>a .caret { border-top-color: #fff; border-bottom-color: #fff; } -#staff-navbar.navbar-default .navbar-nav>.dropdown>a:hover .caret { +#staff-navbar .navbar-nav>.dropdown>a:hover .caret { border-top-color: #ddd; border-bottom-color: #ddd; } -#staff-navbar .nav-left { - margin-right: auto; -} -#staff-navbar .nav-right { - margin-right: 6px; +/* remove dropdown carret for icon-based entries */ +#staff-navbar .no-caret::after { + display:none; } + 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 b7d566b2bb..e5f32cdace 100644 --- a/Open-ILS/webby-src/src/app/staff/nav.component.html +++ b/Open-ILS/webby-src/src/app/staff/nav.component.html @@ -4,15 +4,18 @@ href="./stuff" direct routing routerLink="/suff" --> +