]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/blob
b2f636708b97063c4508873a0dc94a22a7925097
[ceph-ci.git] /
1 import { Component, OnInit } from '@angular/core';
2 import { FormGroup } from '@angular/forms';
3
4 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
5 import { forkJoin } from 'rxjs';
6
7 import { OsdService } from '~/app/shared/api/osd.service';
8 import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
9 import { NotificationType } from '~/app/shared/enum/notification-type.enum';
10 import { JoinPipe } from '~/app/shared/pipes/join.pipe';
11 import { NotificationService } from '~/app/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 activeModal: NgbActiveModal,
25     public actionLabels: ActionLabelsI18n,
26     private osdService: OsdService,
27     private notificationService: NotificationService,
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           $localize`${operation} was initialized in the following OSD(s): ${this.joinPipe.transform(
43             this.selected
44           )}`
45         );
46
47         this.activeModal.close();
48       },
49       () => this.activeModal.close()
50     );
51   }
52 }