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

86.21% Statements 25/29
68.75% Branches 11/16
80% Functions 4/5
84% Lines 21/25

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
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    984x

    4x

    4x

    4x

    4x

    4x

    4x

    2x

    2x

    2x

    2x

    4x
    2x

    2x

    2x

    2x

    2x

    4x

    4x
    6x

    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';

    @Component({
      selector: 'cd-mirroring-images',
      template: require('./image-list.component.html'),
      styles: []
    })
    export class ImageListComponent implements OnInit, OnDestroy {
      @ViewChild('stateTmpl')
      stateTmpl: TemplateRef<any>;
      @ViewChild('syncTmpl')
      syncTmpl: TemplateRef<any>;
      @ViewChild('progressTmpl')
      progressTmpl: TemplateRef<any>;

      subs: Subscription;

      image_error = {
        data: [],
        columns: {}
      };
      image_syncing = {
        data: [],
        columns: {}
      };
      image_ready = {
        data: [],
        columns: {}
      };

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

      ngOnInit() {
        this.image_error.columns = [
          { prop: 'pool_name', name: this.i18n('Pool'), flexGrow: 2 },
          { prop: 'name', name: this.i18n('Image'), flexGrow: 2 },
          { prop: 'description', name: this.i18n('Issue'), flexGrow: 4 },
          {
            prop: 'state',
            name: this.i18n('State'),
            cellTemplate: this.stateTmpl,
            flexGrow: 1
          }
        ];

        this.image_syncing.columns = [
          { prop: 'pool_name', name: this.i18n('Pool'), flexGrow: 2 },
          { prop: 'name', name: this.i18n('Image'), flexGrow: 2 },
          {
            prop: 'progress',
            name: this.i18n('Progress'),
            cellTemplate: this.progressTmpl,
            flexGrow: 2
          },
          {
            prop: 'state',
            name: this.i18n('State'),
            cellTemplate: this.syncTmpl,
            flexGrow: 1
          }
        ];

        this.image_ready.columns = [
          { prop: 'pool_name', name: this.i18n('Pool'), flexGrow: 2 },
          { prop: 'name', name: this.i18n('Image'), flexGrow: 2 },
          { prop: 'description', name: this.i18n('Description'), flexGrow: 4 },
          {
            prop: 'state',
            name: this.i18n('State'),
            cellTemplate: this.stateTmpl,
            flexGrow: 1
          }
        ];

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

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

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