All files / src/app/ceph/cephfs/cephfs-list cephfs-list.component.ts

76.19% Statements 16/21
75% Branches 6/8
42.86% Functions 3/7
76.47% Lines 13/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 576x   6x   6x     6x             6x   1x 1x   1x   6x 1x                                     6x                     6x     6x  
import { Component, OnInit } from '@angular/core';
 
import { I18n } from '@ngx-translate/i18n-polyfill';
 
import { CephfsService } from '../../../shared/api/cephfs.service';
import { CdTableColumn } from '../../../shared/models/cd-table-column';
import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-data-context';
import { CdTableSelection } from '../../../shared/models/cd-table-selection';
 
@Component({
  selector: 'cd-cephfs-list',
  template: require('./cephfs-list.component.html'),
  styles: []
})
export class CephfsListComponent implements OnInit {
  columns: CdTableColumn[];
  filesystems: any = [];
  selection = new CdTableSelection();
 
  constructor(private cephfsService: CephfsService, private i18n: I18n) {}
 
  ngOnInit() {
    this.columns = [
      {
        name: this.i18n('Name'),
        prop: 'mdsmap.fs_name',
        flexGrow: 2
      },
      {
        name: this.i18n('Created'),
        prop: 'mdsmap.created',
        flexGrow: 2
      },
      {
        name: this.i18n('Enabled'),
        prop: 'mdsmap.enabled',
        flexGrow: 1
      }
    ];
  }
 
  loadFilesystems(context: CdTableFetchDataContext) {
    this.cephfsService.list().subscribe(
      (resp: any[]) => {
        this.filesystems = resp;
      },
      () => {
        context.error();
      }
    );
  }
 
  updateSelection(selection: CdTableSelection) {
    this.selection = selection;
  }
}