-<cd-table [data]="data | filter:filters"
+<cd-table [data]="data"
(fetchData)="getConfigurationList($event)"
[columns]="columns"
+ [extraFilterableColumns]="filters"
selectionType="single"
(updateSelection)="updateSelection($event)">
<cd-table-actions class="table-actions"
[selection]="selection"
[tableActions]="tableActions">
</cd-table-actions>
- <div class="table-filters form-inline">
- <div class="form-group filter"
- *ngFor="let filter of filters">
- <label class="col-form-label">{{ filter.label }}: </label>
- <select class="form-control custom-select"
- [(ngModel)]="filter.value"
- (ngModelChange)="updateFilter()">
- <option *ngFor="let opt of filter.options">{{ opt }}</option>
- </select>
- </div>
-
- <div class="widget-toolbar tc_refreshBtn">
- <button type="button"
- title="Reset filters"
- class="btn btn-light"
- (click)="resetFilter()">
- <span [ngClass]="[icons.stack]">
- <i [ngClass]="[icons.filter, icons.stack2x]"></i>
- <i [ngClass]="[icons.destroy, icons.stack1x]"></i>
- </span>
- </button>
- </div>
- </div>
<cd-configuration-details cdTableDetail
[selection]="selection">
</cd-configuration-details>
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,
}
},
{
- 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') {
- return true;
- }
-
+ filterOptions: ['mon'],
+ filterPredicate: (row, value) => {
if (!row.hasOwnProperty('source')) {
return false;
}
-
return row.source.includes(value);
}
}
);
}
- 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;