From: Bill Erickson Date: Thu, 30 Nov 2017 22:14:27 +0000 (-0500) Subject: LP#626157 Ang2 experiments X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=2e55dea94593c8da85e65b7195a1425a442b5668;p=working%2FEvergreen.git LP#626157 Ang2 experiments Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/webby-src/src/app/core/auth.ts b/Open-ILS/webby-src/src/app/core/auth.ts index 6d94d80169..07668fa48e 100644 --- a/Open-ILS/webby-src/src/app/core/auth.ts +++ b/Open-ILS/webby-src/src/app/core/auth.ts @@ -54,8 +54,8 @@ export class EgAuthService { constructor( private egEvt: EgEventService, - private egNet: EgNetService, - private egStore: EgStoreService + private net: EgNetService, + private store: EgStoreService ) {} // - Accessor functions alway refer to the active user. @@ -81,14 +81,14 @@ export class EgAuthService { testAuthToken(): Promise { this.activeUser = new EgAuthUser( - this.egStore.getLoginSessionItem('eg.auth.token'), - this.egStore.getLoginSessionItem('eg.auth.time') + this.store.getLoginSessionItem('eg.auth.token'), + this.store.getLoginSessionItem('eg.auth.time') ); if (!this.token()) return Promise.reject('no authtoken'); return new Promise( (resolve, reject) => { - this.egNet.request( + this.net.request( 'open-ils.auth', 'open-ils.auth.session.retrieve', this.token() ).subscribe( @@ -112,7 +112,7 @@ export class EgAuthService { login(args: EgAuthLoginArgs, isOpChange?: boolean): Promise { return new Promise((resolve, reject) => { - this.egNet.request('open-ils.auth', 'open-ils.auth.login', args) + this.net.request('open-ils.auth', 'open-ils.auth.login', args) .subscribe(res => { this.handleLoginResponse(args, this.egEvt.parse(res), isOpChange) .then( @@ -147,8 +147,8 @@ export class EgAuthService { handleLoginOk(args: EgAuthLoginArgs, evt: EgEvent, isOpChange: boolean): void { if (isOpChange) { - this.egStore.setLoginSessionItem('eg.auth.token.oc', this.token()); - this.egStore.setLoginSessionItem('eg.auth.time.oc', this.authtime()); + this.store.setLoginSessionItem('eg.auth.token.oc', this.token()); + this.store.setLoginSessionItem('eg.auth.time.oc', this.authtime()); this.opChangeUser = this.activeUser; } @@ -158,8 +158,8 @@ export class EgAuthService { args.workstation ); - this.egStore.setLoginSessionItem('eg.auth.token', this.token()); - this.egStore.setLoginSessionItem('eg.auth.time', this.authtime()); + this.store.setLoginSessionItem('eg.auth.token', this.token()); + this.store.setLoginSessionItem('eg.auth.time', this.authtime()); } undoOpChange(): Promise { @@ -167,10 +167,10 @@ export class EgAuthService { this.deleteSession(); this.activeUser = this.opChangeUser; this.opChangeUser = null; - this.egStore.removeLoginSessionItem('eg.auth.token.oc'); - this.egStore.removeLoginSessionItem('eg.auth.time.oc'); - this.egStore.setLoginSessionItem('eg.auth.token', this.token()); - this.egStore.setLoginSessionItem('eg.auth.time', this.authtime()); + this.store.removeLoginSessionItem('eg.auth.token.oc'); + this.store.removeLoginSessionItem('eg.auth.time.oc'); + this.store.setLoginSessionItem('eg.auth.token', this.token()); + this.store.setLoginSessionItem('eg.auth.time', this.authtime()); } return this.testAuthToken(); } @@ -196,7 +196,7 @@ export class EgAuthService { return; } - this.egStore.getItem('eg.workstation.all') + this.store.getItem('eg.workstation.all') .then(workstations => { if (!workstations) workstations = []; @@ -217,7 +217,7 @@ export class EgAuthService { deleteSession(): void { if (this.token()) { - this.egNet.request( + this.net.request( 'open-ils.auth', 'open-ils.auth.session.delete', this.token()) .subscribe(x => console.log('logged out')) @@ -232,7 +232,7 @@ export class EgAuthService { } this.deleteSession(); - this.egStore.clearLoginSessionItems(); + this.store.clearLoginSessionItems(); this.activeUser = null; this.opChangeUser = null; } diff --git a/Open-ILS/webby-src/src/app/core/net.service.ts b/Open-ILS/webby-src/src/app/core/net.service.ts index 0d98d17222..b037de1840 100644 --- a/Open-ILS/webby-src/src/app/core/net.service.ts +++ b/Open-ILS/webby-src/src/app/core/net.service.ts @@ -1,6 +1,6 @@ /** * - * constructor(private egNet : EgNetService) { + * constructor(private net : EgNetService) { * ... * egNet.request(service, method, param1 [, param2, ...]) * .subscribe( diff --git a/Open-ILS/webby-src/src/app/core/org.ts b/Open-ILS/webby-src/src/app/core/org.ts index 460b1e35d1..cad7930e96 100644 --- a/Open-ILS/webby-src/src/app/core/org.ts +++ b/Open-ILS/webby-src/src/app/core/org.ts @@ -13,7 +13,7 @@ export class EgOrgService { private orgTree: EgIdlObject; // root node + children constructor( - private egPcrud: EgPcrudService + private pcrud: EgPcrudService ) {} get(nodeOrId: EgOrgNodeOrId): EgIdlObject { @@ -116,7 +116,7 @@ export class EgOrgService { fetchOrgs(): Promise { console.log('fetching..'); - return this.egPcrud.search('aou', {parent_ou : null}, + return this.pcrud.search('aou', {parent_ou : null}, {flesh : -1, flesh_fields : {aou : ['children', 'ou_type']}}, {anonymous : true} ).toPromise().then(tree => { diff --git a/Open-ILS/webby-src/src/app/core/pcrud.ts b/Open-ILS/webby-src/src/app/core/pcrud.ts index 42a93ef9fb..b6185cbed2 100644 --- a/Open-ILS/webby-src/src/app/core/pcrud.ts +++ b/Open-ILS/webby-src/src/app/core/pcrud.ts @@ -32,9 +32,9 @@ export class EgPcrudContext { private cudLast: EgPcrudResponse; private cudList: EgIdlObject[]; - private egIdl: EgIdlService; - private egNet: EgNetService; - private egAuth: EgAuthService; + private idl: EgIdlService; + private net: EgNetService; + private auth: EgAuthService; // Tracks nested CUD actions cudObserver: Observer; @@ -46,9 +46,9 @@ export class EgPcrudContext { egNet: EgNetService, egAuth: EgAuthService ) { - this.egIdl = egIdl; - this.egNet = egNet; - this.egAuth = egAuth; + this.idl = egIdl; + this.net = egNet; + this.auth = egAuth; this.xactCloseMode = 'rollback'; this.ident = EgPcrudContext.identGenerator++; this.session = new OpenSRF.ClientSession('open-ils.pcrud'); @@ -69,7 +69,7 @@ export class EgPcrudContext { token(reqOps?: EgPcrudReqOps): string { return (reqOps && reqOps.anonymous) ? - 'ANONYMOUS' : this.egAuth.token(); + 'ANONYMOUS' : this.auth.token(); } connect(): Promise { @@ -98,7 +98,7 @@ export class EgPcrudContext { retrieveAll(fmClass: string, pcrudOps?: any, reqOps?: EgPcrudReqOps): Observable { let search = {}; - search[this.egIdl.classes[fmClass].pkey] = {'!=' : null}; + search[this.idl.classes[fmClass].pkey] = {'!=' : null}; return this.search(fmClass, search, pcrudOps, reqOps); } @@ -192,7 +192,7 @@ export class EgPcrudContext { this.log(`sendRequest(${method})`); - return this.egNet.requestCompiled( + return this.net.requestCompiled( new EgNetRequest( 'open-ils.pcrud', method, params, this.session) ); @@ -261,9 +261,9 @@ export class EgPcrudContext { export class EgPcrudService { constructor( - private egIdl: EgIdlService, - private egNet: EgNetService, - private egAuth: EgAuthService + private idl: EgIdlService, + private net: EgNetService, + private auth: EgAuthService ) {} // Pass-thru functions for one-off PCRUD calls @@ -273,7 +273,7 @@ export class EgPcrudService { } newContext(): EgPcrudContext { - return new EgPcrudContext(this.egIdl, this.egNet, this.egAuth); + return new EgPcrudContext(this.idl, this.net, this.auth); } retrieve(fmClass: string, pkey: Number | string, diff --git a/Open-ILS/webby-src/src/app/resolver.service.ts b/Open-ILS/webby-src/src/app/resolver.service.ts index c63b2d5ed6..b699fcece5 100644 --- a/Open-ILS/webby-src/src/app/resolver.service.ts +++ b/Open-ILS/webby-src/src/app/resolver.service.ts @@ -9,8 +9,8 @@ export class EgBaseResolver implements Resolve> { constructor( private router: Router, - private egIdl: EgIdlService, - private egOrg: EgOrgService, + private idl: EgIdlService, + private org: EgOrgService, ) {} resolve( @@ -20,9 +20,9 @@ export class EgBaseResolver implements Resolve> { console.debug('EgBaseResolver:resolve()'); // Safe to assume some data is needed by all applications. - this.egIdl.parseIdl(); + this.idl.parseIdl(); - return this.egOrg.fetchOrgs(); + return this.org.fetchOrgs(); // load other common stuff... } } 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 456e2c2d5e..8508e2b5c0 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 @@ -27,7 +27,7 @@ export class EgWorkstationsComponent implements OnInit { // Org selector callbacks shouldDisableOrg = (org: EgIdlObject): boolean => { // TODO: check register perms too - return !this.egOrg.canHaveUsers(org); + return !this.org.canHaveUsers(org); } shouldHideOrg = (org: EgIdlObject): boolean => { @@ -36,22 +36,20 @@ export class EgWorkstationsComponent implements OnInit { orgOnChange = (org: EgIdlObject): void => { console.log('org changed to ' + org.shortname()); + this.newOwner = org; } - constructor( private route: ActivatedRoute, - private egNet: EgNetService, - private egAuth: EgAuthService, - private egStore: EgStoreService, - private egOrg: EgOrgService + private net: EgNetService, + private store: EgStoreService, + private auth: EgAuthService, + private org: EgOrgService ) {} ngOnInit() { - this.egStore.getItem('eg.workstation.all') + this.store.getItem('eg.workstation.all') .then(res => this.workstations = res); - - this.newOwner = this.egOrg.root(); } selected(): Workstation { diff --git a/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts b/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts index 3b2cfe1695..3cc225e92b 100644 --- a/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts +++ b/Open-ILS/webby-src/src/app/staff/circ/patron/bcsearch/bcsearch.component.ts @@ -14,8 +14,8 @@ export class EgBcSearchComponent implements OnInit { constructor( private route: ActivatedRoute, - private egNet: EgNetService, - private egAuth: EgAuthService + private net: EgNetService, + private auth: EgAuthService ) {} ngOnInit() { @@ -30,7 +30,7 @@ export class EgBcSearchComponent implements OnInit { console.debug('EgBcSearch ngOnInit complete'); }); - this.egNet.request( + this.net.request( 'open-ils.actor', 'opensrf.system.echo', 'hello', 'goodbye', 'in the middle' 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 3dd94940aa..7ec46237b6 100644 --- a/Open-ILS/webby-src/src/app/staff/login.component.ts +++ b/Open-ILS/webby-src/src/app/staff/login.component.ts @@ -24,14 +24,14 @@ export class EgStaffLoginComponent implements OnInit { private router: Router, private ngLocation: Location, private renderer: Renderer, - private egAuth: EgAuthService, - private egStore: EgStoreService + private auth: EgAuthService, + private store: EgStoreService ) {} ngOnInit() { // clear out any stale auth data - this.egAuth.logout(); + this.auth.logout(); // Focus username this.renderer.selectRootElement('#username').focus(); @@ -39,7 +39,7 @@ export class EgStaffLoginComponent implements OnInit { // load browser-local workstation data // TODO: insert for testing. - this.egStore.setItem( + this.store.setItem( 'eg.workstation.all', [{name:'BR1-skiddoo',id:1,owning_lib:4}] ); @@ -48,13 +48,13 @@ export class EgStaffLoginComponent implements OnInit { handleSubmit() { // post-login URL - let url: string = this.egAuth.redirectUrl || '/staff/splash'; + let url: string = this.auth.redirectUrl || '/staff/splash'; - this.egAuth.login(this.args).then( + this.auth.login(this.args).then( ok => { - this.egAuth.redirectUrl = null; + this.auth.redirectUrl = null; - if (this.egAuth.workstationState == EgAuthWsState.NOT_FOUND_SERVER) { + if (this.auth.workstationState == EgAuthWsState.NOT_FOUND_SERVER) { // User is logged in without a workstation. // Redirect them to the WS admin page. this.router.navigate( 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 21eddec7ce..4c7fdf51a0 100644 --- a/Open-ILS/webby-src/src/app/staff/resolver.service.ts +++ b/Open-ILS/webby-src/src/app/staff/resolver.service.ts @@ -21,9 +21,9 @@ export class EgStaffResolver implements Resolve> { constructor( private router: Router, private ngLocation: Location, - private egStore: EgStoreService, - private egNet: EgNetService, - private egAuth: EgAuthService + private store: EgStoreService, + private net: EgNetService, + private auth: EgAuthService ) {} resolve( @@ -33,16 +33,16 @@ export class EgStaffResolver implements Resolve> { console.debug('EgStaffResolver:resolve()'); // Staff cookies stay in /$base/staff/ - this.egStore.loginSessionBasePath = + this.store.loginSessionBasePath = this.ngLocation.prepareExternalUrl('/staff'); // Login resets everything. No need to load data. if (state.url == '/staff/login') return Observable.of(true); return Observable.create(observer => { - this.egAuth.testAuthToken().then( + this.auth.testAuthToken().then( tokenOk => { - this.egAuth.verifyWorkstation().then( + this.auth.verifyWorkstation().then( wsOk => { this.loadStartupData(observer).then( ok => observer.complete() @@ -58,7 +58,7 @@ export class EgStaffResolver implements Resolve> { }, tokenNotOk => { // Authtoken is not OK. - this.egAuth.redirectUrl = state.url; + this.auth.redirectUrl = state.url; this.router.navigate([this.loginPath]); observer.complete(); } diff --git a/Open-ILS/webby-src/src/app/staff/share/org-select.component.ts b/Open-ILS/webby-src/src/app/staff/share/org-select.component.ts index ee1fa5fcc5..d5a361af10 100644 --- a/Open-ILS/webby-src/src/app/staff/share/org-select.component.ts +++ b/Open-ILS/webby-src/src/app/staff/share/org-select.component.ts @@ -39,9 +39,9 @@ export class EgOrgSelectComponent implements OnInit { @Input() shouldHide: (org:EgIdlObject) => boolean; constructor( - private egAuth: EgAuthService, - private egStore: EgStoreService, - private egOrg: EgOrgService + private auth: EgAuthService, + private store: EgStoreService, + private org: EgOrgService ) {} ngOnInit() { @@ -49,7 +49,7 @@ export class EgOrgSelectComponent implements OnInit { orgChanged(selEvent: NgbTypeaheadSelectItemEvent) { if (this.onChange) { - this.onChange(this.egOrg.get(selEvent.item.id)); + this.onChange(this.org.get(selEvent.item.id)); } } @@ -63,7 +63,7 @@ export class EgOrgSelectComponent implements OnInit { .map(term => { // TODO: displayField / shortname - return this.egOrg.list().filter(org => { + return this.org.list().filter(org => { // Find orgs matching the search term return org.shortname() diff --git a/Open-ILS/webby-src/src/app/staff/staff.component.ts b/Open-ILS/webby-src/src/app/staff/staff.component.ts index 836a92bbd1..572e44e201 100644 --- a/Open-ILS/webby-src/src/app/staff/staff.component.ts +++ b/Open-ILS/webby-src/src/app/staff/staff.component.ts @@ -15,8 +15,8 @@ export class EgStaffComponent implements OnInit { constructor( private router: Router, private route: ActivatedRoute, - private egNet: EgNetService, - private egAuth: EgAuthService + private net: EgNetService, + private auth: EgAuthService ) {} ngOnInit() { @@ -30,9 +30,9 @@ export class EgStaffComponent implements OnInit { }); // Redirect to the login page on any auth timeout events. - this.egNet.authExpired$.subscribe(uhOh => { + this.net.authExpired$.subscribe(uhOh => { console.log('Auth session has expired. Send to login'); - this.egAuth.redirectUrl = this.router.url; + this.auth.redirectUrl = this.router.url; this.router.navigate(['/staff/login']); }); @@ -55,14 +55,14 @@ export class EgStaffComponent implements OnInit { // Access to login page is always granted if (routeEvent.url == this.loginPath) return; - if (!this.egAuth.token()) + if (!this.auth.token()) this.router.navigate([this.loginPath]); // Access to workstation admin page is granted regardless // of workstation validity. if (routeEvent.url == this.wsAdminPath) return; - if (this.egAuth.workstationState != EgAuthWsState.VALID) + if (this.auth.workstationState != EgAuthWsState.VALID) this.router.navigate([this.wsAdminPath]); } }