]> git.proxmox.com Git - ceph.git/blame - 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
CommitLineData
11fdf7f2
TL
1import { Component, OnInit } from '@angular/core';
2import { FormGroup } from '@angular/forms';
3
4import { I18n } from '@ngx-translate/i18n-polyfill';
5import { BsModalRef } from 'ngx-bootstrap/modal';
9f95a23c 6import { forkJoin } from 'rxjs';
11fdf7f2
TL
7
8import { OsdService } from '../../../../shared/api/osd.service';
9import { NotificationType } from '../../../../shared/enum/notification-type.enum';
9f95a23c 10import { JoinPipe } from '../../../../shared/pipes/join.pipe';
11fdf7f2
TL
11import { 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})
18export class OsdScrubModalComponent implements OnInit {
19 deep: boolean;
11fdf7f2 20 scrubForm: FormGroup;
9f95a23c 21 selected: any[] = [];
11fdf7f2
TL
22
23 constructor(
24 public bsModalRef: BsModalRef,
25 private osdService: OsdService,
26 private notificationService: NotificationService,
9f95a23c
TL
27 private i18n: I18n,
28 private joinPipe: JoinPipe
11fdf7f2
TL
29 ) {}
30
31 ngOnInit() {
32 this.scrubForm = new FormGroup({});
33 }
34
35 scrub() {
9f95a23c 36 forkJoin(this.selected.map((id: any) => this.osdService.scrub(id, this.deep))).subscribe(
11fdf7f2
TL
37 () => {
38 const operation = this.deep ? 'Deep scrub' : 'Scrub';
39
40 this.notificationService.show(
41 NotificationType.success,
9f95a23c 42 this.i18n('{{operation}} was initialized in the following OSD(s): {{id}}', {
11fdf7f2 43 operation: operation,
9f95a23c 44 id: this.joinPipe.transform(this.selected)
11fdf7f2
TL
45 })
46 );
47
48 this.bsModalRef.hide();
49 },
9f95a23c 50 () => this.bsModalRef.hide()
11fdf7f2
TL
51 );
52 }
53}