1 import { Component, Input, OnChanges, OnInit, ViewChild } from '@angular/core';
2 import { Observable, of } from 'rxjs';
3 import { catchError } from 'rxjs/operators';
4 import { CephfsSubvolumeService } from '~/app/shared/api/cephfs-subvolume.service';
5 import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
6 import { Icons } from '~/app/shared/enum/icons.enum';
7 import { CdTableColumn } from '~/app/shared/models/cd-table-column';
8 import { CdTableFetchDataContext } from '~/app/shared/models/cd-table-fetch-data-context';
9 import { CdTableSelection } from '~/app/shared/models/cd-table-selection';
10 import { CephfsSubvolume } from '~/app/shared/models/cephfs-subvolume.model';
13 selector: 'cd-cephfs-subvolume-list',
14 templateUrl: './cephfs-subvolume-list.component.html',
15 styleUrls: ['./cephfs-subvolume-list.component.scss']
17 export class CephfsSubvolumeListComponent implements OnInit, OnChanges {
18 @ViewChild('quotaUsageTpl', { static: true })
21 @ViewChild('typeTpl', { static: true })
24 @ViewChild('modeToHumanReadableTpl', { static: true })
25 modeToHumanReadableTpl: any;
27 @ViewChild('nameTpl', { static: true })
30 @ViewChild('quotaSizeTpl', { static: true })
33 @Input() fsName: string;
35 columns: CdTableColumn[] = [];
36 context: CdTableFetchDataContext;
37 selection = new CdTableSelection();
40 subVolumes$: Observable<CephfsSubvolume[]>;
42 constructor(private cephfsSubVolume: CephfsSubvolumeService) {}
47 name: $localize`Name`,
50 cellTemplate: this.nameTpl
53 name: $localize`Data Pool`,
54 prop: 'info.data_pool',
56 cellTransformation: CellTemplate.badge,
57 customTemplateConfig: {
58 class: 'badge-background-primary'
62 name: $localize`Usage`,
63 prop: 'info.bytes_pcent',
65 cellTemplate: this.quotaUsageTpl,
66 cellClass: 'text-right'
69 name: $localize`Path`,
72 cellTransformation: CellTemplate.path
75 name: $localize`Mode`,
78 cellTemplate: this.modeToHumanReadableTpl
81 name: $localize`Created`,
82 prop: 'info.created_at',
84 cellTransformation: CellTemplate.timeAgo
90 this.subVolumes$ = this.cephfsSubVolume.get(this.fsName).pipe(
98 updateSelection(selection: CdTableSelection) {
99 this.selection = selection;