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

80% Statements 20/25
73.33% Branches 11/15
20% Functions 1/5
81.82% Lines 18/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
    661x

    1x

    1x

    1x

    1x
    1x

    1x
    1x
    1x
    1x

    1x
    1x

    1x

    1x
    1x

    1x

    1x

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

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

    import { RgwDaemonService } from '../../../shared/api/rgw-daemon.service';
    import { CdTableColumn } from '../../../shared/models/cd-table-column';
    import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-data-context';
    import { CdTableSelection } from '../../../shared/models/cd-table-selection';
    import { Permission } from '../../../shared/models/permissions';
    import { CephShortVersionPipe } from '../../../shared/pipes/ceph-short-version.pipe';
    import { AuthStorageService } from '../../../shared/services/auth-storage.service';

    @Component({
      selector: 'cd-rgw-daemon-list',
      template: require('./rgw-daemon-list.component.html'),
      styles: []
    })
    export class RgwDaemonListComponent {
      columns: CdTableColumn[] = [];
      daemons: object[] = [];
      selection: CdTableSelection = new CdTableSelection();
      grafanaPermission: Permission;

      constructor(
        private rgwDaemonService: RgwDaemonService,
        private authStorageService: AuthStorageService,
        cephShortVersionPipe: CephShortVersionPipe,
        private i18n: I18n
      ) {
        this.grafanaPermission = this.authStorageService.getPermissions().grafana;
        this.columns = [
          {
            name: this.i18n('ID'),
            prop: 'id',
            flexGrow: 2
          },
          {
            name: this.i18n('Hostname'),
            prop: 'server_hostname',
            flexGrow: 2
          },
          {
            name: this.i18n('Version'),
            prop: 'version',
            flexGrow: 1,
            pipe: cephShortVersionPipe
          }
        ];
      }

      getDaemonList(context: CdTableFetchDataContext) {
        this.rgwDaemonService.list().subscribe(
          (resp: object[]) => {
            this.daemons = resp;
          },
          () => {
            context.error();
          }
        );
      }

      updateSelection(selection: CdTableSelection) {
        this.selection = selection;
      }
    }