From 099fd5a97de26451c3d97f818cef8bb67306c477 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 12 Dec 2017 17:56:18 -0500 Subject: [PATCH] LP#626157 Ang2 experiments Signed-off-by: Bill Erickson --- .../src/app/share/catalog/catalog-url.service.ts | 10 +- .../src/app/share/catalog/search-context.ts | 12 +-- .../webby-src/src/app/staff/admin/app.module.ts | 10 -- .../src/app/staff/admin/routing.module.ts | 2 +- .../src/app/staff/admin/workstation/app.module.ts | 19 ---- .../app/staff/admin/workstation/routing.module.ts | 11 +- .../app.component.html} | 0 .../app.component.ts} | 13 ++- .../admin/workstation/workstations/app.module.ts | 21 ++++ .../workstation/workstations/routing.module.ts | 25 +++++ Open-ILS/webby-src/src/app/staff/app.component.ts | 4 +- .../webby-src/src/app/staff/circ/app.module.ts | 16 --- .../webby-src/src/app/staff/login.component.ts | 7 +- .../webby-src/src/app/staff/resolver.service.ts | 4 +- Open-ILS/webby-src/src/app/staff/routing.module.ts | 4 +- .../webby-src/src/app/staff/splash.component.html | 112 ++++++++++++++++++++- .../webby-src/src/app/staff/splash.component.ts | 27 ++++- 17 files changed, 217 insertions(+), 80 deletions(-) delete mode 100644 Open-ILS/webby-src/src/app/staff/admin/app.module.ts delete mode 100644 Open-ILS/webby-src/src/app/staff/admin/workstation/app.module.ts rename Open-ILS/webby-src/src/app/staff/admin/workstation/{workstations.component.html => workstations/app.component.html} (100%) rename Open-ILS/webby-src/src/app/staff/admin/workstation/{workstations.component.ts => workstations/app.component.ts} (84%) create mode 100644 Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/app.module.ts create mode 100644 Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/routing.module.ts delete mode 100644 Open-ILS/webby-src/src/app/staff/circ/app.module.ts diff --git a/Open-ILS/webby-src/src/app/share/catalog/catalog-url.service.ts b/Open-ILS/webby-src/src/app/share/catalog/catalog-url.service.ts index 27a05a0900..00f3203956 100644 --- a/Open-ILS/webby-src/src/app/share/catalog/catalog-url.service.ts +++ b/Open-ILS/webby-src/src/app/share/catalog/catalog-url.service.ts @@ -62,7 +62,11 @@ export class EgCatalogUrlService { // Each facet is a JSON encoded blob of class, name, and value context.facetFilters.forEach(facet => { - params.facets.push(JSON.stringify(facet)); + params.facets.push(JSON.stringify({ + c : facet.facetClass, + n : facet.facetName, + v : facet.facetValue + })); }); params.org = context.searchOrg.id(); @@ -114,8 +118,8 @@ export class EgCatalogUrlService { }); params.getAll('facets').forEach(blob => { - let facet: FacetFilter = JSON.parse(blob); - context.addFacet(facet); + let facet = JSON.parse(blob); + context.addFacet(new FacetFilter(facet.c, facet.n, facet.v)); }); context.searchOrg = diff --git a/Open-ILS/webby-src/src/app/share/catalog/search-context.ts b/Open-ILS/webby-src/src/app/share/catalog/search-context.ts index 61ea37ce02..b3c21e53a8 100644 --- a/Open-ILS/webby-src/src/app/share/catalog/search-context.ts +++ b/Open-ILS/webby-src/src/app/share/catalog/search-context.ts @@ -3,8 +3,12 @@ import {EgIdlObject} from '@eg/core/idl'; import {Pager} from '@eg/share/util/pager'; import {Params} from '@angular/router'; +export enum CatalogSearchState { + PENDING, + SEARCHING, + COMPLETE +} -// Document and enforce facet filter entries. export class FacetFilter { facetClass: string; facetName: string; @@ -25,12 +29,6 @@ export class FacetFilter { } } -export enum CatalogSearchState { - PENDING, - SEARCHING, - COMPLETE -} - // Not an angular service. // It's conceviable there could be multiple contexts. export class CatalogSearchContext { diff --git a/Open-ILS/webby-src/src/app/staff/admin/app.module.ts b/Open-ILS/webby-src/src/app/staff/admin/app.module.ts deleted file mode 100644 index 10613316ac..0000000000 --- a/Open-ILS/webby-src/src/app/staff/admin/app.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import {CommonModule} from '@angular/common'; -import {NgModule} from '@angular/core'; -import {EgAdminRoutingModule} from './routing.module'; - -@NgModule({ - declarations: [], - imports: [EgAdminRoutingModule] -}) - -export class EgAdminModule {} diff --git a/Open-ILS/webby-src/src/app/staff/admin/routing.module.ts b/Open-ILS/webby-src/src/app/staff/admin/routing.module.ts index 53418899fe..4e4ef09152 100644 --- a/Open-ILS/webby-src/src/app/staff/admin/routing.module.ts +++ b/Open-ILS/webby-src/src/app/staff/admin/routing.module.ts @@ -5,7 +5,7 @@ const routes: Routes = [{ path: '', children : [{ path: 'workstation', - loadChildren: '@eg/staff/admin/workstation/app.module#EgAdminWsModule' + loadChildren: '@eg/staff/admin/workstation/routing.module#EgAdminWsRoutingModule' }] }]; diff --git a/Open-ILS/webby-src/src/app/staff/admin/workstation/app.module.ts b/Open-ILS/webby-src/src/app/staff/admin/workstation/app.module.ts deleted file mode 100644 index 71015dff53..0000000000 --- a/Open-ILS/webby-src/src/app/staff/admin/workstation/app.module.ts +++ /dev/null @@ -1,19 +0,0 @@ -import {NgModule} from '@angular/core'; -import {CommonModule} from '@angular/common'; -import {EgStaffModule} from '../../app.module'; -import {EgAdminWsRoutingModule} from './routing.module'; -import {EgWorkstationsComponent} from './workstations.component'; - -@NgModule({ - declarations: [ - EgWorkstationsComponent - ], - imports: [ - EgStaffModule, - EgAdminWsRoutingModule, - CommonModule - ] -}) - -export class EgAdminWsModule {} - diff --git a/Open-ILS/webby-src/src/app/staff/admin/workstation/routing.module.ts b/Open-ILS/webby-src/src/app/staff/admin/workstation/routing.module.ts index c65a5e791c..114c312f3d 100644 --- a/Open-ILS/webby-src/src/app/staff/admin/workstation/routing.module.ts +++ b/Open-ILS/webby-src/src/app/staff/admin/workstation/routing.module.ts @@ -1,13 +1,10 @@ import {NgModule} from '@angular/core'; import {RouterModule, Routes} from '@angular/router'; -import {EgWorkstationsComponent} from './workstations.component'; -const routes: Routes = [ - // TODO: load each sub-app lazily - { path: 'workstations', - component: EgWorkstationsComponent - } -]; +const routes: Routes = [{ + path: 'workstations', + loadChildren: '@eg/staff/admin/workstation/workstations/app.module#ManageWorkstationsModule' +}]; @NgModule({ imports: [RouterModule.forChild(routes)], 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/app.component.html similarity index 100% rename from Open-ILS/webby-src/src/app/staff/admin/workstation/workstations.component.html rename to Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/app.component.html 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/app.component.ts similarity index 84% rename from Open-ILS/webby-src/src/app/staff/admin/workstation/workstations.component.ts rename to Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/app.component.ts index 0006a1b9e0..b724dc0f2e 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/app.component.ts @@ -14,17 +14,16 @@ interface Workstation { } @Component({ - templateUrl: 'workstations.component.html' + templateUrl: 'app.component.html' }) -export class EgWorkstationsComponent implements OnInit { +export class WorkstationsComponent implements OnInit { selectedId: Number; workstations: Workstation[] = []; - isRemoving: boolean = false; + removeWorkstation: string; newOwner: EgIdlObject; newName: String; - // Org selector options. hideOrgs: number[]; disableOrgs: number[]; @@ -46,6 +45,12 @@ export class EgWorkstationsComponent implements OnInit { // TODO: perm limits required here too this.disableOrgs = this.org.filterList({canHaveUsers : true}, true); + + this.removeWorkstation = this.route.snapshot.paramMap.get('remove'); + if (this.removeWorkstation) { + console.log('Removing workstation ' + this.removeWorkstation); + // TODO remove + } } selected(): Workstation { diff --git a/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/app.module.ts b/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/app.module.ts new file mode 100644 index 0000000000..c7051fb759 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/app.module.ts @@ -0,0 +1,21 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {EgStaffModule} from '@eg/staff/app.module'; +import {WorkstationsRoutingModule} from './routing.module'; +import {WorkstationsComponent} from './app.component'; + +@NgModule({ + declarations: [ + WorkstationsComponent + ], + imports: [ + CommonModule, + EgStaffModule, + WorkstationsRoutingModule + ] +}) + +export class ManageWorkstationsModule { + constructor() {console.log('Loading ManageWorkstationsModule')} +} + diff --git a/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/routing.module.ts b/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/routing.module.ts new file mode 100644 index 0000000000..f1ac37ed0c --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/routing.module.ts @@ -0,0 +1,25 @@ +import {NgModule} from '@angular/core'; +import {RouterModule, Routes} from '@angular/router'; +import {WorkstationsComponent} from './app.component'; + +// Note that we need a path value (e.g. 'manage') because without it +// there is nothing for the router to match, unless we rely on the parent +// module to handle all of our routing for us. +const routes: Routes = [ + { + path: 'manage', + component: WorkstationsComponent + }, { + path: 'remove/:remove', + component: WorkstationsComponent + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) + +export class WorkstationsRoutingModule { +} + diff --git a/Open-ILS/webby-src/src/app/staff/app.component.ts b/Open-ILS/webby-src/src/app/staff/app.component.ts index 48b6a66db6..3c90ab0a91 100644 --- a/Open-ILS/webby-src/src/app/staff/app.component.ts +++ b/Open-ILS/webby-src/src/app/staff/app.component.ts @@ -11,7 +11,7 @@ import { EgNetService } from '@eg/core/net'; export class EgStaffComponent implements OnInit { readonly loginPath = '/staff/login'; - readonly wsAdminPath = '/staff/admin/workstation/workstations'; + readonly wsAdminPath = '/staff/admin/workstation/workstations/manage'; constructor( private router: Router, @@ -36,7 +36,7 @@ export class EgStaffComponent implements OnInit { this.net.authExpired$.subscribe(uhOh => { console.debug('Auth session has expired. Redirecting to login'); this.auth.redirectUrl = this.router.url; - this.router.navigate(['/staff/login']); + this.router.navigate([this.loginPath]); }); this.route.data.subscribe((data: {staffResolver : any}) => { diff --git a/Open-ILS/webby-src/src/app/staff/circ/app.module.ts b/Open-ILS/webby-src/src/app/staff/circ/app.module.ts deleted file mode 100644 index b9ea323f2f..0000000000 --- a/Open-ILS/webby-src/src/app/staff/circ/app.module.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { EgCircRoutingModule } from './routing.module'; - -@NgModule({ - declarations: [ - ], - imports: [ - EgCircRoutingModule - ], - providers: [] -}) - -export class EgCircModule { - -} 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 7ec46237b6..64ae6c5361 100644 --- a/Open-ILS/webby-src/src/app/staff/login.component.ts +++ b/Open-ILS/webby-src/src/app/staff/login.component.ts @@ -49,16 +49,17 @@ export class EgStaffLoginComponent implements OnInit { // post-login URL let url: string = this.auth.redirectUrl || '/staff/splash'; + let workstation: string = this.args.workstation; this.auth.login(this.args).then( ok => { this.auth.redirectUrl = null; if (this.auth.workstationState == EgAuthWsState.NOT_FOUND_SERVER) { - // User is logged in without a workstation. - // Redirect them to the WS admin page. + // User attempted to login with a workstation that is + // unknown to the server. Redirect to the WS admin page. this.router.navigate( - ['/staff/admin/workstation/workstations']); + ['/staff/admin/workstation/workstations/remove/${workstation}']); } else { // Force reload of the app after a successful login. // This allows the route resolver to re-run with a diff --git a/Open-ILS/webby-src/src/app/staff/resolver.service.ts b/Open-ILS/webby-src/src/app/staff/resolver.service.ts index a08b30bb31..8c23030377 100644 --- a/Open-ILS/webby-src/src/app/staff/resolver.service.ts +++ b/Open-ILS/webby-src/src/app/staff/resolver.service.ts @@ -16,7 +16,7 @@ import {EgAuthService} from '@eg/core/auth'; export class EgStaffResolver implements Resolve> { readonly loginPath = '/staff/login'; - readonly wsAdminPath = '/staff/admin/workstation/workstations'; + readonly wsAdminPath = '/staff/admin/workstation/workstations/manage'; constructor( private router: Router, @@ -33,6 +33,8 @@ export class EgStaffResolver implements Resolve> { console.debug('EgStaffResolver:resolve()'); // Staff cookies stay in /$base/staff/ + // NOTE: storing session data at '/' so it can be shared by + // Angularjs apps. this.store.loginSessionBasePath = '/'; //this.ngLocation.prepareExternalUrl('/staff'); diff --git a/Open-ILS/webby-src/src/app/staff/routing.module.ts b/Open-ILS/webby-src/src/app/staff/routing.module.ts index f2f41edaa2..81c0609565 100644 --- a/Open-ILS/webby-src/src/app/staff/routing.module.ts +++ b/Open-ILS/webby-src/src/app/staff/routing.module.ts @@ -24,13 +24,13 @@ const routes: Routes = [{ component: EgStaffSplashComponent }, { path: 'circ', - loadChildren : '@eg/staff/circ/app.module#EgCircModule' + loadChildren : '@eg/staff/circ/routing.module#EgCircRoutingModule' }, { path: 'catalog', loadChildren : '@eg/staff/catalog/app.module#EgCatalogModule' }, { path: 'admin', - loadChildren : '@eg/staff/admin/app.module#EgAdminModule' + loadChildren : '@eg/staff/admin/routing.module#EgAdminRoutingModule' }] }]; diff --git a/Open-ILS/webby-src/src/app/staff/splash.component.html b/Open-ILS/webby-src/src/app/staff/splash.component.html index a278fd1cbd..9f2f23e43a 100644 --- a/Open-ILS/webby-src/src/app/staff/splash.component.html +++ b/Open-ILS/webby-src/src/app/staff/splash.component.html @@ -1,7 +1,111 @@ -Staff Splash Page -
+
-Workstation Admin -
+ +
+
+ +
+
+ +
+
+
+
+
Circulation and Patrons
+
+ +
+
+ +
+
+
+
Item Search and Cataloging
+
+
+
+
+
+ + + + + +
+
+ +
+ + Copy Buckets +
+
+
+
+
+ +
+
+
+
Administration
+
+ +
+
+
+
diff --git a/Open-ILS/webby-src/src/app/staff/splash.component.ts b/Open-ILS/webby-src/src/app/staff/splash.component.ts index b8f8a0d8ae..e113437229 100644 --- a/Open-ILS/webby-src/src/app/staff/splash.component.ts +++ b/Open-ILS/webby-src/src/app/staff/splash.component.ts @@ -1,4 +1,5 @@ -import {Component, OnInit} from '@angular/core'; +import {Component, OnInit, Renderer} from '@angular/core'; +import {Router} from '@angular/router'; @Component({ templateUrl: 'splash.component.html' @@ -6,7 +7,31 @@ import {Component, OnInit} from '@angular/core'; export class EgStaffSplashComponent implements OnInit { + catSearchQuery: string; + + constructor( + private renderer: Renderer, + private router: Router + ) {} + ngOnInit() { + + // Focus catalog search form + this.renderer.selectRootElement('#catalog-search-input').focus(); + } + + checkEnter($event: any): void { + if ($event.keyCode == 13) + this.searchCatalog(); + } + + searchCatalog(): void { + if (!this.catSearchQuery) return; + + this.router.navigate( + ['/staff/catalog/search'], + {queryParams: {query : this.catSearchQuery}} + ); } } -- 2.11.0