Skip to content

Commit

Permalink
Handle issues with settings
Browse files Browse the repository at this point in the history
  • Loading branch information
YehuditAdler committed Jan 24, 2024
1 parent 22eb365 commit 844e8b1
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions cloudapp/src/app/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
RestErrorResponse,
} from "@exlibris/exl-cloudapp-angular-lib";
import { Configuration } from "../models/configuration.model";
import { forkJoin } from "rxjs";
import { forkJoin, of } from "rxjs";
import { Router } from "@angular/router";
import { finalize, map } from "rxjs/operators";
import { catchError, finalize, map } from "rxjs/operators";
import { Departments } from "../models/departments.model";
import { Statuses } from "../models/statuses.model";

Expand Down Expand Up @@ -93,7 +93,7 @@ export class SettingsComponent implements OnInit {
this.config.from.department = "";
}

let rests = [this.restService.call("/conf/departments?library="+code)];
let rests = [this.getDepartmentData(code)];
if(code != ''){
rests.push(this.restService.call("/conf/libraries/"+code+"/circ-desks"));
}
Expand All @@ -108,11 +108,15 @@ export class SettingsComponent implements OnInit {
}))
.subscribe({
next: (res ) => {
this.departments = res[0].department;
this.departments.unshift({name : ' ',code:'',type:{value : ' '} });
if(res[0] != null){
this.departments = res[0].department;
this.departments.unshift({name : ' ',code:'',type:{value : ' '} });
}
if(res.length >1){
this.circulation_desks = res[1].circ_desk
this.circulation_desks.unshift({name : ' ',code:'',link:''});
}else{
this.circulation_desks = [];
}

},
Expand All @@ -125,6 +129,19 @@ export class SettingsComponent implements OnInit {

}


getDepartmentData(code) {
return this.restService.call("/conf/departments?library="+code).pipe(
catchError((error) => {
// Handle errors from the department API
this.departments = [];
console.error(error.message);
// Return a placeholder value or an empty observable to continue with the other API
return of(null);
})
);
}


onCircDeskOrDepartmentChange(circ_desk : string,department_code: string){
this.work_order_types =[];
Expand Down

0 comments on commit 844e8b1

Please sign in to comment.