File

src/app/ceph/block/rbd-trash-restore-modal/rbd-trash-restore-modal.component.ts

Implements

OnInit

Metadata

selector cd-rbd-trash-restore-modal
styleUrls ./rbd-trash-restore-modal.component.scss
templateUrl ./rbd-trash-restore-modal.component.html

Index

Properties
Methods

Constructor

constructor(rbdService: RbdService, modalRef: BsModalRef, fb: CdFormBuilder, taskWrapper: TaskWrapperService)
Parameters :
Name Type Optional
rbdService RbdService No
modalRef BsModalRef No
fb CdFormBuilder No
taskWrapper TaskWrapperService No

Methods

ngOnInit
ngOnInit()
Returns : void
restore
restore()
Returns : void

Properties

executingTasks
Type : ExecutingTask[]
imageId
Type : string
imageName
Type : string
metaType
Type : string
Public modalRef
Type : BsModalRef
poolName
Type : string
restoreForm
Type : CdFormGroup
import { Component, OnInit } from '@angular/core';

import { BsModalRef } from 'ngx-bootstrap/modal';

import { RbdService } from '../../../shared/api/rbd.service';
import { CdFormBuilder } from '../../../shared/forms/cd-form-builder';
import { CdFormGroup } from '../../../shared/forms/cd-form-group';
import { ExecutingTask } from '../../../shared/models/executing-task';
import { FinishedTask } from '../../../shared/models/finished-task';
import { TaskWrapperService } from '../../../shared/services/task-wrapper.service';

@Component({
  selector: 'cd-rbd-trash-restore-modal',
  templateUrl: './rbd-trash-restore-modal.component.html',
  styleUrls: ['./rbd-trash-restore-modal.component.scss']
})
export class RbdTrashRestoreModalComponent implements OnInit {
  metaType: string;
  poolName: string;
  imageName: string;
  imageId: string;
  executingTasks: ExecutingTask[];

  restoreForm: CdFormGroup;

  constructor(
    private rbdService: RbdService,
    public modalRef: BsModalRef,
    private fb: CdFormBuilder,
    private taskWrapper: TaskWrapperService
  ) {}

  ngOnInit() {
    this.restoreForm = this.fb.group({
      name: this.imageName
    });
  }

  restore() {
    const name = this.restoreForm.getValue('name');

    this.taskWrapper
      .wrapTaskAroundCall({
        task: new FinishedTask('rbd/trash/restore', {
          pool_name: this.poolName,
          image_id: this.imageId,
          new_image_name: name
        }),
        call: this.rbdService.restoreTrash(this.poolName, this.imageId, name)
      })
      .subscribe(
        undefined,
        () => {
          this.restoreForm.setErrors({ cdSubmitButton: true });
        },
        () => {
          this.modalRef.hide();
        }
      );
  }
}
<cd-modal>
  <ng-container i18n
                class="modal-title">Restore Image</ng-container>

  <ng-container class="modal-content">
    <form name="restoreForm"
          class="form"
          #formDir="ngForm"
          [formGroup]="restoreForm"
          novalidate>
      <div class="modal-body">
        <p>
          <ng-container i18n>To restore</ng-container>&nbsp;
          <kbd>{{ poolName }}/{{ imageName }}@{{ imageId }}</kbd>,&nbsp;
          <ng-container i18n>type the image's new name and click</ng-container>&nbsp;
          <kbd i18n>Restore Image</kbd>.
        </p>

        <div class="form-group"
             [ngClass]="{'has-error': restoreForm.showError('name', formDir)}">
          <label for="name"
                 i18n>New Name</label>
          <input type="text"
                 class="form-control"
                 name="name"
                 id="name"
                 autocomplete="off"
                 formControlName="name"
                 autofocus>
          <span class="help-block"
                *ngIf="restoreForm.showError('name', formDir, 'required')"
                i18n>This field is required.</span>
        </div>
      </div>

      <div class="modal-footer">
        <div class="button-group text-right">
          <cd-submit-button [form]="restoreForm"
                            (submitAction)="restore()"
                            i18n>Restore Image</cd-submit-button>
          <cd-back-button [back]="modalRef.hide"
                          name="Cancel"
                          i18n-name>
          </cd-back-button>
        </div>
      </div>
    </form>
  </ng-container>
</cd-modal>

./rbd-trash-restore-modal.component.scss

Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""