X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fpybind%2Fmgr%2Fdashboard%2Ffrontend%2Fsrc%2Fapp%2Fceph%2Fcluster%2Fconfiguration%2Fconfiguration.component.ts;h=0c6863b9996e67d79d96e70d43cf6bec8e0c7421;hb=e306af509c4d4816a1f73b17a825ea5186fa0030;hp=f504d544853212ba549e96d9d8649f06bdc56eb4;hpb=11fdf7f228cb605e22a0e495ebabd3329db96b81;p=ceph.git diff --git a/ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts b/ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts index f504d5448..0c6863b99 100644 --- a/ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts +++ b/ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.ts @@ -3,7 +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'; @@ -16,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, @@ -42,57 +45,62 @@ 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; - @ViewChild('confFlagTpl') + @ViewChild('confFlagTpl', { static: false }) public confFlagTpl: TemplateRef; constructor( private authStorageService: AuthStorageService, private configurationService: ConfigurationService, - private i18n: I18n + 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.i18n('Edit'), + name: this.actionLabels.EDIT, disable: () => !this.isEditable(this.selection) }; this.tableActions = [editAction]; @@ -134,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;