-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dedicated.netapp): create volume from snapshot
ref: MANAGER-11778 Signed-off-by: Quentin Pavy <[email protected]>
- Loading branch information
Quentin Pavy
committed
Dec 24, 2024
1 parent
e272f80
commit 6e7dfaa
Showing
14 changed files
with
258 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...nager/modules/netapp/src/dashboard/volumes/dashboard/snapshots/create-volume/component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import controller from './controller'; | ||
import template from './template.html'; | ||
|
||
export default { | ||
bindings: { | ||
goToSnapshots: '<', | ||
goToVolumes: '<', | ||
serviceName: '<', | ||
snapshot: '<', | ||
volumeId: '<', | ||
volume: '<', | ||
trackClick: '<', | ||
}, | ||
controller, | ||
template, | ||
}; |
5 changes: 5 additions & 0 deletions
5
...nager/modules/netapp/src/dashboard/volumes/dashboard/snapshots/create-volume/constants.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const PATTERN = /^[a-zA-Z0-9_|\\,. -]*$/; | ||
|
||
export default { | ||
PATTERN, | ||
}; |
55 changes: 55 additions & 0 deletions
55
...ager/modules/netapp/src/dashboard/volumes/dashboard/snapshots/create-volume/controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { PATTERN } from './constants'; | ||
|
||
export default class NetAppVolumesDashboardSnapshotsCreateVolumeController { | ||
/* @ngInject */ | ||
constructor($http, $translate, NetAppSnapshotCreateVolumeService) { | ||
this.$http = $http; | ||
this.$translate = $translate; | ||
this.NetAppSnapshotCreateVolumeService = NetAppSnapshotCreateVolumeService; | ||
this.PATTERN = PATTERN; | ||
} | ||
|
||
$onInit() { | ||
this.isLoading = false; | ||
} | ||
|
||
createVolumeFromSnapshot() { | ||
this.isLoading = true; | ||
this.trackClick('create-volume::confirm'); | ||
return this.NetAppSnapshotCreateVolumeService.createVolumeFromSnapshot( | ||
this.serviceName, | ||
this.name, | ||
this.description, | ||
this.volume.protocol, | ||
this.volume.size, | ||
this.snapshot.id, | ||
) | ||
.then(() => | ||
this.goToVolumes( | ||
this.$translate.instant( | ||
'netapp_volumes_snapshots_create_volume_success', | ||
), | ||
), | ||
) | ||
.catch((error) => | ||
this.goToSnapshots( | ||
this.$translate.instant( | ||
'netapp_volumes_snapshots_create_volume_error', | ||
{ | ||
message: error.data?.message, | ||
requestId: error.headers('X-Ovh-Queryid'), | ||
}, | ||
), | ||
'error', | ||
), | ||
) | ||
.finally(() => { | ||
this.isLoading = false; | ||
}); | ||
} | ||
|
||
goBack() { | ||
this.trackClick('create-volume::cancel'); | ||
return this.goToSnapshots(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...s/manager/modules/netapp/src/dashboard/volumes/dashboard/snapshots/create-volume/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import angular from 'angular'; | ||
import '@uirouter/angularjs'; | ||
import 'oclazyload'; | ||
|
||
const moduleName = | ||
'ovhManagerNetAppVolumesDashboardSnapshotsCreateVolumeLazyLoading'; | ||
|
||
angular.module(moduleName, ['ui.router', 'oc.lazyLoad']).config( | ||
/* @ngInject */ ($stateProvider) => { | ||
$stateProvider.state( | ||
'netapp.dashboard.volumes.dashboard.snapshots.create-volume.**', | ||
{ | ||
url: '/:snapshotId/create-volume', | ||
lazyLoad: ($transition$) => { | ||
const $ocLazyLoad = $transition$.injector().get('$ocLazyLoad'); | ||
|
||
return import('./module').then((mod) => | ||
$ocLazyLoad.inject(mod.default || mod), | ||
); | ||
}, | ||
}, | ||
); | ||
}, | ||
); | ||
|
||
export default moduleName; |
32 changes: 32 additions & 0 deletions
32
.../manager/modules/netapp/src/dashboard/volumes/dashboard/snapshots/create-volume/module.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import angular from 'angular'; | ||
import '@ovh-ux/manager-core'; | ||
import '@ovh-ux/ng-ui-router-breadcrumb'; | ||
import '@ovh-ux/ng-ui-router-layout'; | ||
import '@ovh-ux/ui-kit'; | ||
import '@uirouter/angularjs'; | ||
import 'angular-translate'; | ||
|
||
import component from './component'; | ||
import routing from './routing'; | ||
import service from './service'; | ||
|
||
const moduleName = 'ovhManagerNetAppVolumesDashboardSnapshotsCreateVolume'; | ||
|
||
angular | ||
.module(moduleName, [ | ||
'ngUiRouterBreadcrumb', | ||
'ngUiRouterLayout', | ||
'oui', | ||
'ovhManagerCore', | ||
'pascalprecht.translate', | ||
'ui.router', | ||
]) | ||
.config(routing) | ||
.component( | ||
'ovhManagerNetAppVolumesDashboardSnapshotsCreateVolumeComponent', | ||
component, | ||
) | ||
.service('NetAppSnapshotCreateVolumeService', service) | ||
.run(/* @ngTranslationsInject:json ./translations */); | ||
|
||
export default moduleName; |
22 changes: 22 additions & 0 deletions
22
...manager/modules/netapp/src/dashboard/volumes/dashboard/snapshots/create-volume/routing.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export default /* @ngInject */ ($stateProvider) => { | ||
$stateProvider.state( | ||
'netapp.dashboard.volumes.dashboard.snapshots.create-volume', | ||
{ | ||
url: '/:snapshotId/create-volume', | ||
views: { | ||
modal: { | ||
component: | ||
'ovhManagerNetAppVolumesDashboardSnapshotsCreateVolumeComponent', | ||
}, | ||
}, | ||
layout: 'modal', | ||
resolve: { | ||
breadcrumb: /* @ngInject */ () => null, | ||
snapshotId: /* @ngInject */ ($transition$) => | ||
$transition$.params().snapshotId, | ||
snapshot: /* @ngInject */ (snapshots, snapshotId) => | ||
snapshots.find(({ id }) => id === snapshotId), | ||
}, | ||
}, | ||
); | ||
}; |
23 changes: 23 additions & 0 deletions
23
...manager/modules/netapp/src/dashboard/volumes/dashboard/snapshots/create-volume/service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export default class NetAppSnapshotCreateVolumeService { | ||
/* @ngInject */ | ||
constructor($http) { | ||
this.$http = $http; | ||
} | ||
|
||
createVolumeFromSnapshot( | ||
serviceName, | ||
name, | ||
description, | ||
protocol, | ||
size, | ||
snapshotID, | ||
) { | ||
return this.$http.post(`/storage/netapp/${serviceName}/share`, { | ||
name, | ||
description, | ||
protocol, | ||
size, | ||
snapshotID, | ||
}); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...ager/modules/netapp/src/dashboard/volumes/dashboard/snapshots/create-volume/template.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<form | ||
id="createVolumeFormSnapshot" | ||
name="createVolumeFormSnapshot" | ||
data-ng-submit="createVolumeFormSnapshot.$valid && $ctrl.createVolumeFromSnapshot()" | ||
novalidate | ||
> | ||
<oui-modal | ||
data-heading="{{ ::'netapp_volumes_snapshots_create_volume_title' | translate }}" | ||
data-primary-label="{{ ::'netapp_volumes_snapshots_create_volume_confirm' | translate }}" | ||
data-secondary-label="{{ ::'netapp_volumes_snapshots_create_volume_cancel' | translate }}" | ||
data-secondary-action="$ctrl.goBack()" | ||
data-on-dismiss="$ctrl.goBack()" | ||
data-loading="$ctrl.isLoading" | ||
> | ||
<p | ||
data-translate="netapp_volumes_snapshots_create_volume_description" | ||
data-translate-values="{snapshot: $ctrl.snapshot.name || $ctrl.snapshot.id}" | ||
></p> | ||
<oui-field | ||
label="{{:: 'netapp_volumes_snapshots_create_volume_name_label' | translate }}" | ||
> | ||
<input | ||
class="oui-input" | ||
name="volumeName" | ||
type="text" | ||
data-ng-model="$ctrl.name" | ||
data-ng-pattern="$ctrl.PATTERN" | ||
maxlength="255" | ||
/> | ||
</oui-field> | ||
<oui-field | ||
label="{{:: 'netapp_volumes_snapshots_create_volume_description_label' | translate }}" | ||
> | ||
<input | ||
class="oui-input" | ||
name="volumeDescription" | ||
type="text" | ||
data-ng-model="$ctrl.description" | ||
data-ng-pattern="$ctrl.PATTERN" | ||
maxlength="255" | ||
/> | ||
</oui-field> | ||
</oui-modal> | ||
</form> |
10 changes: 10 additions & 0 deletions
10
.../src/dashboard/volumes/dashboard/snapshots/create-volume/translations/Messages_fr_FR.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"netapp_volumes_snapshots_create_volume_title": "Créer un volume", | ||
"netapp_volumes_snapshots_create_volume_description": "Vous allez créer un volume à partir du snapshot {{ snapshot }}", | ||
"netapp_volumes_snapshots_create_volume_name_label": "Nom du volume (optionnel)", | ||
"netapp_volumes_snapshots_create_volume_description_label": "Description (optionnel)", | ||
"netapp_volumes_snapshots_create_volume_confirm": "Confirmer", | ||
"netapp_volumes_snapshots_create_volume_cancel": "Annuler", | ||
"netapp_volumes_snapshots_create_volume_success": "Votre volume a été créé avec succès.", | ||
"netapp_volumes_snapshots_create_volume_error": "Une erreur est survenue lors de la creation du volume. <br> {{ message }} <br> {{ requestId }}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters