- loadTable() {
- this.loadingSubject.next(true);
- this.policySvc.getPolicyTypes()
- .pipe(
- catchError((her: HttpErrorResponse) => {
- this.notificationService.error('Failed to get policy types: ' + her.statusText + ', ' + her.error);
- return of([]);
- }),
- finalize(() => this.loadingSubject.next(false))
- )
- .subscribe((types: PolicyType[]) => {
- this.rowCount = types.length;
- for (let i = 0; i < types.length; i++) {
- const policyType = types[i];
- try {
- policyType.schemaObject = JSON.parse(policyType.schema);
- } catch (jsonError) {
- console.error('Could not parse schema: ' + policyType.schema);
- policyType.schemaObject = { description: 'Incorrect schema: ' + jsonError };
+ public getPolicyTypes() {
+ this.policyTypes = [] as PolicyTypeSchema[];
+ this.policySvc.getPolicyTypes().subscribe(data => {
+ if (data.policytype_ids.length != 0) {
+ data.policytype_ids.forEach(policyId => {
+ var policyTypeSchema = {} as PolicyTypeSchema
+ if (policyId === "") {
+ policyTypeSchema.name = '';
+ policyTypeSchema.schemaObject = '{}';
+ this.policyTypes.push(policyTypeSchema);