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

92.31% Statements 24/26
72.73% Branches 16/22
80% Functions 4/5
90.91% Lines 20/22

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 74 75 76 77 784x   4x 4x 4x   4x   4x   4x             4x 43x     4x   4x   4x   4x     43x 43x                                                                   33x 33x             4x 13x   4x  
import { Component, Input, OnChanges, ViewChild } from '@angular/core';
 
import { I18n } from '@ngx-translate/i18n-polyfill';
import * as _ from 'lodash';
import { TabsetComponent } from 'ngx-bootstrap/tabs';
 
import { PoolService } from '../../../shared/api/pool.service';
import { CdTableColumn } from '../../../shared/models/cd-table-column';
import { CdTableSelection } from '../../../shared/models/cd-table-selection';
import { RbdConfigurationEntry } from '../../../shared/models/configuration';
import { Permissions } from '../../../shared/models/permissions';
 
@Component({
  selector: 'cd-pool-details',
  template: require('./pool-details.component.html'),
  styles: []
})
export class PoolDetailsComponent implements OnChanges {
  cacheTierColumns: Array<CdTableColumn> = [];
 
  @Input()
  selection: CdTableSelection;
  @Input()
  permissions: Permissions;
  @Input()
  cacheTiers: any[];
  @ViewChild(TabsetComponent)
  tabsetChild: TabsetComponent;
  selectedPoolConfiguration: RbdConfigurationEntry[];
 
  constructor(private i18n: I18n, private poolService: PoolService) {
    this.cacheTierColumns = [
      {
        prop: 'pool_name',
        name: this.i18n('Name'),
        flexGrow: 3
      },
      {
        prop: 'cache_mode',
        name: this.i18n('Cache Mode'),
        flexGrow: 2
      },
      {
        prop: 'cache_min_evict_age',
        name: this.i18n('Min Evict Age'),
        flexGrow: 2
      },
      {
        prop: 'cache_min_flush_age',
        name: this.i18n('Min Flush Age'),
        flexGrow: 2
      },
      {
        prop: 'target_max_bytes',
        name: this.i18n('Target Max Bytes'),
        flexGrow: 2
      },
      {
        prop: 'target_max_objects',
        name: this.i18n('Target Max Objects'),
        flexGrow: 2
      }
    ];
  }
 
  ngOnChanges() {
    Iif (this.selection.hasSingleSelection) {
      this.poolService.getConfiguration(this.selection.first().pool_name).subscribe((poolConf) => {
        this.selectedPoolConfiguration = poolConf;
      });
    }
  }
 
  filterNonPoolData(pool: object): object {
    return _.omit(pool, ['cdExecuting', 'cdIsBinary']);
  }
}