1 import { Component, OnInit } from '@angular/core';
3 import { BsModalRef } from 'ngx-bootstrap/modal';
5 import { PoolService } from '../../../shared/api/pool.service';
6 import { RbdService } from '../../../shared/api/rbd.service';
7 import { CdFormBuilder } from '../../../shared/forms/cd-form-builder';
8 import { CdFormGroup } from '../../../shared/forms/cd-form-group';
9 import { FinishedTask } from '../../../shared/models/finished-task';
10 import { Permission } from '../../../shared/models/permissions';
11 import { AuthStorageService } from '../../../shared/services/auth-storage.service';
12 import { TaskWrapperService } from '../../../shared/services/task-wrapper.service';
13 import { Pool } from '../../pool/pool';
16 selector: 'cd-rbd-trash-purge-modal',
17 templateUrl: './rbd-trash-purge-modal.component.html',
18 styleUrls: ['./rbd-trash-purge-modal.component.scss']
20 export class RbdTrashPurgeModalComponent implements OnInit {
21 poolPermission: Permission;
22 purgeForm: CdFormGroup;
26 private authStorageService: AuthStorageService,
27 private rbdService: RbdService,
28 public modalRef: BsModalRef,
29 private fb: CdFormBuilder,
30 private poolService: PoolService,
31 private taskWrapper: TaskWrapperService
33 this.poolPermission = this.authStorageService.getPermissions().pool;
37 this.purgeForm = this.fb.group({
43 if (this.poolPermission.read) {
44 this.poolService.list(['pool_name', 'application_metadata']).then((resp) => {
46 .filter((pool: Pool) => pool.application_metadata.includes('rbd'))
47 .map((pool: Pool) => pool.pool_name);
55 const poolName = this.purgeForm.getValue('poolName') || '';
58 task: new FinishedTask('rbd/trash/purge', {
61 call: this.rbdService.purgeTrash(poolName)
65 this.purgeForm.setErrors({ cdSubmitButton: true });