# All files / src/app/ceph/block/mirroring/daemon-list daemon-list.component.ts

90.91% Statements 20/22
71.43% Branches 10/14
80% Functions 4/5
89.47% Lines 17/19

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
    644x

    4x

    4x
    4x

    4x

    4x

    2x
    2x
    2x

    4x
    2x

    2x

    2x

    4x

    4x
    2x

    4x
     import { Component, OnDestroy, OnInit, TemplateRef, ViewChild } from '@angular/core';

    import { I18n } from '@ngx-translate/i18n-polyfill';
    import { Subscription } from 'rxjs';

    import { RbdMirroringService } from '../../../../shared/api/rbd-mirroring.service';
    import { CephShortVersionPipe } from '../../../../shared/pipes/ceph-short-version.pipe';

    @Component({
      selector: 'cd-mirroring-daemons',
      template: require('./daemon-list.component.html'),
      styles: []
    })
    export class DaemonListComponent implements OnInit, OnDestroy {
      @ViewChild('healthTmpl')
      healthTmpl: TemplateRef<any>;

      subs: Subscription;

      data: [];
      columns: {};

      constructor(
        private rbdMirroringService: RbdMirroringService,
        private cephShortVersionPipe: CephShortVersionPipe,
        private i18n: I18n
      ) {}

      ngOnInit() {
        this.columns = [
          { prop: 'instance_id', name: this.i18n('Instance'), flexGrow: 2 },
          { prop: 'id', name: this.i18n('ID'), flexGrow: 2 },
          { prop: 'server_hostname', name: this.i18n('Hostname'), flexGrow: 2 },
          {
            prop: 'version',
            name: this.i18n('Version'),
            pipe: this.cephShortVersionPipe,
            flexGrow: 2
          },
          {
            prop: 'health',
            name: this.i18n('Health'),
            cellTemplate: this.healthTmpl,
            flexGrow: 1
          }
        ];

        this.subs = this.rbdMirroringService.subscribeSummary((data: any) => {
          if (!data) {
            return;
          }
          this.data = data.content_data.daemons;
        });
      }

      ngOnDestroy(): void {
        this.subs.unsubscribe();
      }

      refresh() {
        this.rbdMirroringService.refresh();
      }
    }