X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fpolicy%2Fpolicy-type%2Fpolicy-type.component.ts;h=3e8a2ee8be33b4ffa18af616b977dfe694c2a261;hb=dcf60a7be63414b4110b77f0a5b90e8be025a5d3;hp=7d82cb47f46eaaa9566a8b5ccc673cb6e921bab2;hpb=8145531a9b5d15edcaa49249bef0c0c95723acbb;p=portal%2Fnonrtric-controlpanel.git diff --git a/webapp-frontend/src/app/policy/policy-type/policy-type.component.ts b/webapp-frontend/src/app/policy/policy-type/policy-type.component.ts index 7d82cb4..3e8a2ee 100644 --- a/webapp-frontend/src/app/policy/policy-type/policy-type.component.ts +++ b/webapp-frontend/src/app/policy/policy-type/policy-type.component.ts @@ -18,10 +18,11 @@ * ========================LICENSE_END=================================== */ -import { Component, Input, OnInit } from "@angular/core"; +import { Component, Input, OnInit, OnChanges, SimpleChanges} from "@angular/core"; import { BehaviorSubject } from "rxjs"; import { PolicyType, PolicyTypeSchema } from "@interfaces/policy.types"; import { PolicyService } from "@app/services/policy/policy.service"; +import "@policy/policy-control.component"; class PolicyTypeInfo { constructor(public type: PolicyTypeSchema) {} @@ -34,8 +35,9 @@ class PolicyTypeInfo { templateUrl: "./policy-type.component.html", styleUrls: ["./policy-type.component.scss"], }) -export class PolicyTypeComponent implements OnInit { +export class PolicyTypeComponent implements OnInit, OnChanges { @Input() policyTypeId: string; + @Input() minimiseTrigger: boolean; isVisible: BehaviorSubject = new BehaviorSubject(false); @@ -46,7 +48,18 @@ export class PolicyTypeComponent implements OnInit { constructor(private policyService: PolicyService) {} ngOnInit(): void { - if (this.policyTypeId !== "") { + this.loadTypeInfo(); + this.isVisible.next(false); + } + + ngOnChanges(changes: SimpleChanges): void { + if(changes['minimiseTrigger']){ + this.isVisible.next(false); + } + } + + public loadTypeInfo() { + if (this.policyTypeId && this.policyTypeId !== "") { this.policyService .getPolicyType(this.policyTypeId) .subscribe((policyType: PolicyType) => { @@ -57,15 +70,14 @@ export class PolicyTypeComponent implements OnInit { }); } else { const noType = { - policy_schema: JSON.parse('{"schemaObject": "{}"}'), + policy_schema: JSON.parse('{}'), } as PolicyType; const noTypeSchema = this.getSchemaObject(noType); this.policyTypeInfo = new PolicyTypeInfo(noTypeSchema); this.policyType = "< No Type >"; this.policyDescription = "Type with no schema"; } - this.isVisible.next(false); - } +} private getSchemaObject(policyType: PolicyType) { const policyTypeSchema = {} as PolicyTypeSchema; @@ -75,10 +87,6 @@ export class PolicyTypeComponent implements OnInit { return policyTypeSchema; } - public setIsVisible(status: boolean) { - this.isVisible.next(status); - } - public toggleVisible() { this.isVisible.next(!this.isVisible.value); }