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

Commit

Permalink
fix(spare-drive-actions): Add missing actions to spare drives
Browse files Browse the repository at this point in the history
  • Loading branch information
wowshakhov committed Aug 31, 2017
1 parent 583c8bc commit b1eb1cf
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,24 @@ import { SpareDriveAttachAction } from './spare-drive-attach';
import { SpareDriveRemoveAction } from './spare-drive-remove';
import { SpareDriveResizeAction } from './spare-drive-resize';
import { SpareDriveDetachAction } from './spare-drive-detach';
import { SpareDriveSnapshotAction } from './spare-drive-snapshot';
import { SpareDriveRecurringSnapshotsAction } from './spare-drive-recurring-snapshots';


@Injectable()
export class SpareDriveActionsService implements ActionsService<Volume, Action<Volume>> {
public actions = [
this.spareDriveSnapshotAction,
this.spareDriveRecurringSnapshotsAction,
this.spareDriveAttachAction,
this.spareDriveDetachAction,
this.spareDriveResizeAction,
this.spareDriveRemoveAction
];

constructor(
public spareDriveSnapshotAction: SpareDriveSnapshotAction,
public spareDriveRecurringSnapshotsAction: SpareDriveRecurringSnapshotsAction,
public spareDriveAttachAction: SpareDriveAttachAction,
public spareDriveDetachAction: SpareDriveDetachAction,
public spareDriveResizeAction: SpareDriveResizeAction,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Volume } from '../../models/volume.model';
import { SpareDriveAttachmentComponent } from '../../../spare-drive/spare-drive-attachment/spare-drive-attachment.component';
import {
SpareDriveAttachmentComponent
} from './spare-drive-attachment/spare-drive-attachment.component';
import { SpareDriveAction } from './spare-drive-action';


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Component, Inject, OnInit } from '@angular/core';
import { MD_DIALOG_DATA, MdDialogRef } from '@angular/material';
import { Observable } from 'rxjs/Observable';
import { DialogService } from '../../dialog/dialog-service/dialog.service';
import { Volume } from '../../shared/models';
import { JobsNotificationService } from '../../shared/services/jobs-notification.service';
import { VolumeService } from '../../shared/services/volume.service';
import { VirtualMachine } from '../../vm/shared/vm.model';
import { VmService } from '../../vm/shared/vm.service';
import { DialogService } from '../../../../dialog/dialog-service/dialog.service';
import { Volume } from '../../../models';
import { JobsNotificationService } from '../../../services/jobs-notification.service';
import { VolumeService } from '../../../services/volume.service';
import { VirtualMachine } from '../../../../vm/shared/vm.model';
import { VmService } from '../../../../vm/shared/vm.service';


