From: Bill Erickson Date: Tue, 12 Dec 2017 22:56:18 +0000 (-0500) Subject: LP#626157 Ang2 experiments X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6c626282c1ed5bbda26220925a5b22345e183651;p=working%2FEvergreen.git LP#626157 Ang2 experiments Signed-off-by: Bill Erickson --- 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.component.html deleted file mode 100644 index 5b95268e34..0000000000 --- a/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations.component.html +++ /dev/null @@ -1,75 +0,0 @@ -
-
-
- Workstation {{removingWs}} is no longer valid. Removing registration. -
-
- Please register a workstation. -
- -
-
Register a New Workstation For This Browser
-
-
-
- - -
-
-
- -
- -
-
-
-
-
-
- Workstations Registered With This Browser -
-
-
-
- -
-
-
-
- - - -
-
-
-
- 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 deleted file mode 100644 index 0006a1b9e0..0000000000 --- a/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations.component.ts +++ /dev/null @@ -1,78 +0,0 @@ -import {Component, OnInit} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; -import {EgStoreService} from '@eg/core/store'; -import {EgIdlObject} from '@eg/core/idl'; -import {EgNetService} from '@eg/core/net'; -import {EgAuthService} from '@eg/core/auth'; -import {EgOrgService} from '@eg/core/org'; - -// Slim version of the WS that's stored in the cache. -interface Workstation { - id: number; - name: string; - owning_lib: number; -} - -@Component({ - templateUrl: 'workstations.component.html' -}) -export class EgWorkstationsComponent implements OnInit { - - selectedId: Number; - workstations: Workstation[] = []; - isRemoving: boolean = false; - newOwner: EgIdlObject; - newName: String; - - - // Org selector options. - hideOrgs: number[]; - disableOrgs: number[]; - orgOnChange = (org: EgIdlObject): void => { - this.newOwner = org; - } - - constructor( - private route: ActivatedRoute, - private net: EgNetService, - private store: EgStoreService, - private auth: EgAuthService, - private org: EgOrgService - ) {} - - ngOnInit() { - this.store.getItem('eg.workstation.all') - .then(res => this.workstations = res); - - // TODO: perm limits required here too - this.disableOrgs = this.org.filterList({canHaveUsers : true}, true); - } - - selected(): Workstation { - return this.workstations.filter( - ws => {return ws.id == this.selectedId})[0]; - } - - useNow(): void { - console.debug('using ' + this.selected().name); - } - - setDefault(): void { - console.debug('defaulting ' + this.selected().name); - } - - removeSelected(): void { - console.debug('removing ' + this.selected().name); - } - - canDeleteSelected(): boolean { - return true; - } - - registerWorkstation(): void { - console.log(`Registering new workstation ` + - `"${this.newName}" at ${this.newOwner.shortname()}`); - } -} - - diff --git a/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/app.component.html b/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/app.component.html new file mode 100644 index 0000000000..5b95268e34 --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/app.component.html @@ -0,0 +1,75 @@ +
+
+
+ Workstation {{removingWs}} is no longer valid. Removing registration. +
+
+ Please register a workstation. +
+ +
+
Register a New Workstation For This Browser
+
+
+
+ + +
+
+
+ +
+ +
+
+
+
+
+
+ Workstations Registered With This Browser +
+
+
+
+ +
+
+
+
+ + + +
+
+
+
+ diff --git a/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/app.component.ts b/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/app.component.ts new file mode 100644 index 0000000000..b724dc0f2e --- /dev/null +++ b/Open-ILS/webby-src/src/app/staff/admin/workstation/workstations/app.component.ts @@ -0,0 +1,83 @@ +import {Component, OnInit} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; +import {EgStoreService} from '@eg/core/store'; +import {EgIdlObject} from '@eg/core/idl'; +import {EgNetService} from '@eg/core/net'; +import {EgAuthService} from '@eg/core/auth'; +import {EgOrgService} from '@eg/core/org'; + +// Slim version of the WS that's stored in the cache. +interface Workstation { + id: number; + name: string; + owning_lib: number; +} + +@Component({ + templateUrl: 'app.component.html' +}) +export class WorkstationsComponent implements OnInit { + + selectedId: Number; + workstations: Workstation[] = []; + removeWorkstation: string; + newOwner: EgIdlObject; + newName: String; + + // Org selector options. + hideOrgs: number[]; + disableOrgs: number[]; + orgOnChange = (org: EgIdlObject): void => { + this.newOwner = org; + } + + constructor( + private route: ActivatedRoute, + private net: EgNetService, + private store: EgStoreService, + private auth: EgAuthService, + private org: EgOrgService + ) {} + + ngOnInit() { + this.store.getItem('eg.workstation.all') + .then(res => this.workstations = res); + + // 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 { + return this.workstations.filter( + ws => {return ws.id == this.selectedId})[0]; + } + + useNow(): void { + console.debug('using ' + this.selected().name); + } + + setDefault(): void { + console.debug('defaulting ' + this.selected().name); + } + + removeSelected(): void { + console.debug('removing ' + this.selected().name); + } + + canDeleteSelected(): boolean { + return true; + } + + registerWorkstation(): void { + console.log(`Registering new workstation ` + + `"${this.newName}" at ${this.newOwner.shortname()}`); + } +} + + 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}} + ); } }