From 2409e726f671eff810efa59a3855c569701dedd0 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 10 Jul 2018 17:25:14 -0400 Subject: [PATCH] LP#1779158 Que rec matches; queue select shows all Signed-off-by: Bill Erickson --- .../app/staff/cat/vandelay/import.component.html | 2 +- .../src/app/staff/cat/vandelay/import.component.ts | 9 +- .../staff/cat/vandelay/queue-record.component.html | 9 -- .../staff/cat/vandelay/queue-record.component.ts | 32 ------ .../app/staff/cat/vandelay/queue.component.html | 6 +- .../src/app/staff/cat/vandelay/queue.component.ts | 3 +- .../vandelay/queued-record-matches.component.html | 79 +++++++++++++++ .../vandelay/queued-record-matches.component.ts | 112 +++++++++++++++++++++ .../cat/vandelay/queued-record.component.html | 25 +++++ .../staff/cat/vandelay/queued-record.component.ts | 42 ++++++++ .../src/app/staff/cat/vandelay/routing.module.ts | 8 +- .../src/app/staff/cat/vandelay/vandelay.module.ts | 12 ++- .../src/app/staff/cat/vandelay/vandelay.service.ts | 28 +++++- 13 files changed, 308 insertions(+), 59 deletions(-) delete mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-record.component.html delete mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-record.component.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.ts create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record.component.ts 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 8b8d6da806..4f544b4722 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 @@ -34,7 +34,7 @@
- - - - - - - - diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-record.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-record.component.ts deleted file mode 100644 index abc12b8ce1..0000000000 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queue-record.component.ts +++ /dev/null @@ -1,32 +0,0 @@ -import {Component, OnInit, ViewChild} from '@angular/core'; -import {Router, ActivatedRoute, ParamMap} from '@angular/router'; - -@Component({ - /* - template: ` - - - ` - */ - templateUrl: 'queue-record.component.html' -}) -export class QueueRecordComponent { - - queueId: number; - queueType: string; - recordId: number; - recordTab: string; - - constructor( - private router: Router, - private route: ActivatedRoute) { - - this.route.paramMap.subscribe((params: ParamMap) => { - this.queueId = +params.get('id'); - this.recordId = +params.get('recordId'); - this.queueType = params.get('qtype'); - this.recordTab = params.get('recordType'); - }); - } -} - 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 0393355408..94ef0803f2 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 @@ -90,8 +90,10 @@ - - TODO + + ({{row.matches.length}}) + 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 d2ec377bb4..224be6d285 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 @@ -152,7 +152,8 @@ export class QueueComponent implements AfterViewInit { id: rec.id(), import_error: rec.import_error(), import_time: rec.import_time(), - imported_as: rec.imported_as() + imported_as: rec.imported_as(), + matches: rec.matches() }; // Link the record attribute values to the root record diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.html new file mode 100644 index 0000000000..4d8aee9cef --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.html @@ -0,0 +1,79 @@ + + + + View Catalog Record + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.ts new file mode 100644 index 0000000000..c20da4d569 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record-matches.component.ts @@ -0,0 +1,112 @@ +import {Component, Input, OnInit, ViewChild} from '@angular/core'; +import {Router, ActivatedRoute, ParamMap} from '@angular/router'; +import {Observable} from 'rxjs/Observable'; +import 'rxjs/add/observable/of'; +import {map} from 'rxjs/operators/map'; +import {Pager} from '@eg/share/util/pager'; +import {GridComponent} from '@eg/share/grid/grid.component'; +import {GridDataSource, GridColumn} from '@eg/share/grid/grid'; +import {IdlObject} from '@eg/core/idl.service'; +import {EventService} from '@eg/core/event.service'; +import {NetService} from '@eg/core/net.service'; +import {AuthService} from '@eg/core/auth.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.service'; +import {VandelayService} from './vandelay.service'; + +@Component({ + selector: 'eg-queued-record-matches', + templateUrl: 'queued-record-matches.component.html' +}) +export class QueuedRecordMatchesComponent implements OnInit { + + @Input() queueType: string; + @Input() recordId: number; + @ViewChild('bibGrid') bibGrid: GridComponent; + @ViewChild('authGrid') authGrid: GridComponent; + + queuedRecord: IdlObject; + bibDataSource: GridDataSource; + authDataSource: GridDataSource; + + constructor( + private router: Router, + private route: ActivatedRoute, + private evt: EventService, + private net: NetService, + private auth: AuthService, + private pcrud: PcrudService, + private bib: BibRecordService, + private vandelay: VandelayService) { + + this.bibDataSource = new GridDataSource(); + this.authDataSource = new GridDataSource(); + + this.bibDataSource.getRows = (pager: Pager) => { + return this.getBibMatchRows(pager); + } + + /* TODO + this.authDataSource.getRows = (pager: Pager) => { + } + */ + } + + ngOnInit() {} + + // This thing is a nesty beast -- clean it up + getBibMatchRows(pager: Pager): Observable { + + return new Observable(observer => { + + this.getQueuedRecord().then(() => { + + const matches = this.queuedRecord.matches(); + const recIds = []; + matches.forEach(m => { + if (!recIds.includes(m.eg_record())) { + recIds.push(m.eg_record()); + } + }); + + const bibSummaries: {[id: number]: BibRecordSummary} = {}; + this.bib.getBibSummary(recIds).subscribe( + summary => bibSummaries[summary.id] = summary, + err => {}, + () => { + this.bib.fleshBibUsers( + Object.values(bibSummaries).map(sum => sum.record) + ).then(() => { + matches.forEach(match => { + const row = { + id: match.id(), + eg_record: match.eg_record(), + bre_quality: match.quality(), + vqbr_quality: this.queuedRecord.quality(), + match_score: match.match_score(), + bib_summary: bibSummaries[match.eg_record()] + } + + observer.next(row); + }); + + observer.complete(); + }); + } + ); + }); + }); + } + + getQueuedRecord(): Promise { + if (this.queuedRecord) { + return Promise.resolve(''); + } + let idlClass = this.queueType === 'bib' ? 'vqbr' : 'vqar'; + const flesh = {flesh: 1, flesh_fields: {}}; + flesh.flesh_fields[idlClass] = ['matches']; + return this.pcrud.retrieve(idlClass, this.recordId, flesh) + .toPromise().then(rec => this.queuedRecord = rec); + } +} + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record.component.html new file mode 100644 index 0000000000..31d88b105c --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record.component.html @@ -0,0 +1,25 @@ + +
+
+ +
+
+ + + + + + + + + + + + + + + diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record.component.ts new file mode 100644 index 0000000000..3a37be74c8 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record.component.ts @@ -0,0 +1,42 @@ +import {Component, OnInit, ViewChild} from '@angular/core'; +import {Router, ActivatedRoute, ParamMap} from '@angular/router'; +import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap'; + +@Component({ + templateUrl: 'queued-record.component.html' +}) +export class QueuedRecordComponent { + + queueId: number; + queueType: string; + recordId: number; + recordTab: string; + + constructor( + private router: Router, + private route: ActivatedRoute) { + + this.route.paramMap.subscribe((params: ParamMap) => { + this.queueId = +params.get('id'); + this.recordId = +params.get('recordId'); + this.queueType = params.get('qtype'); + this.recordTab = params.get('recordTab'); + }); + } + + // Changing a tab in the UI means changing the route. + // Changing the route ultimately results in changing the tab. + onTabChange(evt: NgbTabChangeEvent) { + this.recordTab = evt.nextId; + + // prevent tab changing until after route navigation + evt.preventDefault(); + + const url = + `/staff/cat/vandelay/queue/${this.queueType}/${this.queueId}` + + `/record/${this.recordId}/${this.recordTab}`; + + this.router.navigate([url]); + } +} + 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 2f23f987df..1c253bf3b1 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 @@ -3,9 +3,9 @@ import {RouterModule, Routes} from '@angular/router'; import {VandelayComponent} from './vandelay.component'; import {ImportComponent} from './import.component'; import {ExportComponent} from './export.component'; -import {QueueComponent} from './queue.component'; -import {QueueRecordComponent} from './queue-record.component'; import {QueueListComponent} from './queue-list.component'; +import {QueueComponent} from './queue.component'; +import {QueuedRecordComponent} from './queued-record.component'; const routes: Routes = [{ path: '', @@ -28,10 +28,10 @@ const routes: Routes = [{ component: QueueComponent }, { path: 'queue/:qtype/:id/record/:recordId', - component: QueueRecordComponent + component: QueuedRecordComponent }, { path: 'queue/:qtype/:id/record/:recordId/:recordTab', - component: QueueRecordComponent + component: QueuedRecordComponent }] }]; 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 dba5324e1e..6b3b4524d4 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 @@ -1,5 +1,8 @@ import {NgModule} from '@angular/core'; import {StaffCommonModule} from '@eg/staff/common.module'; +import {CatalogCommonModule} from '@eg/share/catalog/catalog-common.module'; +import {GridModule} from '@eg/share/grid/grid.module'; +import {HttpClientModule} from '@angular/common/http'; import {VandelayRoutingModule} from './routing.module'; import {VandelayService} from './vandelay.service'; import {VandelayComponent} from './vandelay.component'; @@ -7,9 +10,8 @@ import {ImportComponent} from './import.component'; import {ExportComponent} from './export.component'; import {QueueComponent} from './queue.component'; import {QueueListComponent} from './queue-list.component'; -import {QueueRecordComponent} from './queue-record.component'; -import {GridModule} from '@eg/share/grid/grid.module'; -import {HttpClientModule} from '@angular/common/http'; +import {QueuedRecordComponent} from './queued-record.component'; +import {QueuedRecordMatchesComponent} from './queued-record-matches.component'; @NgModule({ declarations: [ @@ -18,10 +20,12 @@ import {HttpClientModule} from '@angular/common/http'; ExportComponent, QueueComponent, QueueListComponent, - QueueRecordComponent + QueuedRecordComponent, + QueuedRecordMatchesComponent ], imports: [ StaffCommonModule, + CatalogCommonModule, VandelayRoutingModule, HttpClientModule, GridModule 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 41e3df617e..533b6c75b9 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 @@ -82,6 +82,27 @@ export class VandelayService { // Returns a promise resolved with the list of queues. // Also emits the onQueueListUpdate event so listeners // can detect queue content changes. + getAllQueues(qtype: string): Promise { + if (this.allQueues[qtype]) { + return Promise.resolve(this.allQueues[qtype]); + } else { + this.allQueues[qtype] = []; + } + + // could be a big list, invoke in streaming mode + return this.net.request( + 'open-ils.vandelay', + `open-ils.vandelay.${qtype}_queue.owner.retrieve`, + this.auth.token() + ).pipe(tap( + queue => this.allQueues[qtype].push(queue) + )).toPromise().then(() => this.allQueues[qtype]); + } + + + // Returns a promise resolved with the list of queues. + // Also emits the onQueueListUpdate event so listeners + // can detect queue content changes. getActiveQueues(qtype: string): Promise { if (this.activeQueues[qtype]) { return Promise.resolve(this.activeQueues[qtype]); @@ -128,6 +149,9 @@ export class VandelayService { // todo: differentiate between biblio and authority a la queue api getMatchSets(mtype: string): Promise { + + const mstype = mtype.match(/bib/) ? 'biblio' : 'authority'; + if (this.matchSets[mtype]) { return Promise.resolve(this.matchSets[mtype]); } else { @@ -137,7 +161,7 @@ export class VandelayService { const owners = this.org.ancestors(this.auth.user().ws_ou(), true); return this.pcrud.search('vms', - {owner: owners, mtype: mtype}, {}, {atomic: true}) + {owner: owners, mtype: mstype}, {}, {atomic: true}) .toPromise().then(sets => { this.matchSets[mtype] = sets; return sets; @@ -225,7 +249,7 @@ export class VandelayService { getQueuedRecords(queueId: number, queueType: string, options?: any, limitToMatches?: boolean): Observable { - const qtype = queueType === 'bib' ? 'bib' : 'auth'; + const qtype = queueType.match(/bib/) ? 'bib' : 'auth'; let method = `open-ils.vandelay.${qtype}_queue.records.retrieve`; -- 2.11.0