@Component({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Volume } from '../../models/volume.model';
import { SpareDriveAction } from './spare-drive-action';
import { RecurringSnapshotsComponent } from '../../../snapshot/recurring-snapshots/recurring-snapshots.component';


@Injectable()
export class SpareDriveRecurringSnapshotsAction extends SpareDriveAction {
public name = 'VOLUME_ACTIONS.SNAPSHOT_SCHEDULE';
public icon = 'schedule';

public activate(volume: Volume): Observable<any> {
return this.dialog.open(RecurringSnapshotsComponent, {
data: volume
})
.afterClosed();
}
}
21 changes: 21 additions & 0 deletions src/app/shared/actions/spare-drive-actions/spare-drive-snapshot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import {
SnapshotCreationComponent
} from '../../../vm/vm-sidebar/storage-detail/volume/snapshot-creation/snapshot-creation.component';
import { Volume } from '../../models/volume.model';
import { SpareDriveAction } from './spare-drive-action';


@Injectable()
export class SpareDriveSnapshotAction extends SpareDriveAction {
public name = 'VOLUME_ACTIONS.TAKE_SNAPSHOT';
public icon = 'camera_alt';

public activate(volume: Volume): Observable<any> {
return this.dialog.open(SnapshotCreationComponent, {
data: volume
})
.afterClosed();
}
}
18 changes: 17 additions & 1 deletion src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ import { UserService } from './services/user.service';
import { VolumeOfferingService } from './services/volume-offering.service';
import { VolumeService } from './services/volume.service';
import { ZoneService } from './services/zone.service';
import {
SpareDriveAttachmentComponent
} from './actions/spare-drive-actions/spare-drive-attachment/spare-drive-attachment.component';
import { SpareDriveSnapshotAction } from './actions/spare-drive-actions/spare-drive-snapshot';
import { SpareDriveRecurringSnapshotsAction } from './actions/spare-drive-actions/spare-drive-recurring-snapshots';
import { SpareDriveAttachAction } from './actions/spare-drive-actions/spare-drive-attach';
import { SpareDriveDetachAction } from './actions/spare-drive-actions/spare-drive-detach';
import { SpareDriveRemoveAction } from './actions/spare-drive-actions/spare-drive-remove';
import { SpareDriveResizeAction } from './actions/spare-drive-actions/spare-drive-resize';


@NgModule({
Expand Down Expand Up @@ -189,7 +198,8 @@ import { ZoneService } from './services/zone.service';
],
entryComponents: [
DatePickerDialogComponent,
LoaderComponent
LoaderComponent,
SpareDriveAttachmentComponent
],
declarations: [
CharacterCountComponent,
Expand Down Expand Up @@ -241,6 +251,12 @@ import { ZoneService } from './services/zone.service';
],
providers: [
SpareDriveActionsService,
SpareDriveSnapshotAction,
SpareDriveRecurringSnapshotsAction,
SpareDriveAttachAction,
SpareDriveDetachAction,
SpareDriveRemoveAction,
SpareDriveResizeAction,
TemplateActionsService,
DescriptionTagService,
MarkForRemovalService,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Component, Input } from '@angular/core';
import { MdDialog } from '@angular/material';
import { SpareDriveSnapshotAction } from '../../../../shared/actions/spare-drive-actions/spare-drive-snapshot';
import { Volume } from '../../../../shared/models/volume.model';
import {
SnapshotCreationComponent
} from '../../../../vm/vm-sidebar/storage-detail/volume/snapshot-creation/snapshot-creation.component';


@Component({
Expand All @@ -14,14 +11,9 @@ import {
export class SpareDriveSnapshotCreationComponent {
@Input() public volume: Volume;

constructor(private dialog: MdDialog) {}
constructor(private spareDriveSnapshotAction: SpareDriveSnapshotAction) {}

public addSnapshot(): void {
this.dialog.open(SnapshotCreationComponent,
{
data: { volume: this.volume },
width: '400px'
}
);
this.spareDriveSnapshotAction.activate(this.volume).subscribe();
}
}
43 changes: 16 additions & 27 deletions src/app/spare-drive/spare-drive.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,38 @@ import {
} from '@angular/material';
import { TranslateModule } from '@ngx-translate/core';
import { DynamicModule } from 'ng-dynamic-component';
import { SpareDriveAttachAction } from '../shared/actions/spare-drive-actions/spare-drive-attach';
import { SpareDriveDetachAction } from '../shared/actions/spare-drive-actions/spare-drive-detach';
import { SpareDriveRemoveAction } from '../shared/actions/spare-drive-actions/spare-drive-remove';
import { SpareDriveResizeAction } from '../shared/actions/spare-drive-actions/spare-drive-resize';
import {
SpareDriveAttachmentComponent
} from '../shared/actions/spare-drive-actions/spare-drive-attachment/spare-drive-attachment.component';
import { SharedModule } from '../shared/shared.module';
import { SpareDriveAttachmentComponent } from './spare-drive-attachment/spare-drive-attachment.component';
import { SpareDriveCreationDialogComponent } from './spare-drive-creation/spare-drive-creation-dialog.component';
import { SpareDriveCreationComponent } from './spare-drive-creation/spare-drive-creation.component';
import { SpareDriveFilterComponent } from './spare-drive-filter/spare-drive-filter.component';
import { SpareDriveItemComponent } from './spare-drive-item/spare-drive-item.component';
import { SpareDriveListComponent } from './spare-drive-list/spare-drive-list.component';
import { SpareDrivePageComponent } from './spare-drive-page/spare-drive-page.component';
import { SpareDriveSidebarComponent } from './spare-drive-sidebar/spare-drive-sidebar.component';
import { spareDrivesRouting } from './spare-drive.routing';
import {
SnapshotActionsComponent
} from './spare-drive-sidebar/snapshot-details/snapshot/snapshot-actions/snapshot-actions.component';
SpareDriveActionsSidebarComponent
} from './spare-drive-sidebar/actions-sidebar/spare-drive-actions-sidebar.component';
import {
SpareDriveSidebarDiskOfferingComponent
} from './spare-drive-sidebar/details/disk-offering/spare-drive-sidebar-disk-offering.component';
import { SpareDriveDetailsComponent } from './spare-drive-sidebar/details/spare-drive-details.component';
import {
SpareDriveSnapshotComponent
} from './spare-drive-sidebar/snapshot-details/snapshot/spare-drive-snapshot.component';
SpareDriveSidebarVolumeComponent } from './spare-drive-sidebar/details/volume/spare-drive-sidebar-volume.component';
import {
SpareDriveSnapshotCreationComponent
} from './spare-drive-sidebar/snapshot-details/snapshot-creation/spare-drive-snapshot-creation.component';
import {
SpareDriveSnapshotDetailsComponent
} from './spare-drive-sidebar/snapshot-details/spare-drive-snapshot-details.component';
import {
SpareDriveActionsSidebarComponent
} from './spare-drive-sidebar/actions-sidebar/spare-drive-actions-sidebar.component';
SnapshotActionsComponent
} from './spare-drive-sidebar/snapshot-details/snapshot/snapshot-actions/snapshot-actions.component';
import {
SpareDriveSidebarDiskOfferingComponent
} from './spare-drive-sidebar/details/disk-offering/spare-drive-sidebar-disk-offering.component';
SpareDriveSnapshotComponent } from './spare-drive-sidebar/snapshot-details/snapshot/spare-drive-snapshot.component';
import {
SpareDriveSidebarVolumeComponent
} from './spare-drive-sidebar/details/volume/spare-drive-sidebar-volume.component';
SpareDriveSnapshotDetailsComponent
} from './spare-drive-sidebar/snapshot-details/spare-drive-snapshot-details.component';
import { SpareDriveSidebarComponent } from './spare-drive-sidebar/spare-drive-sidebar.component';
import { spareDrivesRouting } from './spare-drive.routing';


@NgModule({
Expand Down Expand Up @@ -92,14 +88,7 @@ import {
SpareDrivePageComponent
],
entryComponents: [
SpareDriveAttachmentComponent,
SpareDriveCreationComponent
],
providers: [
SpareDriveAttachAction,
SpareDriveDetachAction,
SpareDriveResizeAction,
SpareDriveRemoveAction
]
})
export class SpareDriveModule { }

0 comments on commit b1eb1cf

Please sign in to comment.