File

src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts

Implements

OnChanges OnInit

Metadata

selector cd-cephfs-detail
styleUrls ./cephfs-detail.component.scss
templateUrl ./cephfs-detail.component.html

Index

Properties
Methods
Inputs

Constructor

constructor(authStorageService: AuthStorageService, cephfsService: CephfsService, dimlessBinary: DimlessBinaryPipe, dimless: DimlessPipe, i18n: I18n)
Parameters :
Name Type Optional
authStorageService AuthStorageService No
cephfsService CephfsService No
dimlessBinary DimlessBinaryPipe No
dimless DimlessPipe No
i18n I18n No

Inputs

selection
Type : CdTableSelection

Methods

ngOnChanges
ngOnChanges()
Returns : void
ngOnInit
ngOnInit()
Returns : void
refresh
refresh()
Returns : void
trackByFn
trackByFn(_index, item)
Parameters :
Name Optional
_index No
item No
Returns : any

Properties

activityTmpl
Type : TemplateRef<any>
Decorators :
@ViewChild('activityTmpl')
clientCount
Type : number
clientsSelect
Default value : false
grafanaId
Type : any
grafanaPermission
Type : Permission
id
Type : number
mdsCounters
Type : object
Default value : {}
name
Type : string
objectValues
Default value : Object.values
pools
Type : any
poolUsageTpl
Type : TemplateRef<any>
Decorators :
@ViewChild('poolUsageTpl')
ranks
Type : any
selectedItem
Type : any
standbys
Type : []
Default value : []
import { Component, Input, OnChanges, OnInit, TemplateRef, ViewChild } from '@angular/core';

import { I18n } from '@ngx-translate/i18n-polyfill';
import * as _ from 'lodash';

import { CephfsService } from '../../../shared/api/cephfs.service';
import { CdTableSelection } from '../../../shared/models/cd-table-selection';
import { Permission } from '../../../shared/models/permissions';
import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe';
import { DimlessPipe } from '../../../shared/pipes/dimless.pipe';
import { AuthStorageService } from '../../../shared/services/auth-storage.service';

@Component({
  selector: 'cd-cephfs-detail',
  templateUrl: './cephfs-detail.component.html',
  styleUrls: ['./cephfs-detail.component.scss']
})
export class CephfsDetailComponent implements OnChanges, OnInit {
  @ViewChild('poolUsageTpl')
  poolUsageTpl: TemplateRef<any>;
  @ViewChild('activityTmpl')
  activityTmpl: TemplateRef<any>;

  @Input()
  selection: CdTableSelection;

  selectedItem: any;

  id: number;
  name: string;
  ranks: any;
  pools: any;
  standbys = [];
  clientCount: number;
  mdsCounters = {};
  grafanaId: any;
  grafanaPermission: Permission;

  objectValues = Object.values;
  clientsSelect = false;

  constructor(
    private authStorageService: AuthStorageService,
    private cephfsService: CephfsService,
    private dimlessBinary: DimlessBinaryPipe,
    private dimless: DimlessPipe,
    private i18n: I18n
  ) {
    this.grafanaPermission = this.authStorageService.getPermissions().grafana;
  }

  ngOnChanges() {
    if (this.selection.hasSelection) {
      this.selectedItem = this.selection.first();
      const mdsInfo: any[] = this.selectedItem.mdsmap.info;
      this.grafanaId = Object.values(mdsInfo)[0].name;

      if (this.id !== this.selectedItem.id) {
        this.id = this.selectedItem.id;
        this.ranks.data = [];
        this.pools.data = [];
        this.standbys = [];
        this.mdsCounters = {};
      }
    }
  }

