]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.ts
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / block / rbd-configuration-list / rbd-configuration-list.component.ts
1 import { Component, Input, OnChanges, OnInit, TemplateRef, ViewChild } from '@angular/core';
2
3 import { I18n } from '@ngx-translate/i18n-polyfill';
4 import { TableComponent } from '../../../shared/datatable/table/table.component';
5 import { CdTableColumn } from '../../../shared/models/cd-table-column';
6 import {
7 RbdConfigurationEntry,
8 RbdConfigurationSourceField,
9 RbdConfigurationType
10 } from '../../../shared/models/configuration';
11 import { RbdConfigurationSourcePipe } from '../../../shared/pipes/rbd-configuration-source.pipe';
12 import { FormatterService } from '../../../shared/services/formatter.service';
13 import { RbdConfigurationService } from '../../../shared/services/rbd-configuration.service';
14
15 @Component({
16 selector: 'cd-rbd-configuration-table',
17 templateUrl: './rbd-configuration-list.component.html',
18 styleUrls: ['./rbd-configuration-list.component.scss']
19 })
20 export class RbdConfigurationListComponent implements OnInit, OnChanges {
21 @Input()
22 data: RbdConfigurationEntry[];
23 poolConfigurationColumns: CdTableColumn[];
24 @ViewChild('configurationSourceTpl')
25 configurationSourceTpl: TemplateRef<any>;
26 @ViewChild('configurationValueTpl')
27 configurationValueTpl: TemplateRef<any>;
28 @ViewChild('poolConfTable')
29 poolConfTable: TableComponent;
30
31 readonly sourceField = RbdConfigurationSourceField;
32 readonly typeField = RbdConfigurationType;
33
34 constructor(
35 public formatterService: FormatterService,
36 private rbdConfigurationService: RbdConfigurationService,
37 private i18n: I18n
38 ) {}
39
40 ngOnInit() {
41 this.poolConfigurationColumns = [
42 { prop: 'displayName', name: this.i18n('Name') },
43 { prop: 'description', name: this.i18n('Description') },
44 { prop: 'name', name: this.i18n('Key') },
45 {
46 prop: 'source',
47 name: this.i18n('Source'),
48 cellTemplate: this.configurationSourceTpl,
49 pipe: new RbdConfigurationSourcePipe()
50 },
51 { prop: 'value', name: this.i18n('Value'), cellTemplate: this.configurationValueTpl }
52 ];
53 }
54
55 ngOnChanges(): void {
56 if (!this.data) {
57 return;
58 }
59 // Filter settings out which are not listed in RbdConfigurationService
60 this.data = this.data.filter((row) =>
61 this.rbdConfigurationService
62 .getOptionFields()
63 .map((o) => o.name)
64 .includes(row.name)
65 );
66 }
67 }