1 import { Component, OnInit } from '@angular/core';
3 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
5 import { Pool } from '~/app/ceph/pool/pool';
6 import { PoolService } from '~/app/shared/api/pool.service';
7 import { RbdService } from '~/app/shared/api/rbd.service';
8 import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
9 import { CdFormBuilder } from '~/app/shared/forms/cd-form-builder';
10 import { CdFormGroup } from '~/app/shared/forms/cd-form-group';
11 import { FinishedTask } from '~/app/shared/models/finished-task';
12 import { Permission } from '~/app/shared/models/permissions';
13 import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
14 import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service';
17 selector: 'cd-rbd-trash-purge-modal',
18 templateUrl: './rbd-trash-purge-modal.component.html',
19 styleUrls: ['./rbd-trash-purge-modal.component.scss']
21 export class RbdTrashPurgeModalComponent implements OnInit {
22 poolPermission: Permission;
23 purgeForm: CdFormGroup;
27 private authStorageService: AuthStorageService,
28 private rbdService: RbdService,
29 public activeModal: NgbActiveModal,
30 public actionLabels: ActionLabelsI18n,
31 private fb: CdFormBuilder,
32 private poolService: PoolService,
33 private taskWrapper: TaskWrapperService
35 this.poolPermission = this.authStorageService.getPermissions().pool;
39 this.purgeForm = this.fb.group({
45 if (this.poolPermission.read) {
46 this.poolService.list(['pool_name', 'application_metadata']).then((resp) => {
48 .filter((pool: Pool) => pool.application_metadata.includes('rbd'))
49 .map((pool: Pool) => pool.pool_name);
57 const poolName = this.purgeForm.getValue('poolName') || '';
60 task: new FinishedTask('rbd/trash/purge', {
63 call: this.rbdService.purgeTrash(poolName)
67 this.purgeForm.setErrors({ cdSubmitButton: true });
70 this.activeModal.close();