summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
592589c)
The json schema foreach type was parsed several times each time the main
window was rendered.
Change-Id: I209af068d07444a76264764ba4d9a683acae9bc3
Issue-ID: NONRTRIC-61
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
policy_type_id: number;
name: string;
schema: string;
policy_type_id: number;
name: string;
schema: string;
}
export interface PolicyInstance {
}
export interface PolicyInstance {
class="policy-type-table mat-elevation-z8">
<ng-container matColumnDef="name">
class="policy-type-table mat-elevation-z8">
<ng-container matColumnDef="name">
- <mat-header-cell *matHeaderCellDef mat-sort-header>Policy Type</mat-header-cell>
+ <mat-header-cell *matHeaderCellDef>Policy Type</mat-header-cell>
<mat-cell *matCellDef="let policyType">
<mat-icon matTooltip="Properties">{{isInstancesShown(policyType) ? 'expand_less' : 'expand_more'}}
</mat-icon>
<mat-cell *matCellDef="let policyType">
<mat-icon matTooltip="Properties">{{isInstancesShown(policyType) ? 'expand_less' : 'expand_more'}}
</mat-icon>
<ng-container matColumnDef="description">
<mat-header-cell *matHeaderCellDef> Description </mat-header-cell>
<ng-container matColumnDef="description">
<mat-header-cell *matHeaderCellDef> Description </mat-header-cell>
- <mat-cell *matCellDef="let policyType"> {{this.getDescription(policyType)}}
+ <mat-cell *matCellDef="let policyType"> {{policyType.schemaObject.description}}
</mat-cell>
</ng-container>
</mat-cell>
</ng-container>
}
toggleListInstances(policyType: PolicyType): void {
}
toggleListInstances(policyType: PolicyType): void {
- console.log('1toggleListInstances ' + + policyType.name + ' ' + this.getPolicyTypeInfo(policyType).isExpanded.getValue());
const info = this.getPolicyTypeInfo(policyType);
info.isExpanded.next(!info.isExpanded.getValue());
const info = this.getPolicyTypeInfo(policyType);
info.isExpanded.next(!info.isExpanded.getValue());
- console.log('2toggleListInstances ' + + policyType.name + ' ' + this.getPolicyTypeInfo(policyType).isExpanded.getValue());
-
}
getPolicyTypeInfo(policyType: PolicyType): PolicyTypeInfo {
}
getPolicyTypeInfo(policyType: PolicyType): PolicyTypeInfo {
- getDescription(policyType: PolicyType): string {
- return JSON.parse(policyType.schema).description;
- }
-
getName(policyType: PolicyType): string {
getName(policyType: PolicyType): string {
- const title = JSON.parse(policyType.schema).title;
- if (title) { return title; }
+ if (policyType.schemaObject.title) { return policyType.schemaObject.title; }
return policyType.name;
}
return policyType.name;
}
this.policyInstanceId = data.instanceId;
this.policyTypeName = data.name;
this.policyTypeId = data.policyTypeId;
this.policyInstanceId = data.instanceId;
this.policyTypeName = data.name;
this.policyTypeId = data.policyTypeId;
- this.parseJson(data.createSchema, data.instanceJson);
+ this.jsonSchemaObject = data.createSchema;
+ this.jsonObject = this.parseJson(data.instanceJson);
return errorArray.join('<br>');
}
return errorArray.join('<br>');
}
- private parseJson(createSchema: string, instanceJson: string): void {
+ private parseJson(str: string): string {
- this.jsonSchemaObject = JSON.parse(createSchema);
- if (instanceJson != null) {
- this.jsonObject = JSON.parse(instanceJson);
+ if (str != null) {
+ return JSON.parse(str);
}
} catch (jsonError) {
this.jsonFormStatusMessage =
'Invalid JSON\n' +
'parser returned:\n\n' + jsonError;
}
} catch (jsonError) {
this.jsonFormStatusMessage =
'Invalid JSON\n' +
'parser returned:\n\n' + jsonError;
}
public toggleVisible(item: string) {
}
public toggleVisible(item: string) {
export function getPolicyDialogProperties(policyType: PolicyType, instance: PolicyInstance, darkMode: boolean): MatDialogConfig {
const policyTypeId = policyType.policy_type_id;
export function getPolicyDialogProperties(policyType: PolicyType, instance: PolicyInstance, darkMode: boolean): MatDialogConfig {
const policyTypeId = policyType.policy_type_id;
- const createSchema = policyType.schema;
+ const createSchema = policyType.schemaObject;
const instanceId = instance ? instance.instanceId : null;
const instanceJson = instance ? instance.instance : null;
const name = policyType.name;
const instanceId = instance ? instance.instanceId : null;
const instanceJson = instance ? instance.instance : null;
const name = policyType.name;
)
.subscribe((types: PolicyType[]) => {
this.rowCount = types.length;
)
.subscribe((types: PolicyType[]) => {
this.rowCount = types.length;
+ for (let i = 0; i < types.length; i++) {
+ const policyType = types[i];
+ policyType.schemaObject = JSON.parse(policyType.schema);
+ }
this.policyTypeSubject.next(types);
});
}
this.policyTypeSubject.next(types);
});
}