File

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

Implements

OnInit

Metadata

selector cd-osd-scrub-modal
styleUrls ./osd-scrub-modal.component.scss
templateUrl ./osd-scrub-modal.component.html

Index

Properties
Methods

Constructor

constructor(bsModalRef: BsModalRef, osdService: OsdService, notificationService: NotificationService, i18n: I18n)
Parameters :
Name Type Optional
bsModalRef BsModalRef No
osdService OsdService No
notificationService NotificationService No
i18n I18n No

Methods

ngOnInit
ngOnInit()
Returns : void
scrub
scrub()
Returns : void

Properties

Public bsModalRef
Type : BsModalRef
deep
Type : boolean
scrubForm
Type : FormGroup
selected
Type : []
Default value : []
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',
  templateUrl: './osd-scrub-modal.component.html',
  styleUrls: ['./osd-scrub-modal.component.scss']
})
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();
      }
    );
  }
}
<cd-modal [modalRef]="bsModalRef">
  <ng-container class="modal-title"
                i18n>OSDs {deep, select, 1 {Deep }}Scrub</ng-container>

  <ng-container class="modal-content">
    <form name="scrubForm"
          class="form-horizontal"
          #formDir="ngForm"
          [formGroup]="scrubForm"
          novalidate>
      <div class="modal-body">
        <div *ngIf="selected.length === 1">
          <p i18n>You are about to apply a {deep, select, 1 {deep }}scrub to
            the OSD <strong>{{ selected[0].id }}</strong>.</p>
        </div>
      </div>

      <div class="modal-footer">
        <cd-submit-button (submitAction)="scrub()"
                          [form]="scrubForm"
                          i18n>Submit</cd-submit-button>
        <cd-back-button [back]="bsModalRef.hide"
                        name="Cancel"
                        i18n-name>
        </cd-back-button>
      </div>
    </form>
  </ng-container>
</cd-modal>

./osd-scrub-modal.component.scss

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""