constructor(
private egEvt: EgEventService,
- private egNet: EgNetService,
- private egStore: EgStoreService
+ private net: EgNetService,
+ private store: EgStoreService
) {}
// - Accessor functions alway refer to the active user.
testAuthToken(): Promise<any> {
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<any>( (resolve, reject) => {
- this.egNet.request(
+ this.net.request(
'open-ils.auth',
'open-ils.auth.session.retrieve', this.token()
).subscribe(
login(args: EgAuthLoginArgs, isOpChange?: boolean): Promise<void> {
return new Promise<void>((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(
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;
}
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<any> {
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();
}
return;
}
- this.egStore.getItem('eg.workstation.all')
+ this.store.getItem('eg.workstation.all')
.then(workstations => {
if (!workstations) workstations = [];
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'))
}
this.deleteSession();
- this.egStore.clearLoginSessionItems();
+ this.store.clearLoginSessionItems();
this.activeUser = null;
this.opChangeUser = null;
}
/**
*
- * constructor(private egNet : EgNetService) {
+ * constructor(private net : EgNetService) {
* ...
* egNet.request(service, method, param1 [, param2, ...])
* .subscribe(
private orgTree: EgIdlObject; // root node + children
constructor(
- private egPcrud: EgPcrudService
+ private pcrud: EgPcrudService
) {}
get(nodeOrId: EgOrgNodeOrId): EgIdlObject {
fetchOrgs(): Promise<void> {
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 => {
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<EgPcrudResponse>;
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');
token(reqOps?: EgPcrudReqOps): string {
return (reqOps && reqOps.anonymous) ?
- 'ANONYMOUS' : this.egAuth.token();
+ 'ANONYMOUS' : this.auth.token();
}
connect(): Promise<EgPcrudContext> {
retrieveAll(fmClass: string, pcrudOps?: any,
reqOps?: EgPcrudReqOps): Observable<EgPcrudResponse> {
let search = {};
- search[this.egIdl.classes[fmClass].pkey] = {'!=' : null};
+ search[this.idl.classes[fmClass].pkey] = {'!=' : null};
return this.search(fmClass, search, pcrudOps, reqOps);
}
this.log(`sendRequest(${method})`);
- return this.egNet.requestCompiled(
+ return this.net.requestCompiled(
new EgNetRequest(
'open-ils.pcrud', method, params, this.session)
);
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
}
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,
constructor(
private router: Router,
- private egIdl: EgIdlService,
- private egOrg: EgOrgService,
+ private idl: EgIdlService,
+ private org: EgOrgService,
) {}
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...
}
}
// 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 => {
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 {
constructor(
private route: ActivatedRoute,
- private egNet: EgNetService,
- private egAuth: EgAuthService
+ private net: EgNetService,
+ private auth: EgAuthService
) {}
ngOnInit() {
console.debug('EgBcSearch ngOnInit complete');
});
- this.egNet.request(
+ this.net.request(
'open-ils.actor',
'opensrf.system.echo',
'hello', 'goodbye', 'in the middle'
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();
// 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}]
);
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(
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(
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()
},
tokenNotOk => {
// Authtoken is not OK.
- this.egAuth.redirectUrl = state.url;
+ this.auth.redirectUrl = state.url;
this.router.navigate([this.loginPath]);
observer.complete();
}
@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() {
orgChanged(selEvent: NgbTypeaheadSelectItemEvent) {
if (this.onChange) {
- this.onChange(this.egOrg.get(selEvent.item.id));
+ this.onChange(this.org.get(selEvent.item.id));
}
}
.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()
constructor(
private router: Router,
private route: ActivatedRoute,
- private egNet: EgNetService,
- private egAuth: EgAuthService
+ private net: EgNetService,
+ private auth: EgAuthService
) {}
ngOnInit() {
});
// 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']);
});
// 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]);
}
}