All files / src/app/ceph/cluster/osd/osd-details osd-details.component.ts

92.59% Statements 25/27
75% Branches 12/16
100% Functions 5/5
91.3% Lines 21/23

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 486x   6x   6x 6x   6x             6x   6x         19x 19x     6x 16x     16x           6x 2x 2x 2x 2x 1x 1x   2x     6x  
import { Component, Input, OnChanges } from '@angular/core';
 
import * as _ from 'lodash';
 
import { OsdService } from '../../../../shared/api/osd.service';
import { CdTableSelection } from '../../../../shared/models/cd-table-selection';
import { Permission } from '../../../../shared/models/permissions';
import { AuthStorageService } from '../../../../shared/services/auth-storage.service';
 
@Component({
  selector: 'cd-osd-details',
  template: require('./osd-details.component.html'),
  styles: []
})
export class OsdDetailsComponent implements OnChanges {
  @Input()
  selection: CdTableSelection;
 
  osd: any;
  grafanaPermission: Permission;
 
  constructor(private osdService: OsdService, private authStorageService: AuthStorageService) {
    this.grafanaPermission = this.authStorageService.getPermissions().grafana;
  }
 
  ngOnChanges() {
    this.osd = {
      loaded: false
    };
    Iif (this.selection.hasSelection) {
      this.osd = this.selection.first();
      this.refresh();
    }
  }
 
  refresh() {
    this.osdService.getDetails(this.osd.id).subscribe((data: any) => {
      this.osd.details = data;
      this.osd.histogram_failed = '';
      if (!_.isObject(data.histogram)) {
        this.osd.histogram_failed = data.histogram;
        this.osd.details.histogram = undefined;
      }
      this.osd.loaded = true;
    });
  }
}