- policyTypeInfo = new Map<string, PolicyTypeInfo>();
- 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 = 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());
- }
-
- 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<boolean> {
- return this.getPolicyTypeInfo(policyTypeSchema).isExpanded.asObservable();
- }