1 import { Component, OnInit } from '@angular/core';
3 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
5 import { RbdService } from '~/app/shared/api/rbd.service';
6 import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
7 import { CdFormBuilder } from '~/app/shared/forms/cd-form-builder';
8 import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
9 import { ExecutingTask } from '~/app/shared/models/executing-task';
10 import { FinishedTask } from '~/app/shared/models/finished-task';
11 import { ImageSpec } from '~/app/shared/models/image-spec';
12 import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
15 selector: 'cd-rbd-trash-restore-modal',
16 templateUrl: './rbd-trash-restore-modal.component.html',
17 styleUrls: ['./rbd-trash-restore-modal.component.scss']
19 export class RbdTrashRestoreModalComponent implements OnInit {
25 executingTasks: ExecutingTask[];
27 restoreForm: CdFormGroup;
30 private rbdService: RbdService,
31 public activeModal: NgbActiveModal,
32 public actionLabels: ActionLabelsI18n,
33 private fb: CdFormBuilder,
34 private taskWrapper: TaskWrapperService
38 this.imageSpec = new ImageSpec(this.poolName, this.namespace, this.imageName).toString();
39 this.restoreForm = this.fb.group({
45 const name = this.restoreForm.getValue('name');
46 const imageSpec = new ImageSpec(this.poolName, this.namespace, this.imageId);
50 task: new FinishedTask('rbd/trash/restore', {
51 image_id_spec: imageSpec.toString(),
54 call: this.rbdService.restoreTrash(imageSpec, name)
58 this.restoreForm.setErrors({ cdSubmitButton: true });
61 this.activeModal.close();