]>
Commit | Line | Data |
---|---|---|
1 | import { Component, OnInit } from '@angular/core'; | |
2 | ||
3 | import { I18n } from '@ngx-translate/i18n-polyfill'; | |
4 | ||
5 | import { CephfsService } from '../../../shared/api/cephfs.service'; | |
6 | import { ListWithDetails } from '../../../shared/classes/list-with-details.class'; | |
7 | import { CellTemplate } from '../../../shared/enum/cell-template.enum'; | |
8 | import { CdTableColumn } from '../../../shared/models/cd-table-column'; | |
9 | import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-data-context'; | |
10 | import { CdTableSelection } from '../../../shared/models/cd-table-selection'; | |
11 | import { CdDatePipe } from '../../../shared/pipes/cd-date.pipe'; | |
12 | ||
13 | @Component({ | |
14 | selector: 'cd-cephfs-list', | |
15 | templateUrl: './cephfs-list.component.html', | |
16 | styleUrls: ['./cephfs-list.component.scss'] | |
17 | }) | |
18 | export class CephfsListComponent extends ListWithDetails implements OnInit { | |
19 | columns: CdTableColumn[]; | |
20 | filesystems: any = []; | |
21 | selection = new CdTableSelection(); | |
22 | ||
23 | constructor( | |
24 | private cephfsService: CephfsService, | |
25 | private cdDatePipe: CdDatePipe, | |
26 | private i18n: I18n | |
27 | ) { | |
28 | super(); | |
29 | } | |
30 | ||
31 | ngOnInit() { | |
32 | this.columns = [ | |
33 | { | |
34 | name: this.i18n('Name'), | |
35 | prop: 'mdsmap.fs_name', | |
36 | flexGrow: 2 | |
37 | }, | |
38 | { | |
39 | name: this.i18n('Created'), | |
40 | prop: 'mdsmap.created', | |
41 | flexGrow: 2, | |
42 | pipe: this.cdDatePipe | |
43 | }, | |
44 | { | |
45 | name: this.i18n('Enabled'), | |
46 | prop: 'mdsmap.enabled', | |
47 | flexGrow: 1, | |
48 | cellTransformation: CellTemplate.checkIcon | |
49 | } | |
50 | ]; | |
51 | } | |
52 | ||
53 | loadFilesystems(context: CdTableFetchDataContext) { | |
54 | this.cephfsService.list().subscribe( | |
55 | (resp: any[]) => { | |
56 | this.filesystems = resp; | |
57 | }, | |
58 | () => { | |
59 | context.error(); | |
60 | } | |
61 | ); | |
62 | } | |
63 | ||
64 | updateSelection(selection: CdTableSelection) { | |
65 | this.selection = selection; | |
66 | } | |
67 | } |