# All files / src/app/ceph/cluster/monitor monitor.component.ts

48.28% Statements 14/29
71.43% Branches 5/7
16.67% Functions 1/6
45.83% Lines 11/24

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

    6x

    6x
    6x

    6x

    1x

    1x
    1x

    1x

    6x

    6x
     import { Component } from '@angular/core';

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

    import { MonitorService } from '../../../shared/api/monitor.service';
    import { CellTemplate } from '../../../shared/enum/cell-template.enum';

    @Component({
      selector: 'cd-monitor',
      template: require('./monitor.component.html'),
      styles: []
    })
    export class MonitorComponent {
      mon_status: any;
      inQuorum: any;
      notInQuorum: any;

      interval: any;
      sparklineStyle = {
        height: '30px',
        width: '50%'
      };

      constructor(private monitorService: MonitorService, private i18n: I18n) {
        this.inQuorum = {
          columns: [
            { prop: 'name', name: this.i18n('Name'), cellTransformation: CellTemplate.routerLink },
            { prop: 'rank', name: this.i18n('Rank') },
            { prop: 'public_addr', name: this.i18n('Public Address') },
            {
              prop: 'cdOpenSessions',
              name: this.i18n('Open Sessions'),
              cellTransformation: CellTemplate.sparkline
            }
          ],
          data: []
        };

        this.notInQuorum = {
          columns: [
            { prop: 'name', name: this.i18n('Name'), cellTransformation: CellTemplate.routerLink },
            { prop: 'rank', name: this.i18n('Rank') },
            { prop: 'public_addr', name: this.i18n('Public Address') }
          ],
          data: []
        };
      }

      refresh() {
        this.monitorService.getMonitor().subscribe((data: any) => {
          data.in_quorum.map((row) => {
            row.cdOpenSessions = row.stats.num_sessions.map((i) => i[1]);
            row.cdLink = '/perf_counters/mon/' + row.name;
            row.cdParams = { fromLink: '/monitor' };
            return row;
          });

          data.out_quorum.map((row) => {
            row.cdLink = '/perf_counters/mon/' + row.name;
            row.cdParams = { fromLink: '/monitor' };
            return row;
          });

          this.inQuorum.data = [...data.in_quorum];
          this.notInQuorum.data = [...data.out_quorum];
          this.mon_status = data.mon_status;
        });
      }
    }