From: Bill Erickson Date: Thu, 5 Jul 2018 18:23:38 +0000 (-0400) Subject: LP#1779158 Ang vandelay queue list page X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=841cc6e5f0ff3f8eccd2d357e2f487325b77b790;p=working%2FEvergreen.git LP#1779158 Ang vandelay queue list page Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-list.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-list.component.html new file mode 100644 index 0000000000..b75e7a9ded --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-list.component.html @@ -0,0 +1,34 @@ +
+

Select a Queue To Inspect

+
+
+ +
+
+ + + + + +
+
+
+ + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-list.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-list.component.ts new file mode 100644 index 0000000000..84c73a3e39 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-list.component.ts @@ -0,0 +1,99 @@ +import {Component, OnInit, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/observable/of'; +import {map} from 'rxjs/operators/map'; +import {Router, ActivatedRoute, ParamMap} from '@angular/router'; +import {Pager} from '@eg/share/util/pager'; +import {IdlObject} from '@eg/core/idl.service'; +import {NetService} from '@eg/core/net.service'; +import {AuthService} from '@eg/core/auth.service'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {GridDataSource, GridColumn} from '@eg/share/grid/grid'; +import {VandelayService} from './vandelay.service'; + +@Component({ + templateUrl: 'queue-list.component.html' +}) +export class QueueListComponent { + + queueType: string; // bib / auth / bib-acq + queueSource: GridDataSource; + deleteSelected: (rows: IdlObject[]) => void; + + // points to the currently active grid. + queueGrid: GridComponent; + + @ViewChild('bibQueueGrid') bibQueueGrid: GridComponent; + @ViewChild('authQueueGrid') authQueueGrid: GridComponent; + + constructor( + private router: Router, + private route: ActivatedRoute, + private net: NetService, + private auth: AuthService, + private vandelay: VandelayService) { + + this.queueType = 'bib'; + this.queueSource = new GridDataSource(); + + // queue API does not support sorting + this.queueSource.getRows = (pager: Pager) => { + return this.loadQueues(pager); + } + + this.deleteSelected = (queues: IdlObject[]) => { + + // Serialize the deletes, especially if there are many of them + // because they can be bulky calls + const qtype = this.queueType; + const method = `open-ils.vandelay.${qtype}_queue.delete`; + + const deleteNext = (queues: IdlObject[], idx: number) => { + const queue = queues[idx]; + if (!queue) { + this.currentGrid().reload(); + return Promise.resolve(); + } + + return this.net.request('open-ils.vandelay', + method, this.auth.token(), queue.id() + ).toPromise().then(() => deleteNext(queues, ++idx)); + } + + deleteNext(queues, 0); + }; + } + + currentGrid(): GridComponent { + // The active grid changes along with the queue type. + // The inactive grid will be set to null. + return this.bibQueueGrid || this.authQueueGrid; + } + + rowActivated(queue) { + const url = `/staff/cat/vandelay/queue/${this.queueType}/${queue.id()}`; + this.router.navigate([url]); + } + + queueTypeChanged($event) { + this.queueType = $event.id; + this.queueSource.reset(); + } + + + loadQueues(pager: Pager): Observable { + + if (!this.queueType) { + return Observable.of(); + } + + const qtype = this.queueType.match(/bib/) ? 'bib' : 'authority'; + const method = `open-ils.vandelay.${qtype}_queue.owner.retrieve`; + + return this.net.request('open-ils.vandelay', + method, this.auth.token(), null, null, + {offset: pager.offset, limit: pager.limit} + ); + } +} + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.html index a8066520b4..ac3da87677 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.html @@ -1,23 +1,25 @@ -
- show queue selector -
+

Queue {{queueSummary ? queueSummary.queue.name() : ''}}

-
+ + + TODO + - - - View MARC - + + + TODO + - - - Matches - + + + {{row.import_error}} + - - - {{row.import_error}} - + + + {{row.imported_as}} + + - - - - - - - - - - - - - - - -
+ + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.ts index 57d3607121..8d257ad0bc 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue.component.ts @@ -1,10 +1,12 @@ -import {Component, OnInit, ViewChild} from '@angular/core'; +import {Component, OnInit, AfterViewInit, ViewChild} from '@angular/core'; import {Observable} from 'rxjs/Observable'; import 'rxjs/add/observable/of'; import {map} from 'rxjs/operators/map'; import {Router, ActivatedRoute, ParamMap} from '@angular/router'; import {Pager} from '@eg/share/util/pager'; import {IdlObject} from '@eg/core/idl.service'; +import {NetService} from '@eg/core/net.service'; +import {AuthService} from '@eg/core/auth.service'; import {GridComponent} from '@eg/share/grid/grid.component'; import {GridDataSource, GridColumn} from '@eg/share/grid/grid'; import {VandelayService} from './vandelay.service'; @@ -12,12 +14,13 @@ import {VandelayService} from './vandelay.service'; @Component({ templateUrl: 'queue.component.html' }) -export class QueueComponent implements OnInit { +export class QueueComponent implements AfterViewInit { queueId: number; queueType: string; // bib / auth / bib-acq queueSource: GridDataSource; queuedRecClass: string; + queueSummary: any; // keep a local copy for convenience attrDefs: IdlObject[]; @@ -27,6 +30,8 @@ export class QueueComponent implements OnInit { constructor( private router: Router, private route: ActivatedRoute, + private net: NetService, + private auth: AuthService, private vandelay: VandelayService) { this.route.paramMap.subscribe((params: ParamMap) => { @@ -38,13 +43,17 @@ export class QueueComponent implements OnInit { // queue API does not support sorting this.queueSource.getRows = (pager: Pager) => { - return this.loadQueue(pager); + return this.loadQueueRecords(pager); } - } - ngOnInit() { - if (this.queueType) { this.applyQueueType(); } + ngAfterViewInit() { + if (this.queueType) { + this.applyQueueType(); + if (this.queueId) { + this.loadQueueSummary(); + } + } } applyQueueType() { @@ -68,11 +77,16 @@ export class QueueComponent implements OnInit { ); } - loadQueue(pager?: Pager): Observable { + loadQueueSummary(): Promise { + const method = + `open-ils.vandelay.${this.queueType}_queue.summary.retrieve`; - if (!(this.queueId && this.queueType)) { - return Observable.of(); - } + return this.net.request( + 'open-ils.vandelay', method, this.auth.token(), this.queueId) + .toPromise().then(sum => this.queueSummary = sum); + } + + loadQueueRecords(pager: Pager): Observable { const options = { clear_marc: true, diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/routing.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/routing.module.ts index 0275b37cb3..4d085692b1 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/routing.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/routing.module.ts @@ -4,6 +4,7 @@ import {VandelayComponent} from './vandelay.component'; import {ImportComponent} from './import.component'; import {ExportComponent} from './export.component'; import {QueueComponent} from './queue.component'; +import {QueueListComponent} from './queue-list.component'; const routes: Routes = [{ path: '', @@ -20,7 +21,7 @@ const routes: Routes = [{ component: ExportComponent }, { path: 'queue', - component: QueueComponent + component: QueueListComponent }, { path: 'queue/:qtype/:id', component: QueueComponent diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts index 6babf9498d..bd8fecc66a 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts @@ -6,6 +6,7 @@ import {VandelayComponent} from './vandelay.component'; import {ImportComponent} from './import.component'; import {ExportComponent} from './export.component'; import {QueueComponent} from './queue.component'; +import {QueueListComponent} from './queue-list.component'; import {GridModule} from '@eg/share/grid/grid.module'; import {HttpClientModule} from '@angular/common/http'; @@ -14,7 +15,8 @@ import {HttpClientModule} from '@angular/common/http'; VandelayComponent, ImportComponent, ExportComponent, - QueueComponent + QueueComponent, + QueueListComponent ], imports: [ StaffCommonModule,