]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-scrub-modal/osd-scrub-modal.component.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / osd / osd-scrub-modal / osd-scrub-modal.component.ts
1 import { Component, OnInit } from '@angular/core';
2 import { FormGroup } from '@angular/forms';
3
4 import { I18n } from '@ngx-translate/i18n-polyfill';
5 import { BsModalRef } from 'ngx-bootstrap/modal';
6 import { forkJoin } from 'rxjs';
7
8 import { OsdService } from '../../../../shared/api/osd.service';
9 import { NotificationType } from '../../../../shared/enum/notification-type.enum';
10 import { JoinPipe } from '../../../../shared/pipes/join.pipe';
11 import { NotificationService } from '../../../../shared/services/notification.service';
12
13 @Component({
14 selector: 'cd-osd-scrub-modal',
15 templateUrl: './osd-scrub-modal.component.html',
16 styleUrls: ['./osd-scrub-modal.component.scss']
17 })
18 export class OsdScrubModalComponent implements OnInit {
19 deep: boolean;
20 scrubForm: FormGroup;
21 selected: any[] = [];
22
23 constructor(
24 public bsModalRef: BsModalRef,
25 private osdService: OsdService,
26 private notificationService: NotificationService,
27 private i18n: I18n,
28 private joinPipe: JoinPipe
29 ) {}
30
31 ngOnInit() {
32 this.scrubForm = new FormGroup({});
33 }
34
35 scrub() {
36 forkJoin(this.selected.map((id: any) => this.osdService.scrub(id, this.deep))).subscribe(
37 () => {
38 const operation = this.deep ? 'Deep scrub' : 'Scrub';
39
40 this.notificationService.show(
41 NotificationType.success,
42 this.i18n('{{operation}} was initialized in the following OSD(s): {{id}}', {
43 operation: operation,
44 id: this.joinPipe.transform(this.selected)
45 })
46 );
47
48 this.bsModalRef.hide();
49 },
50 () => this.bsModalRef.hide()
51 );
52 }
53 }