All files / src/app/ceph/nfs/nfs-details nfs-details.component.ts

100% Statements 32/32
83.33% Branches 10/12
100% Functions 4/4
100% Lines 30/30

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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 746x   6x       6x             6x   6x           27x   27x 27x                                     6x 27x 5x   5x   5x 5x 5x 5x 10x   5x 5x 5x 5x 5x   5x 4x 4x 4x 4x   1x 1x       6x  
import { Component, Input, OnChanges } from '@angular/core';
 
import { I18n } from '@ngx-translate/i18n-polyfill';
import * as _ from 'lodash';
 
import { CdTableColumn } from '../../../shared/models/cd-table-column';
import { CdTableSelection } from '../../../shared/models/cd-table-selection';
 
@Component({
  selector: 'cd-nfs-details',
  template: require('./nfs-details.component.html'),
  styles: []
})
export class NfsDetailsComponent implements OnChanges {
  @Input()
  selection: CdTableSelection;
 
  selectedItem: any;
  data: any;
 
  clientsColumns: CdTableColumn[];
  clients = [];
 
  constructor(private i18n: I18n) {
    this.clientsColumns = [
      {
        name: this.i18n('Addresses'),
        prop: 'addresses',
        flexGrow: 2
      },
      {
        name: this.i18n('Access Type'),
        prop: 'access_type',
        flexGrow: 1
      },
      {
        name: this.i18n('Squash'),
        prop: 'squash',
        flexGrow: 1
      }
    ];
  }
 
  ngOnChanges() {
    if (this.selection.hasSelection) {
      this.selectedItem = this.selection.first();
 
      this.clients = this.selectedItem.clients;
 
      this.data = {};
      this.data[this.i18n('Cluster')] = this.selectedItem.cluster_id;
      this.data[this.i18n('Daemons')] = this.selectedItem.daemons;
      this.data[this.i18n('NFS Protocol')] = this.selectedItem.protocols.map(
        (protocol) => 'NFSv' + protocol
      );
      this.data[this.i18n('Pseudo')] = this.selectedItem.pseudo;
      this.data[this.i18n('Access Type')] = this.selectedItem.access_type;
      this.data[this.i18n('Squash')] = this.selectedItem.squash;
      this.data[this.i18n('Transport')] = this.selectedItem.transports;
      this.data[this.i18n('Path')] = this.selectedItem.path;
 
      if (this.selectedItem.fsal.name === 'CEPH') {
        this.data[this.i18n('Storage Backend')] = this.i18n('CephFS');
        this.data[this.i18n('CephFS User')] = this.selectedItem.fsal.user_id;
        this.data[this.i18n('CephFS Filesystem')] = this.selectedItem.fsal.fs_name;
        this.data[this.i18n('Security Label')] = this.selectedItem.fsal.sec_label_xattr;
      } else {
        this.data[this.i18n('Storage Backend')] = this.i18n('Object Gateway');
        this.data[this.i18n('Object Gateway User')] = this.selectedItem.fsal.rgw_user_id;
      }
    }
  }
}