]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts
import 15.2.4
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / configuration / configuration.component.ts
index 82ea4b444e68d5380014e67804b624ed0d4963ca..0c6863b9996e67d79d96e70d43cf6bec8e0c7421 100644 (file)
@@ -3,8 +3,10 @@ import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
 import { I18n } from '@ngx-translate/i18n-polyfill';
 
 import { ConfigurationService } from '../../../shared/api/configuration.service';
+import { ListWithDetails } from '../../../shared/classes/list-with-details.class';
 import { ActionLabelsI18n } from '../../../shared/constants/app.constants';
 import { CellTemplate } from '../../../shared/enum/cell-template.enum';
+import { Icons } from '../../../shared/enum/icons.enum';
 import { CdTableAction } from '../../../shared/models/cd-table-action';
 import { CdTableColumn } from '../../../shared/models/cd-table-column';
 import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-data-context';
@@ -17,20 +19,20 @@ import { AuthStorageService } from '../../../shared/services/auth-storage.servic
   templateUrl: './configuration.component.html',
   styleUrls: ['./configuration.component.scss']
 })
-export class ConfigurationComponent implements OnInit {
+export class ConfigurationComponent extends ListWithDetails implements OnInit {
   permission: Permission;
   tableActions: CdTableAction[];
-  data = [];
+  data: any[] = [];
+  icons = Icons;
   columns: CdTableColumn[];
   selection = new CdTableSelection();
-  filters = [
+  filters: CdTableColumn[] = [
     {
-      label: this.i18n('Level'),
+      name: this.i18n('Level'),
       prop: 'level',
-      initValue: 'basic',
-      value: 'basic',
-      options: ['basic', 'advanced', 'dev'],
-      applyFilter: (row, value) => {
+      filterOptions: ['basic', 'advanced', 'dev'],
+      filterInitValue: 'basic',
+      filterPredicate: (row, value) => {
         enum Level {
           basic = 0,
           advanced = 1,
@@ -43,42 +45,45 @@ export class ConfigurationComponent implements OnInit {
       }
     },
     {
-      label: this.i18n('Service'),
+      name: this.i18n('Service'),
       prop: 'services',
-      initValue: 'any',
-      value: 'any',
-      options: ['any', 'mon', 'mgr', 'osd', 'mds', 'common', 'mds_client', 'rgw'],
-      applyFilter: (row, value) => {
-        if (value === 'any') {
-          return true;
-        }
-
+      filterOptions: ['mon', 'mgr', 'osd', 'mds', 'common', 'mds_client', 'rgw'],
+      filterPredicate: (row, value) => {
         return row.services.includes(value);
       }
     },
     {
-      label: this.i18n('Source'),
+      name: this.i18n('Source'),
       prop: 'source',
-      initValue: 'any',
-      value: 'any',
-      options: ['any', 'mon'],
-      applyFilter: (row, value) => {
-        if (value === 'any') {
+      filterOptions: ['mon'],
+      filterPredicate: (row, value) => {
+        if (!row.hasOwnProperty('source')) {
+          return false;
+        }
+        return row.source.includes(value);
+      }
+    },
+    {
+      name: this.i18n('Modified'),
+      prop: 'modified',
+      filterOptions: ['yes', 'no'],
+      filterPredicate: (row, value) => {
+        if (value === 'yes' && row.hasOwnProperty('value')) {
           return true;
         }
 
-        if (!row.hasOwnProperty('source')) {
-          return false;
+        if (value === 'no' && !row.hasOwnProperty('value')) {
+          return true;
         }
 
-        return row.source.includes(value);
+        return false;
       }
     }
   ];
 
-  @ViewChild('confValTpl')
+  @ViewChild('confValTpl', { static: true })
   public confValTpl: TemplateRef<any>;
-  @ViewChild('confFlagTpl')
+  @ViewChild('confFlagTpl', { static: false })
   public confFlagTpl: TemplateRef<any>;
 
   constructor(
@@ -87,12 +92,13 @@ export class ConfigurationComponent implements OnInit {
     private i18n: I18n,
     public actionLabels: ActionLabelsI18n
   ) {
+    super();
     this.permission = this.authStorageService.getPermissions().configOpt;
     const getConfigOptUri = () =>
       this.selection.first() && `${encodeURIComponent(this.selection.first().name)}`;
     const editAction: CdTableAction = {
       permission: 'update',
-      icon: 'fa-pencil',
+      icon: Icons.edit,
       routerLink: () => `/configuration/edit/${getConfigOptUri()}`,
       name: this.actionLabels.EDIT,
       disable: () => !this.isEditable(this.selection)
@@ -136,17 +142,6 @@ export class ConfigurationComponent implements OnInit {
     );
   }
 
-  updateFilter() {
-    this.data = [...this.data];
-  }
-
-  resetFilter() {
-    this.filters.forEach((item) => {
-      item.value = item.initValue;
-    });
-    this.data = [...this.data];
-  }
-
   isEditable(selection: CdTableSelection): boolean {
     if (selection.selected.length !== 1) {
       return false;