From b3170b7f8e5898e5bd16a395139b6d03f771a956 Mon Sep 17 00:00:00 2001 From: baron_l Date: Tue, 12 Mar 2019 18:24:45 +0100 Subject: [PATCH] feat(storidge): profiles can enable snapshots without interval + interval in minutes --- app/extensions/storidge/models/profile.js | 4 +-- .../create/createProfileController.js | 11 +++++++ .../views/profiles/create/createprofile.html | 32 ++++++++++++------- .../storidge/views/profiles/edit/profile.html | 32 ++++++++++++------- .../views/profiles/edit/profileController.js | 18 ++++++++++- 5 files changed, 70 insertions(+), 27 deletions(-) diff --git a/app/extensions/storidge/models/profile.js b/app/extensions/storidge/models/profile.js index 9b433825e..e78f7fa52 100644 --- a/app/extensions/storidge/models/profile.js +++ b/app/extensions/storidge/models/profile.js @@ -10,8 +10,8 @@ function StoridgeProfileDefaultModel() { this.MaxBandwidth = 100; this.Filesystem = 'btrfs'; this.SnapshotEnabled = false; - this.SnapshotInterval = 60; - this.SnapshotMax = 1; + this.SnapshotInterval = 0; + this.SnapshotMax = 0; this.EncryptionEnabled = false; this.InterfaceType = 'nfs'; this.InterfaceDriver = ''; diff --git a/app/extensions/storidge/views/profiles/create/createProfileController.js b/app/extensions/storidge/views/profiles/create/createProfileController.js index da767dca3..c46f62f28 100644 --- a/app/extensions/storidge/views/profiles/create/createProfileController.js +++ b/app/extensions/storidge/views/profiles/create/createProfileController.js @@ -50,6 +50,17 @@ function ($scope, $state, $transition$, Notifications, StoridgeProfileService) { delete profile.MaxBandwidth; } + if (profile.SnapshotEnabled && $scope.state.RecurringSnapshotEnabled) { + if (!profile.SnapshotInterval) { + profile.SnapshotInterval = 1; + } + profile.SnapshotInterval *= 60; + } + + if (!$scope.state.RecurringSnapshotEnabled) { + profile.SnapshotInterval = 0; + } + prepareLabels(profile); $scope.state.actionInProgress = true; diff --git a/app/extensions/storidge/views/profiles/create/createprofile.html b/app/extensions/storidge/views/profiles/create/createprofile.html index 038438ad2..2d3ae352b 100644 --- a/app/extensions/storidge/views/profiles/create/createprofile.html +++ b/app/extensions/storidge/views/profiles/create/createprofile.html @@ -105,36 +105,44 @@
-
- - -
+
+ +
+
+ + +
+
-
+
- +

- Snapshot interval (s) + Snapshot interval (minutes)

-
+
diff --git a/app/extensions/storidge/views/profiles/edit/profile.html b/app/extensions/storidge/views/profiles/edit/profile.html index fb2692db5..0391efc0e 100644 --- a/app/extensions/storidge/views/profiles/edit/profile.html +++ b/app/extensions/storidge/views/profiles/edit/profile.html @@ -98,36 +98,44 @@
-
- - -
+
+ +
+
+ + +
+
-
+
- +

- Snapshot interval (s) + Snapshot interval (minutes)

-
+
diff --git a/app/extensions/storidge/views/profiles/edit/profileController.js b/app/extensions/storidge/views/profiles/edit/profileController.js index c6a4c192a..e6eb3a0d5 100644 --- a/app/extensions/storidge/views/profiles/edit/profileController.js +++ b/app/extensions/storidge/views/profiles/edit/profileController.js @@ -11,7 +11,8 @@ function ($scope, $state, $transition$, Notifications, StoridgeProfileService, M LimitIOPS: false, LimitBandwidth: false, updateInProgress: false, - deleteInProgress: false + deleteInProgress: false, + RecurringSnapshotEnabled: false }; $scope.addLabel = function() { @@ -57,6 +58,17 @@ function ($scope, $state, $transition$, Notifications, StoridgeProfileService, M delete profile.MaxBandwidth; } + if (profile.SnapshotEnabled && $scope.state.RecurringSnapshotEnabled) { + if (!profile.SnapshotInterval) { + profile.SnapshotInterval = 1; + } + profile.SnapshotInterval *= 60; + } + + if (!$scope.state.RecurringSnapshotEnabled) { + profile.SnapshotInterval = 0; + } + prepareLabels(profile); $scope.state.updateInProgress = true; @@ -111,6 +123,10 @@ function ($scope, $state, $transition$, Notifications, StoridgeProfileService, M } else { $scope.state.NoLimit = true; } + if (profile.SnapshotEnabled && profile.SnapshotInterval) { + $scope.state.RecurringSnapshotEnabled = true; + profile.SnapshotInterval /= 60; + } initLabels(profile.Labels); $scope.profile = profile; })