Code Review
/
portal
/
nonrtric-controlpanel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix producers and jobs don't appear on interface
[portal/nonrtric-controlpanel.git]
/
webapp-frontend
/
src
/
app
/
policy-control
/
policy-control.component.ts
diff --git
a/webapp-frontend/src/app/policy-control/policy-control.component.ts
b/webapp-frontend/src/app/policy-control/policy-control.component.ts
index
c287438
..
4227d78
100644
(file)
--- a/
webapp-frontend/src/app/policy-control/policy-control.component.ts
+++ b/
webapp-frontend/src/app/policy-control/policy-control.component.ts
@@
-17,29
+17,27
@@
* limitations under the License.
* ========================LICENSE_END===================================
*/
* limitations under the License.
* ========================LICENSE_END===================================
*/
-import { Component, OnInit, ViewChild } from '@angular/core';
-import { MatDialog } from '@angular/material/dialog';
-import { MatSort } from '@angular/material/sort';
import { animate, state, style, transition, trigger } from '@angular/animations';
import { animate, state, style, transition, trigger } from '@angular/animations';
+import { Component, OnInit } from '@angular/core';
+import { MatDialog } from '@angular/material/dialog';
-import { PolicyService } from '../services/policy/policy.service';
-import { PolicyType } from '../interfaces/policy.types';
+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 { PolicyTypeDataSource } from './policy-type.datasource';
import { getPolicyDialogProperties } from './policy-instance-dialog.component';
import { PolicyInstanceDialogComponent } from './policy-instance-dialog.component';
-import { NotificationService } from '../services/ui/notification.service';
-import { BehaviorSubject, Observable } from 'rxjs';
import { UiService } from '../services/ui/ui.service';
import { UiService } from '../services/ui/ui.service';
-import { NoTypePolicyInstanceDialogComponent } from './no-type-policy-instance-dialog.component';
class PolicyTypeInfo {
class PolicyTypeInfo {
- constructor(public type: PolicyType) { }
+ constructor(public type: PolicyType
Schema
) { }
isExpanded: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
}
@Component({
isExpanded: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
}
@Component({
- selector: '
rd
-policy-control',
+ selector: '
nrcp
-policy-control',
templateUrl: './policy-control.component.html',
styleUrls: ['./policy-control.component.scss'],
animations: [
templateUrl: './policy-control.component.html',
styleUrls: ['./policy-control.component.scss'],
animations: [
@@
-53,37
+51,31
@@
class PolicyTypeInfo {
})
export class PolicyControlComponent implements OnInit {
})
export class PolicyControlComponent implements OnInit {
-
- policyTypesDataSource: PolicyTypeDataSource;
- @ViewChild(MatSort, { static: true }) sort: MatSort;
-
policyTypeInfo = new Map<string, PolicyTypeInfo>();
darkMode: boolean;
constructor(
policyTypeInfo = new Map<string, PolicyTypeInfo>();
darkMode: boolean;
constructor(
- p
rivate policySvc: PolicyServi
ce,
+ p
ublic policyTypesDataSource: PolicyTypeDataSour
ce,
private dialog: MatDialog,
private dialog: MatDialog,
- private notificationService: NotificationService,
private ui: UiService) { }
ngOnInit() {
private ui: UiService) { }
ngOnInit() {
- this.policyTypesDataSource = new PolicyTypeDataSource(this.policySvc, this.sort, this.notificationService);
- this.policyTypesDataSource.loadTable();
+ this.policyTypesDataSource.getPolicyTypes();
this.ui.darkModeState.subscribe((isDark) => {
this.darkMode = isDark;
});
}
this.ui.darkModeState.subscribe((isDark) => {
this.darkMode = isDark;
});
}
- createPolicyInstance(policyType
: PolicyType
): void {
+ createPolicyInstance(policyType
Schema: PolicyTypeSchema
): void {
let dialogRef;
let dialogRef;
- if (this.isSchemaEmpty(policyType)) {
+ if (this.isSchemaEmpty(policyType
Schema
)) {
dialogRef = this.dialog.open(NoTypePolicyInstanceDialogComponent,
dialogRef = this.dialog.open(NoTypePolicyInstanceDialogComponent,
- getPolicyDialogProperties(policyType, null, this.darkMode));
+ getPolicyDialogProperties(policyType
Schema
, null, this.darkMode));
} else {
dialogRef = this.dialog.open(PolicyInstanceDialogComponent,
} else {
dialogRef = this.dialog.open(PolicyInstanceDialogComponent,
- getPolicyDialogProperties(policyType, null, this.darkMode));
+ getPolicyDialogProperties(policyType
Schema
, null, this.darkMode));
}
}
- const info: PolicyTypeInfo = this.getPolicyTypeInfo(policyType);
+ const info: PolicyTypeInfo = this.getPolicyTypeInfo(policyType
Schema
);
dialogRef.afterClosed().subscribe(
(_) => {
info.isExpanded.next(info.isExpanded.getValue());
dialogRef.afterClosed().subscribe(
(_) => {
info.isExpanded.next(info.isExpanded.getValue());
@@
-91,40
+83,40
@@
export class PolicyControlComponent implements OnInit {
);
}
);
}
- toggleListInstances(policyType
: PolicyType
): void {
- const info = this.getPolicyTypeInfo(policyType);
+ toggleListInstances(policyType
Schema: PolicyTypeSchema
): void {
+ const info = this.getPolicyTypeInfo(policyType
Schema
);
info.isExpanded.next(!info.isExpanded.getValue());
}
info.isExpanded.next(!info.isExpanded.getValue());
}
- private isSchemaEmpty(policyType
: PolicyType
): boolean {
- return
Object.keys(policyType.schemaObject).length === 0
;
+ private isSchemaEmpty(policyType
Schema: PolicyTypeSchema
): boolean {
+ return
policyTypeSchema.schemaObject === '{}'
;
}
}
- getPolicyTypeInfo(policyType
: PolicyType
): PolicyTypeInfo {
- let info: PolicyTypeInfo = this.policyTypeInfo.get(policyType.name);
+ getPolicyTypeInfo(policyType
Schema: PolicyTypeSchema
): PolicyTypeInfo {
+ let info: PolicyTypeInfo = this.policyTypeInfo.get(policyType
Schema
.name);
if (!info) {
if (!info) {
- info = new PolicyTypeInfo(policyType);
- this.policyTypeInfo.set(policyType.name, info);
+ info = new PolicyTypeInfo(policyType
Schema
);
+ this.policyTypeInfo.set(policyType
Schema
.name, info);
}
return info;
}
}
return info;
}
- getDisplayName(policyType
: PolicyType
): string {
- if (policyType.schemaObject.title) {
- return policyType.schemaObject.title;
+ getDisplayName(policyType
Schema: PolicyTypeSchema
): string {
+ if (policyType
Schema
.schemaObject.title) {
+ return policyType
Schema
.schemaObject.title;
}
return '< No type >';
}
}
return '< No type >';
}
- isInstancesShown(policyType
: PolicyType
): boolean {
- return this.getPolicyTypeInfo(policyType).isExpanded.getValue();
+ isInstancesShown(policyType
Schema: PolicyTypeSchema
): boolean {
+ return this.getPolicyTypeInfo(policyType
Schema
).isExpanded.getValue();
}
}
- getExpandedObserver(policyType
: PolicyType
): Observable<boolean> {
- return this.getPolicyTypeInfo(policyType).isExpanded.asObservable();
+ getExpandedObserver(policyType
Schema: PolicyTypeSchema
): Observable<boolean> {
+ return this.getPolicyTypeInfo(policyType
Schema
).isExpanded.asObservable();
}
}
- refresh() {
-
location.reload
();
+ refresh
Tables
() {
+
this.policyTypesDataSource.getPolicyTypes
();
}
}
}
}