Skip to content
This repository has been archived by the owner on Mar 25, 2023. It is now read-only.

Commit

Permalink
feat(volume): Check if volume is ready before taking snapshot (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
wowshakhov authored and zolotyx committed Sep 19, 2017
1 parent b92225d commit 9d245fe
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/app/shared/models/volume.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export enum VolumeType {
DATADISK = 'DATADISK'
}

export enum VolumeState {
Allocated = 'Allocated',
Ready = 'Ready'
}

export const volumeTypeNames = {
[VolumeType.ROOT]: 'VOLUME_TYPE.ROOT',
[VolumeType.DATADISK]: 'VOLUME_TYPE.DATADISK'
Expand All @@ -40,7 +45,7 @@ export class Volume extends BaseModel {
public diskOfferingId: string;
public loading: boolean;
public name: string;
public state: string;
public state: VolumeState;
public size: number;
public virtualMachineId: string;
public provisioningType: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
<button md-mini-fab (click)="addSnapshot()">
<button
*ngIf="isVolumeReady"
md-mini-fab
(click)="addSnapshot()"
>
<md-icon>add</md-icon>
</button>

<cs-no-results
*ngIf="!isVolumeReady"
[text]="'SPARE_DRIVE_PAGE.SNAPSHOTS.VOLUME_NOT_READY'"
></cs-no-results>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input } from '@angular/core';
import { SpareDriveSnapshotAction } from '../../../../shared/actions/spare-drive-actions/spare-drive-snapshot';
import { Volume } from '../../../../shared/models/volume.model';
import { Volume, VolumeState } from '../../../../shared/models/volume.model';


@Component({
Expand All @@ -13,6 +13,10 @@ export class SpareDriveSnapshotCreationComponent {

constructor(private spareDriveSnapshotAction: SpareDriveSnapshotAction) {}

public get isVolumeReady(): boolean {
return this.volume && this.volume.state === VolumeState.Ready;
}

public addSnapshot(): void {
this.spareDriveSnapshotAction.activate(this.volume).subscribe();
}
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@
},
"SNAPSHOTS": {
"DESCRIPTION": "Description",
"DATE": "Date"
"DATE": "Date",
"VOLUME_NOT_READY": "Can't take snapshot. Volume is not ready"
},
"ATTACHMENT": {
"CHOOSE_VIRTUAL_MACHINE": "Choose a virtual machine",
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,8 @@
},
"SNAPSHOTS": {
"DESCRIPTION": "Описание",
"DATE": "Дата"
"DATE": "Дата",
"VOLUME_NOT_READY": "Невозможно сделать снимок. Диск не готов"
},
"ATTACHMENT": {
"CHOOSE_VIRTUAL_MACHINE": "Выберите машину",
Expand Down

0 comments on commit 9d245fe

Please sign in to comment.