From: Bill Erickson Date: Thu, 12 Apr 2018 21:26:18 +0000 (+0000) Subject: LP#1626157 Ang5 file names best practices; more dialog stuff X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=a455ab8502b4795c789355293e173e1f64c738d8;p=working%2FEvergreen.git LP#1626157 Ang5 file names best practices; more dialog stuff Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/core/README b/Open-ILS/src/eg2/src/app/core/README index 58828bed85..3cf0ec4708 100644 --- a/Open-ILS/src/eg2/src/app/core/README +++ b/Open-ILS/src/eg2/src/app/core/README @@ -1,8 +1,9 @@ Core Angular services and assocated types/classes. -Core services are imported and exported by the base module, which means -they are automatically added as dependencies to ALL applications. +Core services are imported and exported by the base module and +automatically added as dependencies to ALL applications. -1. Only add services here that are universally required! -2. Avoid path navigation in the core services as paths will vary by application. +1. Only add services here that are universally required. +2. Avoid URL path navigation in the core services as paths will vary + by application. diff --git a/Open-ILS/src/eg2/src/app/core/pcrud.ts b/Open-ILS/src/eg2/src/app/core/pcrud.ts index e8a3ec5cf6..6a8dc7dcf9 100644 --- a/Open-ILS/src/eg2/src/app/core/pcrud.ts +++ b/Open-ILS/src/eg2/src/app/core/pcrud.ts @@ -8,7 +8,7 @@ import {EgAuthService} from './auth'; declare var js2JSON: (jsThing:any) => string; declare var OpenSRF: any; // creating sessions -export interface EgPcrudReqOps { +interface EgPcrudReqOps { authoritative?: boolean; anonymous?: boolean; idlist?: boolean; diff --git a/Open-ILS/src/eg2/src/app/migration.module.ts b/Open-ILS/src/eg2/src/app/migration.module.ts index bf3bd6966a..92cec105e6 100644 --- a/Open-ILS/src/eg2/src/app/migration.module.ts +++ b/Open-ILS/src/eg2/src/app/migration.module.ts @@ -31,7 +31,8 @@ import {EgPcrudService} from '@eg/core/pcrud'; import {EgOrgService} from '@eg/core/org'; // Downgraded components -//import {EgConfirmDialogComponent} from '@eg/share/confirm-dialog.component'; +//import {EgDialogComponent} from '@eg/share/dialog/dialog.component'; +//import {EgConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; import {EgHelloWorldComponent} from '@eg/share/hello-world.component'; declare var angular: any; @@ -44,10 +45,15 @@ declare var angular: any; CookieModule.forRoot(), EgCommonModule.forRoot() ], - declarations: [EgHelloWorldComponent], + declarations: [ + EgHelloWorldComponent, + //EgDialogComponent, + //EgConfirmDialogComponent + ], entryComponents: [ EgHelloWorldComponent, - //EgConfirmDialogComponent // declared in EgCommonModule + //EgDialogComponent, + //EgConfirmDialogComponent ] }) @@ -77,6 +83,10 @@ export class EgMigrationModule { .factory('ng2Title', downgradeInjectable(Title)) .directive('eg2HelloWorld', downgradeComponent({component: EgHelloWorldComponent})) + /* + .directive('eg2ConfirmDialog', + downgradeComponent({component: EgConfirmDialogComponent})) + */ ; diff --git a/Open-ILS/src/eg2/src/app/routing.module.ts b/Open-ILS/src/eg2/src/app/routing.module.ts index a1547f824f..594521303f 100644 --- a/Open-ILS/src/eg2/src/app/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/routing.module.ts @@ -16,7 +16,7 @@ const routes: Routes = [ }, { path: 'staff', resolve : {startup : EgBaseResolver}, - loadChildren: './staff/app.module#EgStaffModule' + loadChildren: './staff/staff.module#EgStaffModule' } ]; diff --git a/Open-ILS/src/eg2/src/app/share/dialog/dialog.component.ts b/Open-ILS/src/eg2/src/app/share/dialog/dialog.component.ts index 27828058fc..397a6db4a7 100644 --- a/Open-ILS/src/eg2/src/app/share/dialog/dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/share/dialog/dialog.component.ts @@ -8,7 +8,7 @@ import {NgbModal, NgbModalRef} from '@ng-bootstrap/ng-bootstrap'; */ @Component({ - selector: 'eg-component', + selector: 'eg-dialog', template: '' }) export class EgDialogComponent { diff --git a/Open-ILS/src/eg2/src/app/share/dialog/prompt.component.ts b/Open-ILS/src/eg2/src/app/share/dialog/prompt.component.ts index abf96ece0a..179efeb6bc 100644 --- a/Open-ILS/src/eg2/src/app/share/dialog/prompt.component.ts +++ b/Open-ILS/src/eg2/src/app/share/dialog/prompt.component.ts @@ -7,7 +7,7 @@ import {EgDialogComponent} from '@eg/share/dialog/dialog.component'; }) /** - * Promptation dialog that asks a yes/no question. + * Promptation dialog that requests user input. */ export class EgPromptDialogComponent extends EgDialogComponent { // What question are we asking? diff --git a/Open-ILS/src/eg2/src/app/share/hello-world.component.ts b/Open-ILS/src/eg2/src/app/share/hello-world.component.ts new file mode 100644 index 0000000000..92daf1ccfa --- /dev/null +++ b/Open-ILS/src/eg2/src/app/share/hello-world.component.ts @@ -0,0 +1,14 @@ +import {Component, Input} from '@angular/core'; + +@Component({ + selector: 'eg-hello-world', + template: ` +
Hello, World {{message}}!
+ ` +}) +export class EgHelloWorldComponent { + @Input() public message: string; + constructor() {} +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/workstation/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/workstation/routing.module.ts index 114c312f3d..bd300d7a2b 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/workstation/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/workstation/routing.module.ts @@ -3,7 +3,7 @@ import {RouterModule, Routes} from '@angular/router'; const routes: Routes = [{ path: 'workstations', - loadChildren: '@eg/staff/admin/workstation/workstations/app.module#ManageWorkstationsModule' + loadChildren: '@eg/staff/admin/workstation/workstations/workstations.module#ManageWorkstationsModule' }]; @NgModule({ diff --git a/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.component.html b/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.component.html deleted file mode 100644 index 490f9a614c..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.component.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - -
-
-
- Workstation {{removeWorkstation}} 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/src/eg2/src/app/staff/admin/workstation/workstations/app.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.component.ts deleted file mode 100644 index 2e04c35977..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.component.ts +++ /dev/null @@ -1,176 +0,0 @@ -import {Component, OnInit, ViewChild} from '@angular/core'; -import {Router, ActivatedRoute} from '@angular/router'; -import {EgStoreService} from '@eg/core/store'; -import {EgIdlObject} from '@eg/core/idl'; -import {EgNetService} from '@eg/core/net'; -import {EgPermService} from '@eg/core/perm'; -import {EgAuthService} from '@eg/core/auth'; -import {EgOrgService} from '@eg/core/org'; -import {EgEventService} from '@eg/core/event'; -import {EgConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; - -// 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 { - - selectedName: string; - workstations: Workstation[] = []; - removeWorkstation: string; - newOwner: EgIdlObject; - newName: string; - defaultName: string; - - @ViewChild('workstationExistsDialog') - private wsExistsDialog: EgConfirmDialogComponent; - - // Org selector options. - hideOrgs: number[]; - disableOrgs: number[]; - orgOnChange = (org: EgIdlObject): void => { - this.newOwner = org; - } - - constructor( - private router: Router, - private route: ActivatedRoute, - private evt: EgEventService, - private net: EgNetService, - private store: EgStoreService, - private auth: EgAuthService, - private org: EgOrgService, - private perm: EgPermService - ) {} - - ngOnInit() { - this.store.getItem('eg.workstation.all') - .then(list => this.workstations = list || []) - .then(noop => this.store.getItem('eg.workstation.default')) - .then(defWs => { - this.defaultName = defWs; - this.selectedName = this.auth.workstation() || defWs - }) - .then(noop => { - let rm = this.route.snapshot.paramMap.get('remove'); - if (rm) this.removeSelected(this.removeWorkstation = rm) - }) - - this.perm.hasWorkPermAt(['REGISTER_WORKSTATION'], true) - .then(perms => { - // Disable org units that cannot have users and any - // that this user does not have work perms for. - this.disableOrgs = - this.org.filterList({canHaveUsers : false}, true) - .concat(this.org.filterList( - {notInList : perms.REGISTER_WORKSTATION}, true)); - }); - } - - selected(): Workstation { - return this.workstations.filter( - ws => {return ws.name == this.selectedName})[0]; - } - - useNow(): void { - if (!this.selected()) return; - this.router.navigate(['/staff/login'], - {queryParams: {workstation: this.selected().name}}); - } - - setDefault(): void { - if (!this.selected()) return; - this.defaultName = this.selected().name; - this.store.setItem('eg.workstation.default', this.defaultName); - } - - removeSelected(name?: string): void { - if (!name) name = this.selected().name; - - this.workstations = this.workstations.filter(w => w.name != name); - this.store.setItem('eg.workstation.all', this.workstations); - - if (this.defaultName == name) { - this.defaultName = null; - this.store.removeItem('eg.workstation.default'); - } - } - - canDeleteSelected(): boolean { - return true; - } - - registerWorkstation(): void { - console.log(`Registering new workstation ` + - `"${this.newName}" at ${this.newOwner.shortname()}`); - - this.newName = this.newOwner.shortname() + '-' + this.newName; - - this.registerWorkstationApi().then( - wsId => this.registerWorkstationLocal(wsId)); - - } - - private handleCollision(): Promise { - return new Promise((resolve, reject) => { - this.wsExistsDialog.open() - .then( - confirmed => { - this.registerWorkstationApi(true).then( - wsId => resolve(wsId), - notOk => reject(notOk) - ) - }, - dismissed => reject(dismissed) - ) - }); - } - - - private registerWorkstationApi(override?: boolean): Promise { - let method = 'open-ils.actor.workstation.register'; - if (override) method += '.override'; - - return new Promise((resolve, reject) => { - this.net.request( - 'open-ils.actor', method, - this.auth.token(), this.newName, this.newOwner.id() - ).subscribe(wsId => { - let evt = this.evt.parse(wsId); - if (evt) { - if (evt.textcode == 'WORKSTATION_NAME_EXISTS') { - this.handleCollision().then( - id => resolve(id), - notOk => reject(notOk) - ) - } else { - console.error(`Registration failed ${evt}`); - reject(); - } - } else { - resolve(wsId); - } - }); - }); - } - - private registerWorkstationLocal(wsId: number) { - let ws: Workstation = { - id: wsId, - name: this.newName, - owning_lib: this.newOwner.id() - }; - - this.workstations.push(ws); - this.store.setItem('eg.workstation.all', this.workstations) - .then(ok => this.newName = ''); - } -} - - diff --git a/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.module.ts deleted file mode 100644 index 00d9593f3b..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/app.module.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {NgModule} from '@angular/core'; -import {EgStaffCommonModule} from '@eg/staff/common.module'; -import {WorkstationsRoutingModule} from './routing.module'; -import {WorkstationsComponent} from './app.component'; - -@NgModule({ - declarations: [ - WorkstationsComponent, - ], - imports: [ - EgStaffCommonModule, - WorkstationsRoutingModule - ] -}) - -export class ManageWorkstationsModule {} - - diff --git a/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/routing.module.ts index f1ac37ed0c..a29f19b686 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/routing.module.ts @@ -1,6 +1,6 @@ import {NgModule} from '@angular/core'; import {RouterModule, Routes} from '@angular/router'; -import {WorkstationsComponent} from './app.component'; +import {WorkstationsComponent} from './workstations.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 diff --git a/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/workstations.component.html b/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/workstations.component.html new file mode 100644 index 0000000000..490f9a614c --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/workstations.component.html @@ -0,0 +1,91 @@ + + + + + + + +
+
+
+ Workstation {{removeWorkstation}} 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/src/eg2/src/app/staff/admin/workstation/workstations/workstations.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/workstations.component.ts new file mode 100644 index 0000000000..690a485e62 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/workstations.component.ts @@ -0,0 +1,176 @@ +import {Component, OnInit, ViewChild} from '@angular/core'; +import {Router, ActivatedRoute} from '@angular/router'; +import {EgStoreService} from '@eg/core/store'; +import {EgIdlObject} from '@eg/core/idl'; +import {EgNetService} from '@eg/core/net'; +import {EgPermService} from '@eg/core/perm'; +import {EgAuthService} from '@eg/core/auth'; +import {EgOrgService} from '@eg/core/org'; +import {EgEventService} from '@eg/core/event'; +import {EgConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; + +// 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 WorkstationsComponent implements OnInit { + + selectedName: string; + workstations: Workstation[] = []; + removeWorkstation: string; + newOwner: EgIdlObject; + newName: string; + defaultName: string; + + @ViewChild('workstationExistsDialog') + private wsExistsDialog: EgConfirmDialogComponent; + + // Org selector options. + hideOrgs: number[]; + disableOrgs: number[]; + orgOnChange = (org: EgIdlObject): void => { + this.newOwner = org; + } + + constructor( + private router: Router, + private route: ActivatedRoute, + private evt: EgEventService, + private net: EgNetService, + private store: EgStoreService, + private auth: EgAuthService, + private org: EgOrgService, + private perm: EgPermService + ) {} + + ngOnInit() { + this.store.getItem('eg.workstation.all') + .then(list => this.workstations = list || []) + .then(noop => this.store.getItem('eg.workstation.default')) + .then(defWs => { + this.defaultName = defWs; + this.selectedName = this.auth.workstation() || defWs + }) + .then(noop => { + let rm = this.route.snapshot.paramMap.get('remove'); + if (rm) this.removeSelected(this.removeWorkstation = rm) + }) + + this.perm.hasWorkPermAt(['REGISTER_WORKSTATION'], true) + .then(perms => { + // Disable org units that cannot have users and any + // that this user does not have work perms for. + this.disableOrgs = + this.org.filterList({canHaveUsers : false}, true) + .concat(this.org.filterList( + {notInList : perms.REGISTER_WORKSTATION}, true)); + }); + } + + selected(): Workstation { + return this.workstations.filter( + ws => {return ws.name == this.selectedName})[0]; + } + + useNow(): void { + if (!this.selected()) return; + this.router.navigate(['/staff/login'], + {queryParams: {workstation: this.selected().name}}); + } + + setDefault(): void { + if (!this.selected()) return; + this.defaultName = this.selected().name; + this.store.setItem('eg.workstation.default', this.defaultName); + } + + removeSelected(name?: string): void { + if (!name) name = this.selected().name; + + this.workstations = this.workstations.filter(w => w.name != name); + this.store.setItem('eg.workstation.all', this.workstations); + + if (this.defaultName == name) { + this.defaultName = null; + this.store.removeItem('eg.workstation.default'); + } + } + + canDeleteSelected(): boolean { + return true; + } + + registerWorkstation(): void { + console.log(`Registering new workstation ` + + `"${this.newName}" at ${this.newOwner.shortname()}`); + + this.newName = this.newOwner.shortname() + '-' + this.newName; + + this.registerWorkstationApi().then( + wsId => this.registerWorkstationLocal(wsId)); + + } + + private handleCollision(): Promise { + return new Promise((resolve, reject) => { + this.wsExistsDialog.open() + .then( + confirmed => { + this.registerWorkstationApi(true).then( + wsId => resolve(wsId), + notOk => reject(notOk) + ) + }, + dismissed => reject(dismissed) + ) + }); + } + + + private registerWorkstationApi(override?: boolean): Promise { + let method = 'open-ils.actor.workstation.register'; + if (override) method += '.override'; + + return new Promise((resolve, reject) => { + this.net.request( + 'open-ils.actor', method, + this.auth.token(), this.newName, this.newOwner.id() + ).subscribe(wsId => { + let evt = this.evt.parse(wsId); + if (evt) { + if (evt.textcode == 'WORKSTATION_NAME_EXISTS') { + this.handleCollision().then( + id => resolve(id), + notOk => reject(notOk) + ) + } else { + console.error(`Registration failed ${evt}`); + reject(); + } + } else { + resolve(wsId); + } + }); + }); + } + + private registerWorkstationLocal(wsId: number) { + let ws: Workstation = { + id: wsId, + name: this.newName, + owning_lib: this.newOwner.id() + }; + + this.workstations.push(ws); + this.store.setItem('eg.workstation.all', this.workstations) + .then(ok => this.newName = ''); + } +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/workstations.module.ts b/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/workstations.module.ts new file mode 100644 index 0000000000..064b24dd45 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/workstation/workstations/workstations.module.ts @@ -0,0 +1,18 @@ +import {NgModule} from '@angular/core'; +import {EgStaffCommonModule} from '@eg/staff/common.module'; +import {WorkstationsRoutingModule} from './routing.module'; +import {WorkstationsComponent} from './workstations.component'; + +@NgModule({ + declarations: [ + WorkstationsComponent, + ], + imports: [ + EgStaffCommonModule, + WorkstationsRoutingModule + ] +}) + +export class ManageWorkstationsModule {} + + diff --git a/Open-ILS/src/eg2/src/app/staff/app.component.css b/Open-ILS/src/eg2/src/app/staff/app.component.css deleted file mode 100644 index 508d879b9b..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/app.component.css +++ /dev/null @@ -1,8 +0,0 @@ -#staff-content-container { - width: 95%; - margin-top:56px; - padding-right: 10px; - padding-left: 10px; - margin-right: auto; - margin-left: auto; -} diff --git a/Open-ILS/src/eg2/src/app/staff/app.component.html b/Open-ILS/src/eg2/src/app/staff/app.component.html deleted file mode 100644 index 7bd463a623..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/app.component.html +++ /dev/null @@ -1,8 +0,0 @@ - - - -
- - -
- diff --git a/Open-ILS/src/eg2/src/app/staff/app.component.ts b/Open-ILS/src/eg2/src/app/staff/app.component.ts deleted file mode 100644 index f4bf36fe8d..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/app.component.ts +++ /dev/null @@ -1,88 +0,0 @@ -import {Component, OnInit, NgZone} from '@angular/core'; -import {Router, ActivatedRoute, NavigationEnd} from '@angular/router'; -import {EgAuthService, EgAuthWsState} from '@eg/core/auth'; -import {EgNetService} from '@eg/core/net'; - -@Component({ - templateUrl: 'app.component.html', - styleUrls: ['app.component.css'] -}) - -export class EgStaffComponent implements OnInit { - - readonly loginPath = '/staff/login'; - readonly wsAdminBasePath = '/staff/admin/workstation/workstations/'; - - constructor( - private router: Router, - private route: ActivatedRoute, - private zone: NgZone, - private net: EgNetService, - private auth: EgAuthService - ) {} - - ngOnInit() { - - console.debug('EgStaffComponent:ngOnInit()'); - - // Fires on all in-app router navigation, but not initial page load. - this.router.events.subscribe(routeEvent => { - if (routeEvent instanceof NavigationEnd) { - //console.debug(`EgStaffComponent routing to ${routeEvent.url}`); - this.basicAuthChecks(routeEvent.url); - } - }); - - // Redirect to the login page on any auth timeout events. - this.net.authExpired$.subscribe(expireEvent => { - - // If the expired authtoken was identified locally (i.e. - // in this browser tab) notify all tabs of imminent logout. - if (!expireEvent.viaExternal) this.auth.broadcastLogout(); - - console.debug('Auth session has expired. Redirecting to login'); - this.auth.redirectUrl = this.router.url; - - // https://github.com/angular/angular/issues/18254 - // When a tab redirects to a login page as a result of - // another tab broadcasting a logout, ngOnInit() fails to - // fire in the login component, until the user interacts - // with the page. Fix it by wrapping it in zone.run(). - // This is the only navigate() where I have seen this happen. - this.zone.run(() => { - this.router.navigate([this.loginPath]); - }); - }); - - this.route.data.subscribe((data: {staffResolver : any}) => { - // Data fetched via EgStaffResolver is available here. - }); - } - - /** - * Verifying the auth token on every route is overkill, since - * an expired token will make itself known with the first API - * call or when the auth session poll discovers it, but we do - * want to prevent navigation from the login or workstation admin - * page, since these can be accessed without a valid authtoken or - * workstation, respectively, once the initial route resolvers have - * done their jobs. - */ - basicAuthChecks(url: string): void { - - // Access to login page is always granted - if (url == this.loginPath) return; - - if (!this.auth.token()) - this.router.navigate([this.loginPath]); - - // Access to workstation admin page is granted regardless - // of workstation validity. - if (url.indexOf(this.wsAdminBasePath) >= 0) return; - - if (this.auth.workstationState != EgAuthWsState.VALID) - this.router.navigate([this.wsAdminBasePath]); - } -} - - diff --git a/Open-ILS/src/eg2/src/app/staff/app.module.ts b/Open-ILS/src/eg2/src/app/staff/app.module.ts deleted file mode 100644 index dfdd41b512..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/app.module.ts +++ /dev/null @@ -1,24 +0,0 @@ -import {NgModule} from '@angular/core'; -import {EgStaffCommonModule} from '@eg/staff/common.module'; - -import {EgStaffComponent} from './app.component'; -import {EgStaffRoutingModule} from './routing.module'; -import {EgStaffNavComponent} from './nav.component'; -import {EgStaffLoginComponent} from './login.component'; -import {EgStaffSplashComponent} from './splash.component'; - -@NgModule({ - declarations: [ - EgStaffComponent, - EgStaffNavComponent, - EgStaffSplashComponent, - EgStaffLoginComponent - ], - imports: [ - EgStaffCommonModule.forRoot(), - EgStaffRoutingModule - ] -}) - -export class EgStaffModule {} - diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/app.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/app.component.html deleted file mode 100644 index 1596454ac1..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/catalog/app.component.html +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/app.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/app.component.ts deleted file mode 100644 index 8fffa13ed2..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/catalog/app.component.ts +++ /dev/null @@ -1,18 +0,0 @@ -import {Component, OnInit} from '@angular/core'; -import {StaffCatalogService} from './app.service'; - -@Component({ - templateUrl: 'app.component.html' -}) -export class EgCatalogComponent implements OnInit { - - constructor(private staffCat: StaffCatalogService) {} - - ngOnInit() { - // Create the search context that will be used by all of my - // child components. After initial creation, the context is - // reset and updated as needed to apply new search parameters. - this.staffCat.createContext(); - } -} - diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/app.module.ts b/Open-ILS/src/eg2/src/app/staff/catalog/app.module.ts deleted file mode 100644 index fbcf894586..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/catalog/app.module.ts +++ /dev/null @@ -1,46 +0,0 @@ -import {NgModule} from '@angular/core'; -import {EgStaffCommonModule} from '@eg/staff/common.module'; -import {EgUnapiService} from '@eg/share/unapi'; -import {EgCatalogRoutingModule} from './routing.module'; -import {EgCatalogService} from '@eg/share/catalog/catalog.service'; -import {EgCatalogUrlService} from '@eg/share/catalog/catalog-url.service'; -import {EgCatalogComponent} from './app.component'; -import {SearchFormComponent} from './search-form.component'; -import {ResultsComponent} from './result/results.component'; -import {RecordComponent} from './record/record.component'; -import {CopiesComponent} from './record/copies.component'; -import {EgBibSummaryComponent} from '../share/bib-summary.component'; -import {ResultPaginationComponent} from './result/pagination.component'; -import {ResultFacetsComponent} from './result/facets.component'; -import {ResultRecordComponent} from './result/record.component'; -import {StaffCatalogService} from './app.service'; -import {RecordPaginationComponent} from './record/pagination.component'; - -@NgModule({ - declarations: [ - EgCatalogComponent, - ResultsComponent, - RecordComponent, - CopiesComponent, - EgBibSummaryComponent, - SearchFormComponent, - ResultRecordComponent, - ResultFacetsComponent, - ResultPaginationComponent, - RecordPaginationComponent - ], - imports: [ - EgStaffCommonModule, - EgCatalogRoutingModule - ], - providers: [ - EgUnapiService, - EgCatalogService, - EgCatalogUrlService, - StaffCatalogService - ] -}) - -export class EgCatalogModule { - -} diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/app.service.ts b/Open-ILS/src/eg2/src/app/staff/catalog/app.service.ts deleted file mode 100644 index 0cf04ca7f2..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/catalog/app.service.ts +++ /dev/null @@ -1,82 +0,0 @@ -import {Injectable} from '@angular/core'; -import {Router, ActivatedRoute} from '@angular/router'; -import {EgIdlObject} from '@eg/core/idl'; -import {EgOrgService} from '@eg/core/org'; -import {EgCatalogService} from '@eg/share/catalog/catalog.service'; -import {EgCatalogUrlService} from '@eg/share/catalog/catalog-url.service'; -import {CatalogSearchContext} from '@eg/share/catalog/search-context'; - -/** - * Shared bits needed by the staff version of the catalog. - */ - -@Injectable() -export class StaffCatalogService { - - searchContext: CatalogSearchContext; - routeIndex: number = 0; - defaultSearchOrg: EgIdlObject; - defaultSearchLimit: number; - - // TODO: does unapi support pref-lib for result-page copy counts? - prefOrg: EgIdlObject; - - constructor( - private router: Router, - private route: ActivatedRoute, - private org: EgOrgService, - private cat: EgCatalogService, - private catUrl: EgCatalogUrlService - ) { } - - createContext(): void { - // Initialize the search context from the load-time URL params. - // Do this here so the search form and other context data are - // applied on every page, not just the search results page. The - // search results pages will handle running the actual search. - this.searchContext = - this.catUrl.fromUrlParams(this.route.snapshot.queryParamMap); - - this.searchContext.org = this.org; // service, not searchOrg - this.searchContext.isStaff = true; - this.applySearchDefaults(); - } - - applySearchDefaults(): void { - if (!this.searchContext.searchOrg) { - this.searchContext.searchOrg = - this.defaultSearchOrg || this.org.root(); - } - - if (!this.searchContext.pager.limit) { - this.searchContext.pager.limit = this.defaultSearchLimit || 20; - } - } - - /** - * Redirect to the search results page while propagating the current - * search paramters into the URL. Let the search results component - * execute the actual search. - */ - search(): void { - if (!this.searchContext.isSearchable()) return; - - let params = this.catUrl.toUrlParams(this.searchContext); - - // Force a new search every time this method is called, even if - // it's the same as the active search. Since router navigation - // exits early when the route + params is identical, add a - // random token to the route params to force a full navigation. - // This also resolves a problem where only removing secondary+ - // versions of a query param fail to cause a route navigation. - // (E.g. going from two query= params to one). Investigation - // pending. - params.ridx=''+this.routeIndex++; - - this.router.navigate( - ['/staff/catalog/search'], {queryParams: params}); - } - -} - - diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.component.html new file mode 100644 index 0000000000..1596454ac1 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.component.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.component.ts new file mode 100644 index 0000000000..0324ed406b --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.component.ts @@ -0,0 +1,18 @@ +import {Component, OnInit} from '@angular/core'; +import {StaffCatalogService} from './catalog.service'; + +@Component({ + templateUrl: 'catalog.component.html' +}) +export class EgCatalogComponent implements OnInit { + + constructor(private staffCat: StaffCatalogService) {} + + ngOnInit() { + // Create the search context that will be used by all of my + // child components. After initial creation, the context is + // reset and updated as needed to apply new search parameters. + this.staffCat.createContext(); + } +} + diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts new file mode 100644 index 0000000000..80a1499746 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.module.ts @@ -0,0 +1,46 @@ +import {NgModule} from '@angular/core'; +import {EgStaffCommonModule} from '@eg/staff/common.module'; +import {EgUnapiService} from '@eg/share/unapi'; +import {EgCatalogRoutingModule} from './routing.module'; +import {EgCatalogService} from '@eg/share/catalog/catalog.service'; +import {EgCatalogUrlService} from '@eg/share/catalog/catalog-url.service'; +import {EgCatalogComponent} from './catalog.component'; +import {SearchFormComponent} from './search-form.component'; +import {ResultsComponent} from './result/results.component'; +import {RecordComponent} from './record/record.component'; +import {CopiesComponent} from './record/copies.component'; +import {EgBibSummaryComponent} from '../share/bib-summary.component'; +import {ResultPaginationComponent} from './result/pagination.component'; +import {ResultFacetsComponent} from './result/facets.component'; +import {ResultRecordComponent} from './result/record.component'; +import {StaffCatalogService} from './catalog.service'; +import {RecordPaginationComponent} from './record/pagination.component'; + +@NgModule({ + declarations: [ + EgCatalogComponent, + ResultsComponent, + RecordComponent, + CopiesComponent, + EgBibSummaryComponent, + SearchFormComponent, + ResultRecordComponent, + ResultFacetsComponent, + ResultPaginationComponent, + RecordPaginationComponent + ], + imports: [ + EgStaffCommonModule, + EgCatalogRoutingModule + ], + providers: [ + EgUnapiService, + EgCatalogService, + EgCatalogUrlService, + StaffCatalogService + ] +}) + +export class EgCatalogModule { + +} diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts new file mode 100644 index 0000000000..0cf04ca7f2 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts @@ -0,0 +1,82 @@ +import {Injectable} from '@angular/core'; +import {Router, ActivatedRoute} from '@angular/router'; +import {EgIdlObject} from '@eg/core/idl'; +import {EgOrgService} from '@eg/core/org'; +import {EgCatalogService} from '@eg/share/catalog/catalog.service'; +import {EgCatalogUrlService} from '@eg/share/catalog/catalog-url.service'; +import {CatalogSearchContext} from '@eg/share/catalog/search-context'; + +/** + * Shared bits needed by the staff version of the catalog. + */ + +@Injectable() +export class StaffCatalogService { + + searchContext: CatalogSearchContext; + routeIndex: number = 0; + defaultSearchOrg: EgIdlObject; + defaultSearchLimit: number; + + // TODO: does unapi support pref-lib for result-page copy counts? + prefOrg: EgIdlObject; + + constructor( + private router: Router, + private route: ActivatedRoute, + private org: EgOrgService, + private cat: EgCatalogService, + private catUrl: EgCatalogUrlService + ) { } + + createContext(): void { + // Initialize the search context from the load-time URL params. + // Do this here so the search form and other context data are + // applied on every page, not just the search results page. The + // search results pages will handle running the actual search. + this.searchContext = + this.catUrl.fromUrlParams(this.route.snapshot.queryParamMap); + + this.searchContext.org = this.org; // service, not searchOrg + this.searchContext.isStaff = true; + this.applySearchDefaults(); + } + + applySearchDefaults(): void { + if (!this.searchContext.searchOrg) { + this.searchContext.searchOrg = + this.defaultSearchOrg || this.org.root(); + } + + if (!this.searchContext.pager.limit) { + this.searchContext.pager.limit = this.defaultSearchLimit || 20; + } + } + + /** + * Redirect to the search results page while propagating the current + * search paramters into the URL. Let the search results component + * execute the actual search. + */ + search(): void { + if (!this.searchContext.isSearchable()) return; + + let params = this.catUrl.toUrlParams(this.searchContext); + + // Force a new search every time this method is called, even if + // it's the same as the active search. Since router navigation + // exits early when the route + params is identical, add a + // random token to the route params to force a full navigation. + // This also resolves a problem where only removing secondary+ + // versions of a query param fail to cause a route navigation. + // (E.g. going from two query= params to one). Investigation + // pending. + params.ridx=''+this.routeIndex++; + + this.router.navigate( + ['/staff/catalog/search'], {queryParams: params}); + } + +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.ts index b8e05f0baa..cae7920175 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/copies.component.ts @@ -1,6 +1,6 @@ import {Component, OnInit, Input} from '@angular/core'; import {EgNetService} from '@eg/core/net'; -import {StaffCatalogService} from '../app.service'; +import {StaffCatalogService} from '../catalog.service'; import {Pager} from '@eg/share/util/pager'; import {EgOrgService} from '@eg/core/org'; diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/pagination.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/pagination.component.ts index a7535f6514..31fee2cde6 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/pagination.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/pagination.component.ts @@ -3,7 +3,7 @@ import {Router} from '@angular/router'; import {EgCatalogService} from '@eg/share/catalog/catalog.service'; import {CatalogSearchContext} from '@eg/share/catalog/search-context'; import {EgCatalogUrlService} from '@eg/share/catalog/catalog-url.service'; -import {StaffCatalogService} from '../app.service'; +import {StaffCatalogService} from '../catalog.service'; import {Pager} from '@eg/share/util/pager'; diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts index 78552eb443..61e5759cd8 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/record/record.component.ts @@ -5,7 +5,7 @@ import {EgIdlObject} from '@eg/core/idl'; import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context'; import {EgCatalogService} from '@eg/share/catalog/catalog.service'; -import {StaffCatalogService} from '../app.service'; +import {StaffCatalogService} from '../catalog.service'; import {EgBibSummaryComponent} from '../../share/bib-summary.component'; @Component({ diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts b/Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts index 45fc8c5927..8452323a94 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts @@ -8,7 +8,7 @@ import {EgOrgService} from '@eg/core/org'; import {EgAuthService} from '@eg/core/auth'; import {EgPcrudService} from '@eg/core/pcrud'; import {EgCatalogService} from '@eg/share/catalog/catalog.service'; -import {StaffCatalogService} from './app.service'; +import {StaffCatalogService} from './catalog.service'; @Injectable() export class EgCatalogResolver implements Resolve> { diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/facets.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/result/facets.component.ts index 8101ceda01..be689686c4 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/facets.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/facets.component.ts @@ -1,7 +1,7 @@ import {Component, OnInit, Input} from '@angular/core'; import {EgCatalogService} from '@eg/share/catalog/catalog.service'; import {CatalogSearchContext, FacetFilter} from '@eg/share/catalog/search-context'; -import {StaffCatalogService} from '../app.service'; +import {StaffCatalogService} from '../catalog.service'; export const FACET_CONFIG = { display: [ diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/pagination.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/result/pagination.component.ts index 8dbb4d84c9..189fbced81 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/pagination.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/pagination.component.ts @@ -1,7 +1,7 @@ import {Component, OnInit, Input} from '@angular/core'; import {EgCatalogService} from '@eg/share/catalog/catalog.service'; import {CatalogSearchContext} from '@eg/share/catalog/search-context'; -import {StaffCatalogService} from '../app.service'; +import {StaffCatalogService} from '../catalog.service'; @Component({ selector: 'eg-catalog-result-pagination', diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts index beee4cfbb0..cf903f56c2 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts @@ -5,7 +5,7 @@ import {EgCatalogService} from '@eg/share/catalog/catalog.service'; import {CatalogSearchContext} from '@eg/share/catalog/search-context'; import {EgNetService} from '@eg/core/net'; import {EgCatalogUrlService} from '@eg/share/catalog/catalog-url.service'; -import {StaffCatalogService} from '../app.service'; +import {StaffCatalogService} from '../catalog.service'; @Component({ selector: 'eg-catalog-result-record', diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts index ff2d36ce29..ff9c259a25 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts @@ -7,7 +7,7 @@ import {EgCatalogUrlService} from '@eg/share/catalog/catalog-url.service'; import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context'; import {EgPcrudService} from '@eg/core/pcrud'; -import {StaffCatalogService} from '../app.service'; +import {StaffCatalogService} from '../catalog.service'; import {EgIdlObject} from '@eg/core/idl'; @Component({ diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/catalog/routing.module.ts index 9125c9d7eb..2376f80cb4 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/routing.module.ts @@ -1,6 +1,6 @@ import {NgModule} from '@angular/core'; import {RouterModule, Routes} from '@angular/router'; -import {EgCatalogComponent} from './app.component'; +import {EgCatalogComponent} from './catalog.component'; import {ResultsComponent} from './result/results.component'; import {RecordComponent} from './record/record.component'; import {EgCatalogResolver} from './resolver.service'; diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts index 9e5b807593..615e608f34 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts @@ -4,7 +4,7 @@ import {EgOrgService} from '@eg/core/org'; import {EgCatalogService,} from '@eg/share/catalog/catalog.service'; import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context'; -import {StaffCatalogService} from './app.service'; +import {StaffCatalogService} from './catalog.service'; @Component({ selector: 'eg-catalog-search-form', diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/app.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/app.component.html deleted file mode 100644 index 58d5c4c3d5..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/app.component.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - -
-
-
- Barcode: -
- -
- -
-
-
- - diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/app.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/app.component.ts deleted file mode 100644 index 294a88e3c8..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/app.component.ts +++ /dev/null @@ -1,36 +0,0 @@ -import {Component, OnInit, Renderer} from '@angular/core'; -import {ActivatedRoute} from '@angular/router'; -import {EgNetService} from '@eg/core/net'; -import {EgAuthService} from '@eg/core/auth'; - -@Component({ - templateUrl: 'app.component.html' -}) - -export class EgBcSearchComponent implements OnInit { - - barcode: string = ''; - - constructor( - private route: ActivatedRoute, - private renderer: Renderer, - private net: EgNetService, - private auth: EgAuthService - ) {} - - ngOnInit() { - - this.renderer.selectRootElement('#barcode-search-input').focus(); - this.barcode = this.route.snapshot.paramMap.get('barcode'); - - if (this.barcode) { - this.findUser(); - } - } - - findUser(): void { - alert('Searching for user ' + this.barcode); - } -} - - diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/app.module.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/app.module.ts deleted file mode 100644 index bb5f6881fb..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/app.module.ts +++ /dev/null @@ -1,17 +0,0 @@ -import {NgModule} from '@angular/core'; -import {EgStaffCommonModule} from '@eg/staff/common.module'; -import {EgBcSearchRoutingModule} from './routing.module'; -import {EgBcSearchComponent} from './app.component'; - -@NgModule({ - declarations: [ - EgBcSearchComponent - ], - imports: [ - EgStaffCommonModule, - EgBcSearchRoutingModule, - ], -}) - -export class EgBcSearchModule {} - diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/bcsearch.component.html b/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/bcsearch.component.html new file mode 100644 index 0000000000..58d5c4c3d5 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/bcsearch.component.html @@ -0,0 +1,19 @@ + + + + +
+
+
+ Barcode: +
+ +
+ +
+
+
+ + diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts new file mode 100644 index 0000000000..35e9e85a78 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts @@ -0,0 +1,36 @@ +import {Component, OnInit, Renderer} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; +import {EgNetService} from '@eg/core/net'; +import {EgAuthService} from '@eg/core/auth'; + +@Component({ + templateUrl: 'bcsearch.component.html' +}) + +export class EgBcSearchComponent implements OnInit { + + barcode: string = ''; + + constructor( + private route: ActivatedRoute, + private renderer: Renderer, + private net: EgNetService, + private auth: EgAuthService + ) {} + + ngOnInit() { + + this.renderer.selectRootElement('#barcode-search-input').focus(); + this.barcode = this.route.snapshot.paramMap.get('barcode'); + + if (this.barcode) { + this.findUser(); + } + } + + findUser(): void { + alert('Searching for user ' + this.barcode); + } +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/bcsearch.module.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/bcsearch.module.ts new file mode 100644 index 0000000000..cbb97b54be --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/bcsearch.module.ts @@ -0,0 +1,17 @@ +import {NgModule} from '@angular/core'; +import {EgStaffCommonModule} from '@eg/staff/common.module'; +import {EgBcSearchRoutingModule} from './routing.module'; +import {EgBcSearchComponent} from './bcsearch.component'; + +@NgModule({ + declarations: [ + EgBcSearchComponent + ], + imports: [ + EgStaffCommonModule, + EgBcSearchRoutingModule, + ], +}) + +export class EgBcSearchModule {} + diff --git a/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/routing.module.ts index a8c5a040d7..82f8a8bfc2 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/patron/bcsearch/routing.module.ts @@ -1,6 +1,6 @@ import {NgModule} from '@angular/core'; import {RouterModule, Routes} from '@angular/router'; -import {EgBcSearchComponent} from './app.component'; +import {EgBcSearchComponent} from './bcsearch.component'; const routes: Routes = [ { path: '', diff --git a/Open-ILS/src/eg2/src/app/staff/circ/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/circ/routing.module.ts index a61417a923..969decd546 100644 --- a/Open-ILS/src/eg2/src/app/staff/circ/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/circ/routing.module.ts @@ -5,7 +5,7 @@ const routes: Routes = [ { path: 'patron', children: [{ path: 'bcsearch', - loadChildren: '@eg/staff/circ/patron/bcsearch/app.module#EgBcSearchModule' + loadChildren: '@eg/staff/circ/patron/bcsearch/bcsearch.module#EgBcSearchModule' }] } ]; diff --git a/Open-ILS/src/eg2/src/app/staff/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/routing.module.ts index a25baf9f23..49a04a35c7 100644 --- a/Open-ILS/src/eg2/src/app/staff/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/routing.module.ts @@ -1,7 +1,7 @@ import {NgModule} from '@angular/core'; import {RouterModule, Routes} from '@angular/router'; import {EgStaffResolver} from './resolver.service'; -import {EgStaffComponent} from './app.component'; +import {EgStaffComponent} from './staff.component'; import {EgStaffLoginComponent} from './login.component'; import {EgStaffSplashComponent} from './splash.component'; @@ -28,7 +28,7 @@ const routes: Routes = [{ loadChildren : '@eg/staff/circ/routing.module#EgCircRoutingModule' }, { path: 'catalog', - loadChildren : '@eg/staff/catalog/app.module#EgCatalogModule' + loadChildren : '@eg/staff/catalog/catalog.module#EgCatalogModule' }, { path: 'admin', loadChildren : '@eg/staff/admin/routing.module#EgAdminRoutingModule' diff --git a/Open-ILS/src/eg2/src/app/staff/staff.component.css b/Open-ILS/src/eg2/src/app/staff/staff.component.css new file mode 100644 index 0000000000..508d879b9b --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/staff.component.css @@ -0,0 +1,8 @@ +#staff-content-container { + width: 95%; + margin-top:56px; + padding-right: 10px; + padding-left: 10px; + margin-right: auto; + margin-left: auto; +} diff --git a/Open-ILS/src/eg2/src/app/staff/staff.component.html b/Open-ILS/src/eg2/src/app/staff/staff.component.html new file mode 100644 index 0000000000..7bd463a623 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/staff.component.html @@ -0,0 +1,8 @@ + + + +
+ + +
+ diff --git a/Open-ILS/src/eg2/src/app/staff/staff.component.ts b/Open-ILS/src/eg2/src/app/staff/staff.component.ts new file mode 100644 index 0000000000..864beab8eb --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/staff.component.ts @@ -0,0 +1,88 @@ +import {Component, OnInit, NgZone} from '@angular/core'; +import {Router, ActivatedRoute, NavigationEnd} from '@angular/router'; +import {EgAuthService, EgAuthWsState} from '@eg/core/auth'; +import {EgNetService} from '@eg/core/net'; + +@Component({ + templateUrl: 'staff.component.html', + styleUrls: ['staff.component.css'] +}) + +export class EgStaffComponent implements OnInit { + + readonly loginPath = '/staff/login'; + readonly wsAdminBasePath = '/staff/admin/workstation/workstations/'; + + constructor( + private router: Router, + private route: ActivatedRoute, + private zone: NgZone, + private net: EgNetService, + private auth: EgAuthService + ) {} + + ngOnInit() { + + console.debug('EgStaffComponent:ngOnInit()'); + + // Fires on all in-app router navigation, but not initial page load. + this.router.events.subscribe(routeEvent => { + if (routeEvent instanceof NavigationEnd) { + //console.debug(`EgStaffComponent routing to ${routeEvent.url}`); + this.basicAuthChecks(routeEvent.url); + } + }); + + // Redirect to the login page on any auth timeout events. + this.net.authExpired$.subscribe(expireEvent => { + + // If the expired authtoken was identified locally (i.e. + // in this browser tab) notify all tabs of imminent logout. + if (!expireEvent.viaExternal) this.auth.broadcastLogout(); + + console.debug('Auth session has expired. Redirecting to login'); + this.auth.redirectUrl = this.router.url; + + // https://github.com/angular/angular/issues/18254 + // When a tab redirects to a login page as a result of + // another tab broadcasting a logout, ngOnInit() fails to + // fire in the login component, until the user interacts + // with the page. Fix it by wrapping it in zone.run(). + // This is the only navigate() where I have seen this happen. + this.zone.run(() => { + this.router.navigate([this.loginPath]); + }); + }); + + this.route.data.subscribe((data: {staffResolver : any}) => { + // Data fetched via EgStaffResolver is available here. + }); + } + + /** + * Verifying the auth token on every route is overkill, since + * an expired token will make itself known with the first API + * call or when the auth session poll discovers it, but we do + * want to prevent navigation from the login or workstation admin + * page, since these can be accessed without a valid authtoken or + * workstation, respectively, once the initial route resolvers have + * done their jobs. + */ + basicAuthChecks(url: string): void { + + // Access to login page is always granted + if (url == this.loginPath) return; + + if (!this.auth.token()) + this.router.navigate([this.loginPath]); + + // Access to workstation admin page is granted regardless + // of workstation validity. + if (url.indexOf(this.wsAdminBasePath) >= 0) return; + + if (this.auth.workstationState != EgAuthWsState.VALID) + this.router.navigate([this.wsAdminBasePath]); + } +} + + diff --git a/Open-ILS/src/eg2/src/app/staff/staff.module.ts b/Open-ILS/src/eg2/src/app/staff/staff.module.ts new file mode 100644 index 0000000000..52f6abdd31 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/staff.module.ts @@ -0,0 +1,24 @@ +import {NgModule} from '@angular/core'; +import {EgStaffCommonModule} from '@eg/staff/common.module'; + +import {EgStaffComponent} from './staff.component'; +import {EgStaffRoutingModule} from './routing.module'; +import {EgStaffNavComponent} from './nav.component'; +import {EgStaffLoginComponent} from './login.component'; +import {EgStaffSplashComponent} from './splash.component'; + +@NgModule({ + declarations: [ + EgStaffComponent, + EgStaffNavComponent, + EgStaffSplashComponent, + EgStaffLoginComponent + ], + imports: [ + EgStaffCommonModule.forRoot(), + EgStaffRoutingModule + ] +}) + +export class EgStaffModule {} + diff --git a/Open-ILS/src/eg2/src/app/welcome.component.html b/Open-ILS/src/eg2/src/app/welcome.component.html index 3ce97cc247..eaa1c71896 100644 --- a/Open-ILS/src/eg2/src/app/welcome.component.html +++ b/Open-ILS/src/eg2/src/app/welcome.component.html @@ -5,7 +5,7 @@


- But maybe you meant to go to the staff page - or the catalog. + But maybe you meant to go to the + staff page