From 2540cbce9869d9508567eb55206f7c7b4074202d Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 11 Nov 2019 15:00:48 -0500 Subject: [PATCH] better error handling Signed-off-by: Jason Etheridge --- .../acq/search/picklist-clone-dialog.component.ts | 20 ++++++++++++++++++-- .../acq/search/picklist-create-dialog.component.ts | 20 ++++++++++++++++++-- .../acq/search/picklist-delete-dialog.component.ts | 20 ++++++++++++++++++-- .../acq/search/picklist-merge-dialog.component.ts | 19 +++++++++++++++++-- 4 files changed, 71 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.ts index dd9317a735..63996dcce8 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-clone-dialog.component.ts @@ -1,7 +1,9 @@ import {Component, Input, ViewChild, TemplateRef, OnInit} from '@angular/core'; import {Observable, from, empty, throwError} from 'rxjs'; import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {AlertDialogComponent} from '@eg/share/dialog/alert.component'; import {IdlService, 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 {NgbModal} from '@ng-bootstrap/ng-bootstrap'; @@ -20,8 +22,11 @@ export class PicklistCloneDialogComponent leadListName: String; selections: IdlObject[]; + @ViewChild('fail', { static: true }) private fail: AlertDialogComponent; + constructor( private idl: IdlService, + private evt: EventService, private net: NetService, private auth: AuthService, private modal: NgbModal @@ -47,8 +52,19 @@ export class PicklistCloneDialogComponent this.grid.context.getSelectedRows()[0].id(), this.selectionListName ).subscribe( - new_id => this.close(new_id), - err => throwError(err) + (res) => { + if (this.evt.parse(res)) { + console.error(res); + this.fail.open(); + } else { + console.log(res); + } + }, + (err) => { + console.error(err); + this.fail.open(); + }, + () => this.close(true) ); } } diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.ts index 380b9fcb10..2325aae7f1 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-create-dialog.component.ts @@ -1,7 +1,9 @@ import {Component, Input, ViewChild, TemplateRef, OnInit} from '@angular/core'; import {Observable, from, empty, throwError} from 'rxjs'; import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {AlertDialogComponent} from '@eg/share/dialog/alert.component'; import {IdlService, 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 {NgbModal} from '@ng-bootstrap/ng-bootstrap'; @@ -17,8 +19,11 @@ export class PicklistCreateDialogComponent selectionListName: String; + @ViewChild('fail', { static: true }) private fail: AlertDialogComponent; + constructor( private idl: IdlService, + private evt: EventService, private net: NetService, private auth: AuthService, private modal: NgbModal @@ -39,8 +44,19 @@ export class PicklistCreateDialogComponent 'open-ils.acq.picklist.create', this.auth.token(), picklist ).subscribe( - new_id => this.close(new_id), - err => throwError(err) + (res) => { + if (this.evt.parse(res)) { + console.error(res); + this.fail.open(); + } else { + console.log(res); + } + }, + (err) => { + console.error(err); + this.fail.open(); + }, + () => this.close(true) ); } } diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.ts index cb6f658004..e1e3b6091a 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-delete-dialog.component.ts @@ -1,7 +1,9 @@ import {Component, Input, ViewChild, TemplateRef, OnInit} from '@angular/core'; import {Observable, forkJoin, from, empty, throwError} from 'rxjs'; import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {AlertDialogComponent} from '@eg/share/dialog/alert.component'; import {IdlService, 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 {NgbModal} from '@ng-bootstrap/ng-bootstrap'; @@ -18,8 +20,11 @@ export class PicklistDeleteDialogComponent @Input() grid: any; listNames: string[]; + @ViewChild('fail', { static: true }) private fail: AlertDialogComponent; + constructor( private idl: IdlService, + private evt: EventService, private net: NetService, private auth: AuthService, private modal: NgbModal @@ -50,8 +55,19 @@ export class PicklistDeleteDialogComponent observables.push( that.deleteList(r) ); }); forkJoin(observables).subscribe( - results => this.close(results), - err => throwError(err) + (res) => { + if (this.evt.parse(res)) { + console.error(res); + this.fail.open(); + } else { + console.log(res); + } + }, + (err) => { + console.error(err); + this.fail.open(); + }, + () => this.close(true) ); } } diff --git a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-merge-dialog.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-merge-dialog.component.ts index a3476895b9..d2b67551a3 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-merge-dialog.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/search/picklist-merge-dialog.component.ts @@ -1,7 +1,9 @@ import {Component, Input, ViewChild, TemplateRef, OnInit} from '@angular/core'; import {Observable, forkJoin, from, empty, throwError} from 'rxjs'; import {DialogComponent} from '@eg/share/dialog/dialog.component'; +import {AlertDialogComponent} from '@eg/share/dialog/alert.component'; import {IdlService, 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 {NgbModal} from '@ng-bootstrap/ng-bootstrap'; @@ -20,8 +22,11 @@ export class PicklistMergeDialogComponent leadList: number; selectedLists: IdlObject[]; + @ViewChild('fail', { static: true }) private fail: AlertDialogComponent; + constructor( private idl: IdlService, + private evt: EventService, private net: NetService, private auth: AuthService, private modal: NgbModal @@ -45,8 +50,18 @@ export class PicklistMergeDialogComponent this.auth.token(), this.leadList, this.selectedLists.map( list => list.id() ).filter(function(p) { return p != that.leadList; }) ).subscribe( - (res) => console.log('res',res), - (err) => throwError(err), + (res) => { + if (this.evt.parse(res)) { + console.error(res); + this.fail.open(); + } else { + console.log(res); + } + }, + (err) => { + console.error(err); + this.fail.open(); + }, () => this.close(true) ); } -- 2.11.0