X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-frontend%2Fsrc%2Fapp%2Fpolicy-control%2Fpolicy-control.component.ts;fp=webapp-frontend%2Fsrc%2Fapp%2Fpolicy-control%2Fpolicy-control.component.ts;h=0000000000000000000000000000000000000000;hb=c43690c45b3f4d08d013ec488b83dea793cca646;hp=4227d7884999aefbdd83104e42036424737e6c5d;hpb=923a26d056fd5b613aa1342fff7d7f0f74d9267e;p=portal%2Fnonrtric-controlpanel.git diff --git a/webapp-frontend/src/app/policy-control/policy-control.component.ts b/webapp-frontend/src/app/policy-control/policy-control.component.ts deleted file mode 100644 index 4227d78..0000000 --- a/webapp-frontend/src/app/policy-control/policy-control.component.ts +++ /dev/null @@ -1,122 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * 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 { BehaviorSubject, Observable } from 'rxjs'; - -import { NoTypePolicyInstanceDialogComponent } from './no-type-policy-instance-dialog.component'; -import { PolicyTypeSchema } from '../interfaces/policy.types'; -import { PolicyTypeDataSource } from './policy-type.datasource'; -import { getPolicyDialogProperties } from './policy-instance-dialog.component'; -import { PolicyInstanceDialogComponent } from './policy-instance-dialog.component'; -import { UiService } from '../services/ui/ui.service'; - -class PolicyTypeInfo { - constructor(public type: PolicyTypeSchema) { } - - isExpanded: BehaviorSubject = new BehaviorSubject(false); -} - -@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)')) - ]), - ], -}) -export class PolicyControlComponent implements OnInit { - - policyTypeInfo = new Map(); - darkMode: boolean; - - constructor( - public policyTypesDataSource: PolicyTypeDataSource, - private dialog: MatDialog, - private ui: UiService) { } - - ngOnInit() { - this.policyTypesDataSource.getPolicyTypes(); - this.ui.darkModeState.subscribe((isDark) => { - this.darkMode = isDark; - }); - } - - createPolicyInstance(policyTypeSchema: PolicyTypeSchema): void { - let dialogRef; - if (this.isSchemaEmpty(policyTypeSchema)) { - dialogRef = this.dialog.open(NoTypePolicyInstanceDialogComponent, - getPolicyDialogProperties(policyTypeSchema, null, this.darkMode)); - } else { - dialogRef = this.dialog.open(PolicyInstanceDialogComponent, - getPolicyDialogProperties(policyTypeSchema, null, this.darkMode)); - } - const info: PolicyTypeInfo = this.getPolicyTypeInfo(policyTypeSchema); - dialogRef.afterClosed().subscribe( - (_) => { - info.isExpanded.next(info.isExpanded.getValue()); - } - ); - } - - toggleListInstances(policyTypeSchema: PolicyTypeSchema): void { - const info = this.getPolicyTypeInfo(policyTypeSchema); - info.isExpanded.next(!info.isExpanded.getValue()); - } - - private isSchemaEmpty(policyTypeSchema: PolicyTypeSchema): boolean { - return policyTypeSchema.schemaObject === '{}'; - } - - 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 >'; - } - - isInstancesShown(policyTypeSchema: PolicyTypeSchema): boolean { - return this.getPolicyTypeInfo(policyTypeSchema).isExpanded.getValue(); - } - - getExpandedObserver(policyTypeSchema: PolicyTypeSchema): Observable { - return this.getPolicyTypeInfo(policyTypeSchema).isExpanded.asObservable(); - } - - refreshTables() { - this.policyTypesDataSource.getPolicyTypes(); - } -}