  ngOnInit() {
    this.ranks = {
      columns: [
        { prop: 'rank', name: this.i18n('Rank') },
        { prop: 'state', name: this.i18n('State') },
        { prop: 'mds', name: this.i18n('Daemon') },
        { prop: 'activity', name: this.i18n('Activity'), cellTemplate: this.activityTmpl },
        { prop: 'dns', name: this.i18n('Dentries'), pipe: this.dimless },
        { prop: 'inos', name: this.i18n('Inodes'), pipe: this.dimless }
      ],
      data: []
    };

    this.pools = {
      columns: [
        { prop: 'pool', name: this.i18n('Pool') },
        { prop: 'type', name: this.i18n('Type') },
        { prop: 'size', name: this.i18n('Size'), pipe: this.dimlessBinary },
        {
          name: this.i18n('Usage'),
          cellTemplate: this.poolUsageTpl,
          comparator: (_valueA, _valueB, rowA, rowB) => {
            const valA = rowA.used / rowA.avail;
            const valB = rowB.used / rowB.avail;

            if (valA === valB) {
              return 0;
            }

            if (valA > valB) {
              return 1;
            } else {
              return -1;
            }
          }
        }
      ],
      data: []
    };
  }

  refresh() {
    this.cephfsService.getCephfs(this.id).subscribe((data: any) => {
      this.ranks.data = data.cephfs.ranks;
      this.pools.data = data.cephfs.pools;
      this.pools.data.forEach((pool) => {
        pool.size = pool.used + pool.avail;
      });
      this.standbys = [
        {
          key: this.i18n('Standby daemons'),
          value: data.standbys.map((value) => value.name).join(', ')
        }
      ];
      this.name = data.cephfs.name;
      this.clientCount = data.cephfs.client_count;
    });

    this.cephfsService.getMdsCounters(this.id).subscribe((data) => {
      _.each(this.mdsCounters, (_value, key) => {
        if (data[key] === undefined) {
          delete this.mdsCounters[key];
        }
      });

      _.each(data, (mdsData: any, mdsName) => {
        mdsData.name = mdsName;
        this.mdsCounters[mdsName] = mdsData;
      });
    });
  }

  trackByFn(_index, item) {
    return item.name;
  }
}
<tabset *ngIf="selectedItem">
  <tab i18n-heading
       heading="Details">
    <div class="row">
      <div class="col-sm-6">
        <legend i18n>Ranks</legend>

        <cd-table [data]="ranks.data"
                  [columns]="ranks.columns"
                  (fetchData)="refresh()"
                  [toolHeader]="false">
        </cd-table>

        <cd-table-key-value [data]="standbys">
        </cd-table-key-value>
      </div>

      <div class="col-sm-6">
        <legend i18n>Pools</legend>

        <cd-table [data]="pools.data"
                  [columns]="pools.columns"
                  [toolHeader]="false">
        </cd-table>
      </div>
    </div>

    <div class="row"
         *ngFor="let mdsCounter of objectValues(mdsCounters); trackBy: trackByFn">
      <div class="cold-md-12">
        <cd-cephfs-chart [mdsCounter]="mdsCounter"></cd-cephfs-chart>
      </div>
    </div>
  </tab>
  <tab i18n-heading
       heading="Clients: {{ clientCount }}"
       (select)="clientsSelect=true"
       (deselect)="clientsSelect=false">
    <cd-cephfs-clients [id]="id"
                       *ngIf="clientsSelect">
    </cd-cephfs-clients>
  </tab>
  <tab i18n-heading
       *ngIf="grafanaPermission.read"
       heading="Performance Details">
    <cd-grafana [grafanaPath]="'mds-performance?var-mds_servers=mds.' + grafanaId"
                uid="rRfFzWtik"
                grafanaStyle="one">
    </cd-grafana>
  </tab>
</tabset>

<!-- templates -->
<ng-template #poolUsageTpl
             let-row="row">
  <cd-usage-bar [totalBytes]="row.size"
                [usedBytes]="row.used"></cd-usage-bar>
</ng-template>

<ng-template #activityTmpl
             let-row="row"
             let-value="value">
  {{ row.state === 'standby-replay' ? 'Evts' : 'Reqs' }}: {{ value | dimless }} /s
</ng-template>

./cephfs-detail.component.scss

.progress {
  margin-bottom: 0px;
}
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""