File
Implements
Metadata
selector |
cd-osd-scrub-modal |
styleUrls |
./osd-scrub-modal.component.scss |
templateUrl |
./osd-scrub-modal.component.html |
Public
bsModalRef
|
Type : BsModalRef
|
|
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>
Legend
Html element with directive