feat(storidge): profiles can enable snapshots without interval + interval in minutes

storidge-standalone
baron_l 2019-03-12 18:24:45 +01:00
parent 072b20b9cc
commit b3170b7f8e
5 changed files with 70 additions and 27 deletions

View File

@ -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 = '';

View File

@ -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;

View File

@ -105,36 +105,44 @@
<!-- !Filesystem -->
<!-- snapshotEnabled -->
<div class="form-group">
<div class="col-sm-12">
<label for="profile_snapshotEnabled" class="control-label text-left">
Enable snapshots
</label>
<label class="switch" style="margin-left: 20px;">
<input name="profile_snapshotEnabled" type="checkbox" ng-model="model.SnapshotEnabled"><i></i>
</label>
</div>
<div class="col-sm-6">
<label for="profile_snapshotEnabled" class="control-label text-left">
Enable snapshots
</label>
<label class="switch" style="margin-left: 20px;">
<input name="profile_snapshotEnabled" type="checkbox" ng-model="model.SnapshotEnabled"><i></i>
</label>
</div>
<div class="col-sm-6">
<label for="profile_recurringSnapshotEnabled" class="control-label text-left">
Enable periodic snapshots
</label>
<label class="switch" style="margin-left: 20px;">
<input name="profile_recurringSnapshotEnabled" type="checkbox" ng-model="state.RecurringSnapshotEnabled"><i></i>
</label>
</div>
</div>
<!-- !snapshotEnabled -->
<!-- snapshotInterval -->
<div class="form-group" ng-if="model.SnapshotEnabled">
<div class="form-group" ng-if="state.RecurringSnapshotEnabled">
<label for="profile_snapshotInterval" class="col-sm-2 col-lg-1 control-label text-left" style="margin-top: 20px;">
Snapshot interval
</label>
<div class="col-sm-4">
<slider model="model.SnapshotInterval" floor="1" ceil="45000" step="1"></slider>
<slider model="model.SnapshotInterval" floor="1" ceil="750" step="1"></slider>
</div>
<div class="col-sm-2">
<input type="number" min="1" class="form-control" ng-model="model.SnapshotInterval" id="profile_snapshotInterval">
</div>
<div class="col-sm-4">
<p class="small text-muted" style="margin-top: 7px;">
Snapshot interval (<b>s</b>)
Snapshot interval (<b>minutes</b>)
</p>
</div>
</div>
<!-- !snapshotInterval -->
<!-- snapshotMax -->
<div class="form-group" ng-if="model.SnapshotEnabled">
<div class="form-group" ng-if="state.RecurringSnapshotEnabled">
<label for="profile_snapshotMax" class="col-sm-2 col-lg-1 control-label text-left" style="margin-top: 20px;">
Snapshot max
</label>

View File

@ -98,36 +98,44 @@
<!-- !Filesystem -->
<!-- snapshotEnabled -->
<div class="form-group">
<div class="col-sm-12">
<label for="profile_snapshotEnabled" class="control-label text-left">
Enable snapshots
</label>
<label class="switch" style="margin-left: 20px;">
<input name="profile_snapshotEnabled" type="checkbox" ng-model="profile.SnapshotEnabled"><i></i>
</label>
</div>
<div class="col-sm-6">
<label for="profile_snapshotEnabled" class="control-label text-left">
Enable snapshots
</label>
<label class="switch" style="margin-left: 20px;">
<input name="profile_snapshotEnabled" type="checkbox" ng-model="profile.SnapshotEnabled"><i></i>
</label>
</div>
<div class="col-sm-6">
<label for="profile_recurringSnapshotEnabled" class="control-label text-left">
Enable periodic snapshots
</label>
<label class="switch" style="margin-left: 20px;">
<input name="profile_recurringSnapshotEnabled" type="checkbox" ng-model="state.RecurringSnapshotEnabled"><i></i>
</label>
</div>
</div>
<!-- !snapshotEnabled -->
<!-- snapshotInterval -->
<div class="form-group" ng-if="profile.SnapshotEnabled">
<div class="form-group" ng-if="state.RecurringSnapshotEnabled">
<label for="profile_snapshotInterval" class="col-sm-2 col-lg-1 control-label text-left" style="margin-top: 20px;">
Snapshot interval
</label>
<div class="col-sm-4">
<slider model="profile.SnapshotInterval" floor="1" ceil="45000" step="1"></slider>
<slider model="profile.SnapshotInterval" floor="1" ceil="750" step="1"></slider>
</div>
<div class="col-sm-2">
<input type="number" min="1" class="form-control" ng-model="profile.SnapshotInterval" id="profile_snapshotInterval">
</div>
<div class="col-sm-4">
<p class="small text-muted" style="margin-top: 7px;">
Snapshot interval (<b>s</b>)
Snapshot interval (<b>minutes</b>)
</p>
</div>
</div>
<!-- !snapshotInterval -->
<!-- snapshotMax -->
<div class="form-group" ng-if="profile.SnapshotEnabled">
<div class="form-group" ng-if="state.RecurringSnapshotEnabled">
<label for="profile_snapshotMax" class="col-sm-2 col-lg-1 control-label text-left" style="margin-top: 20px;">
Snapshot max
</label>

View File

@ -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;
})