# All files / src/app/ceph/cluster/osd/osd-scrub-modal osd-scrub-modal.component.ts

73.08% Statements 19/26
64.71% Branches 11/17
40% Functions 2/5
73.91% Lines 17/23

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

    7x
    7x

    7x
    7x
    7x

    7x

    1x

    1x
    1x
    1x
    1x

    7x
    1x

    7x

    7x
     import { Component, OnInit } from '@angular/core';
    import { FormGroup } from '@angular/forms';

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

    import { OsdService } from '../../../../shared/api/osd.service';
    import { NotificationType } from '../../../../shared/enum/notification-type.enum';
    import { NotificationService } from '../../../../shared/services/notification.service';

    @Component({
      selector: 'cd-osd-scrub-modal',
      template: require('./osd-scrub-modal.component.html'),
      styles: []
    })
    export class OsdScrubModalComponent implements OnInit {
      deep: boolean;
      selected = [];
      scrubForm: FormGroup;

      constructor(
        public bsModalRef: BsModalRef,
        private osdService: OsdService,
        private notificationService: NotificationService,
        private i18n: I18n
      ) {}

      ngOnInit() {
        this.scrubForm = new FormGroup({});
      }

      scrub() {
        const id = this.selected[0].id;

        this.osdService.scrub(id, this.deep).subscribe(
          () => {
            const operation = this.deep ? 'Deep scrub' : 'Scrub';

            this.notificationService.show(
              NotificationType.success,
              this.i18n('{{operation}} was initialized in the following OSD: {{id}}', {
                operation: operation,
                id: id
              })
            );

            this.bsModalRef.hide();
          },
          () => {
            this.bsModalRef.hide();
          }
        );
      }
    }