From 565223aab576af3284e60b6195eeb09bbba880be Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sun, 9 Jun 2019 19:18:46 -0400 Subject: [PATCH] LP#1832897: add administrative interfaces for carousels This patch adds three Angular administration interfaces: (Server Admin) Carousel Types (Local Admin) Carousel Library Mappings (Local Admin) Carousels Signed-off-by: Galen Charlton Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg --- .../admin/local/admin-carousel.component.html | 98 +++++++++++++ .../admin/local/admin-carousel.component.ts | 130 ++++++++++++++++++ .../local/admin-local-splash.component.html | 4 + .../staff/admin/local/admin-local.module.ts | 4 +- .../app/staff/admin/local/routing.module.ts | 4 + .../server/admin-server-splash.component.html | 2 + 6 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/admin-carousel.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/admin/local/admin-carousel.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/admin-carousel.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-carousel.component.html new file mode 100644 index 0000000000..6c3e7834d1 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-carousel.component.html @@ -0,0 +1,98 @@ + + + + + +{{idlClassDef.label}} Update Succeeded + + +Update of {{idlClassDef.label}} failed + + +Delete of carousel faiiled or was not allowed + + +Carousel Successfully Deleted + + +{{idlClassDef.label}} Succeessfully Created + + +Failed to create new {{idlClassDef.label}} + + +{{name}} is being refreshed. It may take a couple minutes. + + +{{name}} is manual and cannot be refreshed automatically. + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + Link to bucket + (Note: changes to bucket contents may be overwritten by the next carousel update.) + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/admin-carousel.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-carousel.component.ts new file mode 100644 index 0000000000..bfbd4204a5 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-carousel.component.ts @@ -0,0 +1,130 @@ +import {Component, Input, ViewChild, OnInit} from '@angular/core'; +import {AdminPageComponent} from '@eg/staff/share/admin-page/admin-page.component'; +import {ActivatedRoute} from '@angular/router'; +import {IdlService, IdlObject} from '@eg/core/idl.service'; +import {ToastService} from '@eg/share/toast/toast.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {OrgService} from '@eg/core/org.service'; +import {PermService} from '@eg/core/perm.service'; +import {AuthService} from '@eg/core/auth.service'; +import {NetService} from '@eg/core/net.service'; +import {StringComponent} from '@eg/share/string/string.component'; + +@Component({ + templateUrl: './admin-carousel.component.html' +}) + +export class AdminCarouselComponent extends AdminPageComponent implements OnInit { + + idlClass = 'cc'; + classLabel: string; + + refreshSelected: (idlThings: IdlObject[]) => void; + createNew: () => void; + deleteSelected: (idlThings: IdlObject[]) => void; + + @ViewChild('refreshString') refreshString: StringComponent; + @ViewChild('refreshErrString') refreshErrString: StringComponent; + + constructor( + route: ActivatedRoute, + idl: IdlService, + org: OrgService, + auth: AuthService, + pcrud: PcrudService, + perm: PermService, + toast: ToastService, + private net: NetService + ) { + super(route, idl, org, auth, pcrud, perm, toast); + } + + ngOnInit() { + super.ngOnInit(); + + this.classLabel = this.idlClassDef.label; + this.includeOrgDescendants = true; + + + this.createNew = () => { + super.createNew(); + }; + + this.deleteSelected = (idlThings: IdlObject[]) => { + super.deleteSelected(idlThings); + }; + + this.refreshSelected = (idlThings: IdlObject[]) => { + idlThings.forEach(cc => { + if (cc.type().automatic() === 't') { + this.net.request( + 'open-ils.actor', + 'open-ils.actor.carousel.refresh', + this.auth.token(), cc.id() + ).toPromise(); // fire and forget, as this could take a couple minutes + this.refreshString.current({ name: cc.name() }).then(str => this.toast.success(str)); + } else { + this.refreshErrString.current({ name: cc.name() }).then(str => this.toast.warning(str)); + } + }); + }; + } + + mungeCarousel(editMode: string, rec: IdlObject) { + if (editMode === 'create') { + rec.creator(this.auth.user().id()); + } + rec.editor(this.auth.user().id()); + rec.edit_time('now'); + + // convert empty string to nulls as needed + // for int[] columns + if (rec.owning_lib_filter() === '') { + rec.owning_lib_filter(null); + } + if (rec.copy_location_filter() === '') { + rec.copy_location_filter(null); + } + } + + postSave(rec: IdlObject) { + if (rec._isfieldmapper) { + // if we got an actual IdlObject back, the + // record had just been created, not just + // edited. therefore, we probably need + if (rec.bucket() == null) { + const bucket = this.idl.create('cbreb'); + bucket.owner(this.auth.user().id()); + bucket.name('System-generated bucket for carousel: ' + rec.id()); // FIXME I18N + bucket.btype('carousel'); + bucket.pub('t'); + bucket.owning_lib(rec.owner()); + rec.bucket(bucket); + this.net.request( + 'open-ils.actor', + 'open-ils.actor.container.create', + this.auth.token(), 'biblio', bucket + ).toPromise().then( + newBucket => { + const ccou = this.idl.create('ccou'); + ccou.carousel(rec.id()); + ccou.org_unit(rec.owner()); + ccou.seq(0); + rec.bucket(newBucket); + this.pcrud.create(ccou).subscribe( + ok => { + this.pcrud.update(rec).subscribe( + ok2 => console.debug('updated'), + err => console.error(err), + () => { this.grid.reload(); } + ); + }, + err => console.error(err), + () => { this.grid.reload(); } + ); + } + ); + } + } + } +} diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html index edbb68f7ed..2ec554d11a 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/admin-local-splash.component.html @@ -11,6 +11,10 @@ url="/eg/staff/admin/local/config/auto_print"> + + +