From 4da34bd4db9d937a4edccfa38514c002abcf5c4d Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 20 Sep 2018 17:50:07 -0400 Subject: [PATCH] LP#1779158 Initial support for displaying active imports Signed-off-by: Bill Erickson --- .../cat/vandelay/active-imports.component.html | 46 +++++++++++ .../staff/cat/vandelay/active-imports.component.ts | 92 ++++++++++++++++++++++ .../src/app/staff/cat/vandelay/routing.module.ts | 4 + .../app/staff/cat/vandelay/vandelay.component.html | 5 ++ .../src/app/staff/cat/vandelay/vandelay.module.ts | 4 +- 5 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/active-imports.component.html create mode 100644 Open-ILS/src/eg2/src/app/staff/cat/vandelay/active-imports.component.ts diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/active-imports.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/active-imports.component.html new file mode 100644 index 0000000000..153fc4f8b3 --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/active-imports.component.html @@ -0,0 +1,46 @@ + + + +
+
+
+
+
+ Import Tracker {{tracker.name()}} +
+
+
+
+
+ + + Created for Queue + + {{tracker.queue().name()}} + + on {{tracker.create_time() | date}} + +
+
+ State: + Active + Complete + Error + + + thumb_up + +
+
+ + + +
+
+
+
+
+
+ diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/active-imports.component.ts b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/active-imports.component.ts new file mode 100644 index 0000000000..7fc353ac2d --- /dev/null +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/active-imports.component.ts @@ -0,0 +1,92 @@ +import {Component, OnInit} from '@angular/core'; +import {IdlService, IdlObject} from '@eg/core/idl.service'; +import {AuthService} from '@eg/core/auth.service'; +import {PcrudService} from '@eg/core/pcrud.service'; +import {VandelayService} from './vandelay.service'; + +@Component({ + templateUrl: 'active-imports.component.html' +}) + +export class ActiveImportsComponent implements OnInit { + + trackers: IdlObject[]; + refreshInterval = 2000; // ms + + constructor( + private idl: IdlService, + private auth: AuthService, + private pcrud: PcrudService, + private vandelay: VandelayService + ) { + this.trackers = []; + } + + ngOnInit() { + this.pollTrackers(); + } + + pollTrackers() { + + const prevTrackers = this.trackers; + + // Report on active trackers for this workstation and for the + // logged in user, plus any that were already reported in the + // current instance of the UI. + const query: any = { + '-and' : [ + { + '-or': [ + {workstation: this.auth.user().wsid()}, + {usr: this.auth.user().id()} + ] + } + ] + }; + + if (this.trackers.length) { + query['-and'].push({ + '-or': [ + {state: 'active'}, + {id: prevTrackers.map(t => t.id())} + ] + }); + } else { + query['-and'].push({state: 'active'}); + } + + this.pcrud.search('vst', query, {order_by: {vst: 'create_time'}}) + .subscribe( + tracker => { + // The screen flickers less if the tracker array is + // updated inline instead of rebuilt every time. + + const existing = + this.trackers.filter(t => t.id() === tracker.id())[0]; + + if (existing) { + existing.update_time(tracker.update_time()); + existing.state(tracker.state()); + existing.total_actions(tracker.total_actions()); + existing.actions_performed(tracker.actions_performed()); + } else { + this.trackers.push(tracker); + + // TODO: flesh the queue / check record_type + } + }, + err => {}, + () => { + const active = + this.trackers.filter(t => t.state() === 'active'); + + // Continue updating the display with updated tracker + // data as long as we have any active trackers. + if (active.length > 0) { + setTimeout( + () => this.pollTrackers(), this.refreshInterval); + } + } + ); + } +} 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 a7776d5bda..aee0720a7c 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 @@ -12,6 +12,7 @@ import {HoldingsProfilesComponent} from './holdings-profiles.component'; import {QueueItemsComponent} from './queue-items.component'; import {MatchSetListComponent} from './match-set-list.component'; import {MatchSetComponent} from './match-set.component'; +import {ActiveImportsComponent} from './active-imports.component'; const routes: Routes = [{ path: '', @@ -59,6 +60,9 @@ const routes: Routes = [{ }, { path: 'match_sets/:id/:matchSetTab', component: MatchSetComponent + }, { + path: 'active_imports', + component: ActiveImportsComponent }] }]; diff --git a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.component.html b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.component.html index 1fc1a52b40..24471ed8dc 100644 --- a/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.component.html +++ b/Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.component.html @@ -32,6 +32,11 @@ routerLink="/staff/cat/vandelay/holdings_profiles" i18n>Holdings Import Profiles + 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 a4ce09ed23..1a1d9b19a9 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 @@ -22,6 +22,7 @@ import {MatchSetComponent} from './match-set.component'; import {MatchSetExpressionComponent} from './match-set-expression.component'; import {MatchSetQualityComponent} from './match-set-quality.component'; import {MatchSetNewPointComponent} from './match-set-new-point.component'; +import {ActiveImportsComponent} from './active-imports.component'; @NgModule({ declarations: [ @@ -41,7 +42,8 @@ import {MatchSetNewPointComponent} from './match-set-new-point.component'; MatchSetComponent, MatchSetExpressionComponent, MatchSetQualityComponent, - MatchSetNewPointComponent + MatchSetNewPointComponent, + ActiveImportsComponent ], imports: [ TreeModule, -- 2.11.0