X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fpolicy%2Fpolicy-control.component.ts;h=feb4cfb6f6e6adf2af13d8cfc88fe77ec6e96f9c;hb=90295c9a25c27628164eed0c66d0a89df587525b;hp=de3f57879109119c6e27e74a534c7626823b9939;hpb=41a57e4d75761207f2da883d0e4396c81159e58e;p=portal%2Fnonrtric-controlpanel.git diff --git a/webapp-frontend/src/app/policy/policy-control.component.ts b/webapp-frontend/src/app/policy/policy-control.component.ts index de3f578..feb4cfb 100644 --- a/webapp-frontend/src/app/policy/policy-control.component.ts +++ b/webapp-frontend/src/app/policy/policy-control.component.ts @@ -17,90 +17,34 @@ * limitations under the License. * ========================LICENSE_END=================================== */ -import { animate, state, style, transition, trigger } from '@angular/animations'; -import { Component, OnInit } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; +import { Component, OnInit } from "@angular/core"; -import { BehaviorSubject, Observable } from 'rxjs'; - -import { PolicyTypes, PolicyTypeSchema } from '@interfaces/policy.types'; -import { PolicyTypeDataSource } from './policy-type/policy-type.datasource'; -import { getPolicyDialogProperties } from './policy-instance-dialog/policy-instance-dialog.component'; -import { PolicyInstanceDialogComponent } from './policy-instance-dialog/policy-instance-dialog.component'; -import { UiService } from '@services/ui/ui.service'; -import { PolicyService } from '@services/policy/policy.service'; -import { PolicyTypeComponent } from './policy-type/policy-type.component'; - -class PolicyTypeInfo { - constructor(public type: PolicyTypeSchema) { } - - isExpanded: BehaviorSubject = new BehaviorSubject(false); -} +import { PolicyTypes } from "@interfaces/policy.types"; +import { PolicyService } from "@services/policy/policy.service"; +import { PolicyTypeComponent } from "./policy-type/policy-type.component" @Component({ - selector: 'nrcp-policy-control', - templateUrl: './policy-control.component.html', - styleUrls: ['./policy-control.component.scss'], - animations: [ - trigger('detailExpand', [ - state('collapsed, void', style({ height: '0px', minHeight: '0', display: 'none' })), - state('expanded', style({ height: '*' })), - transition('expanded <=> collapsed', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')), - transition('expanded <=> void', animate('225ms cubic-bezier(0.4, 0.0, 0.2, 1)')) - ]), - ], + selector: "nrcp-policy-control", + templateUrl: "./policy-control.component.html", + styleUrls: ["./policy-control.component.scss"] }) -export class PolicyControlComponent implements OnInit { - - policyTypeInfo = new Map(); - policyTypeIds: Array; - policyTypeComponent = new PolicyTypeComponent(this.policyTypesDataSource); - darkMode: boolean; - - constructor( - public policyTypesDataSource: PolicyTypeDataSource, - private dialog: MatDialog, - private policyService: PolicyService, - private ui: UiService) { } - ngOnInit() { - this.policyTypesDataSource.getPolicyTypes(); - this.ui.darkModeState.subscribe((isDark) => { - this.darkMode = isDark; - }); - this.policyService.getPolicyTypes().subscribe((policyType: PolicyTypes) => { - this.policyTypeIds = policyType.policytype_ids; - } - ); - } - - toggleListInstances(policyTypeSchema: PolicyTypeSchema): void { - const info = this.getPolicyTypeInfo(policyTypeSchema); - info.isExpanded.next(!info.isExpanded.getValue()); - } - - getPolicyTypeInfo(policyTypeSchema: PolicyTypeSchema): PolicyTypeInfo { - let info: PolicyTypeInfo = this.policyTypeInfo.get(policyTypeSchema.name); - if (!info) { - info = new PolicyTypeInfo(policyTypeSchema); - this.policyTypeInfo.set(policyTypeSchema.name, info); - } - return info; - } - - getDisplayName(policyTypeSchema: PolicyTypeSchema): string { - if (policyTypeSchema.schemaObject.title) { - return policyTypeSchema.schemaObject.title; - } - return '< No type >'; - } - - getExpandedObserver(policyTypeSchema: PolicyTypeSchema): Observable { - return this.getPolicyTypeInfo(policyTypeSchema).isExpanded.asObservable(); - } - - refreshTables() { - this.policyTypesDataSource.getPolicyTypes(); - this.policyTypeComponent.setIsVisible(false); - } +export class PolicyControlComponent implements OnInit { + policyTypeIds = []; + ptComponent: PolicyTypeComponent; + + constructor(private policyService: PolicyService) { + this.ptComponent = new PolicyTypeComponent(policyService); + } + + ngOnInit() { + this.refreshTables(); + } + + refreshTables() { + this.policyService.getPolicyTypes().subscribe((policyType: PolicyTypes) => { + this.policyTypeIds = policyType.policytype_ids.sort(); + }); + this.ptComponent.toggleVisible(); + } }