From: Bill Erickson Date: Tue, 3 Jul 2018 21:38:41 +0000 (-0400) Subject: LP#1779158 Ang vandelay queue view cont. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=da40d0245351af66f1a5ff3e52b36fba66a8f767;p=working%2FEvergreen.git LP#1779158 Ang vandelay queue view cont. Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html index 974a319d05..033065231e 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/import.component.html @@ -168,7 +168,8 @@
+ routerLink="/staff/cat/vandelay/queue/{{recordType}}/{{activeQueueId}}" + i18n>Go To Queue
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 7b74fa2573..a8066520b4 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,11 +1,50 @@ - - - View MARC - - - - - - - - +
+ show queue selector +
+ +
+ + + + View MARC + + + + + Matches + + + + + {{row.import_error}} + + + + + + + + + + + + + + + + + + + +
+ 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 8167ebd729..57d3607121 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,9 +1,13 @@ 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 {GridComponent} from '@eg/share/grid/grid.component'; -import {GridDataSource} from '@eg/share/grid/grid'; +import {GridDataSource, GridColumn} from '@eg/share/grid/grid'; +import {VandelayService} from './vandelay.service'; @Component({ templateUrl: 'queue.component.html' @@ -11,33 +15,93 @@ import {GridDataSource} from '@eg/share/grid/grid'; export class QueueComponent implements OnInit { queueId: number; + queueType: string; // bib / auth / bib-acq queueSource: GridDataSource; + queuedRecClass: string; + + // keep a local copy for convenience + attrDefs: IdlObject[]; + @ViewChild('queueGrid') queueGrid: GridComponent; constructor( private router: Router, - private route: ActivatedRoute) { + private route: ActivatedRoute, + private vandelay: VandelayService) { this.route.paramMap.subscribe((params: ParamMap) => { + this.queueType = params.get('qtype'); this.queueId = +params.get('id'); - if (this.queueId) { - this.loadQueue(); - } }); this.queueSource = new GridDataSource(); - this.queueSource.getRows = - (pager: Pager, sort: any[]): Observable => { - return Observable.of([{id:1}]); + + // queue API does not support sorting + this.queueSource.getRows = (pager: Pager) => { + return this.loadQueue(pager); } } ngOnInit() { + if (this.queueType) { this.applyQueueType(); } } - loadQueue() { + applyQueueType() { + this.queuedRecClass = this.queueType.match(/bib/) ? 'vqbr' : 'vqar'; + this.vandelay.getAttrDefs(this.queueType).then( + attrs => { + this.attrDefs = attrs; + // Add grid columns for record attributes + attrs.forEach(attr => { + const col = new GridColumn(); + col.name = attr.code(), + col.label = attr.description(), + col.datatype = 'string'; + this.queueGrid.context.columnSet.add(col); + }); + + // Reapply the grid configuration now that we've + // dynamically added columns. + this.queueGrid.context.applyColumnsConfig(); + } + ); } + loadQueue(pager?: Pager): Observable { + + if (!(this.queueId && this.queueType)) { + return Observable.of(); + } + + const options = { + clear_marc: true, + offset: pager.offset, + limit: pager.limit, + flesh_import_items: true + } + + return this.vandelay.getQueuedRecords( + this.queueId, this.queueType, options) + .pipe(map(rec => { + + const recHash: any = { + id: rec.id(), + import_error: rec.import_error(), + import_time: rec.import_time(), + imported_as: rec.imported_as() + }; + + // Link the record attribute values to the root record + // object so the grid can find them. + rec.attributes().forEach(attr => { + const def = + this.attrDefs.filter(d => d.id() === attr.field())[0]; + recHash[def.code()] = attr.attr_value(); + }); + + return recHash; + })); + } } 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 419a03fab6..0275b37cb3 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 @@ -22,7 +22,7 @@ const routes: Routes = [{ path: 'queue', component: QueueComponent }, { - path: 'queue/:id', + path: 'queue/:qtype/:id', component: QueueComponent }] }]; diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.service.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.service.ts index d31eaa1f1d..5bd16d2582 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.service.ts @@ -214,5 +214,15 @@ export class VandelayService { }); }); } + + getQueuedRecords(queueId: number, + queueType: string, options?: any): Observable { + + const method = + `open-ils.vandelay.${queueType}_queue.records.retrieve`; + + return this.net.request('open-ils.vandelay', + method, this.auth.token(), queueId, options); + } }