1 import { Component, OnInit } from '@angular/core';
3 import { BsModalRef } from 'ngx-bootstrap/modal';
5 import { RbdService } from '../../../shared/api/rbd.service';
6 import { CdFormBuilder } from '../../../shared/forms/cd-form-builder';
7 import { CdFormGroup } from '../../../shared/forms/cd-form-group';
8 import { ExecutingTask } from '../../../shared/models/executing-task';
9 import { FinishedTask } from '../../../shared/models/finished-task';
10 import { ImageSpec } from '../../../shared/models/image-spec';
11 import { TaskWrapperService } from '../../../shared/services/task-wrapper.service';
14 selector: 'cd-rbd-trash-restore-modal',
15 templateUrl: './rbd-trash-restore-modal.component.html',
16 styleUrls: ['./rbd-trash-restore-modal.component.scss']
18 export class RbdTrashRestoreModalComponent implements OnInit {
24 executingTasks: ExecutingTask[];
26 restoreForm: CdFormGroup;
29 private rbdService: RbdService,
30 public modalRef: BsModalRef,
31 private fb: CdFormBuilder,
32 private taskWrapper: TaskWrapperService
36 this.imageSpec = new ImageSpec(this.poolName, this.namespace, this.imageName).toString();
37 this.restoreForm = this.fb.group({
43 const name = this.restoreForm.getValue('name');
44 const imageSpec = new ImageSpec(this.poolName, this.namespace, this.imageId);
48 task: new FinishedTask('rbd/trash/restore', {
49 image_id_spec: imageSpec.toString(),
52 call: this.rbdService.restoreTrash(imageSpec, name)
57 this.restoreForm.setErrors({ cdSubmitButton: true });