From a98ea073b5a24f328fe74d3f4978e438892be833 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 30 Oct 2019 12:09:38 -0400 Subject: [PATCH] LP1830391 Ang print service emits on job queued Emit an event when a print job has either been delivered to Hatch or window.print() has returned. This gives the caller a better idea of the completeness of a print job. Signed-off-by: Bill Erickson --- Open-ILS/src/eg2/src/app/share/print/print.component.ts | 14 +++++++++----- Open-ILS/src/eg2/src/app/share/print/print.service.ts | 6 ++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/print/print.component.ts b/Open-ILS/src/eg2/src/app/share/print/print.component.ts index 6af06bd8f9..644f653096 100644 --- a/Open-ILS/src/eg2/src/app/share/print/print.component.ts +++ b/Open-ILS/src/eg2/src/app/share/print/print.component.ts @@ -79,7 +79,10 @@ export class PrintComponent implements OnInit { this.applyTemplate(printReq).then(() => { // Give templates a chance to render before printing setTimeout(() => { - this.dispatchPrint(printReq).then(_ => this.reset()); + this.dispatchPrint(printReq).then(_ => { + this.reset(); + this.printer.printJobQueued$.emit(printReq); + }); }); }); } @@ -191,7 +194,7 @@ export class PrintComponent implements OnInit { return this.checkHatchEnabled().then(enabled => { if (enabled) { - this.printViaHatch(printReq); + return this.printViaHatch(printReq); } else { // Here the needed HTML is already in the page. window.print(); @@ -199,7 +202,7 @@ export class PrintComponent implements OnInit { }); } - printViaHatch(printReq: PrintRequest) { + printViaHatch(printReq: PrintRequest): Promise { if (!printReq.contentType) { printReq.contentType = 'text/html'; } @@ -210,7 +213,8 @@ export class PrintComponent implements OnInit { html = `${printReq.text}`; } - this.serverStore.getItem(`eg.print.config.${printReq.printContext}`) + return this.serverStore.getItem( + `eg.print.config.${printReq.printContext}`) .then(config => { let msg: HatchMessage; @@ -238,7 +242,7 @@ export class PrintComponent implements OnInit { }); } - this.hatch.sendRequest(msg).then( + return this.hatch.sendRequest(msg).then( ok => console.debug('Print request succeeded'), err => console.warn('Print request failed', err) ); diff --git a/Open-ILS/src/eg2/src/app/share/print/print.service.ts b/Open-ILS/src/eg2/src/app/share/print/print.service.ts index 25ef20606e..5723a4cfd9 100644 --- a/Open-ILS/src/eg2/src/app/share/print/print.service.ts +++ b/Open-ILS/src/eg2/src/app/share/print/print.service.ts @@ -31,12 +31,18 @@ export class PrintService { onPrintRequest$: EventEmitter; + // Emitted after a print request has been delivered to Hatch or + // window.print() has completed. Note window.print() returning + // is not necessarily an indication the job has completed. + printJobQueued$: EventEmitter; + constructor( private locale: LocaleService, private auth: AuthService, private store: StoreService ) { this.onPrintRequest$ = new EventEmitter(); + this.printJobQueued$ = new EventEmitter(); } print(printReq: PrintRequest) { -- 2.11.0