show backup days and hours
This commit is contained in:
+51
-14
@@ -108,12 +108,24 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
|
||||
{ name: 'Forever', value: { keepWithinSecs: -1 }}
|
||||
];
|
||||
|
||||
$scope.intervalTimes = [
|
||||
{ name: 'Every 6 hours', value: 6 * 60 * 60 },
|
||||
{ name: 'Every 12 hours', value: 12 * 60 * 60 },
|
||||
{ name: 'Every day', value: 24 * 60 * 60 },
|
||||
{ name: 'Every 3 days', value: 3 * 24 * 60 * 60 },
|
||||
{ name: 'Every week', value: 7 * 24 * 60 * 60 },
|
||||
// values correspond to cron days
|
||||
$scope.backupDays = [
|
||||
{ name: 'Sunday', value: 0 },
|
||||
{ name: 'Monday', value: 1 },
|
||||
{ name: 'Tuesday', value: 2 },
|
||||
{ name: 'Wednesday', value: 3 },
|
||||
{ name: 'Thursday', value: 4 },
|
||||
{ name: 'Friday', value: 5 },
|
||||
{ name: 'Saturday', value: 6 },
|
||||
];
|
||||
|
||||
$scope.backupHours = [
|
||||
{ name: 'Midnight', value: 0 }, { name: '1 AM', value: 1 }, { name: '2 AM', value: 2 }, { name: '3 AM', value: 3 },
|
||||
{ name: '4 AM', value: 4 }, { name: '5 AM', value: 5 }, { name: '6 AM', value: 6 }, { name: '7 AM', value: 7 },
|
||||
{ name: '8 AM', value: 8 }, { name: '9 AM', value: 9 }, { name: '10 AM', value: 10 }, { name: '11 AM', value: 11 },
|
||||
{ name: 'Noon', value: 12 }, { name: '1 PM', value: 13 }, { name: '2 PM', value: 14 }, { name: '3 PM', value: 15 },
|
||||
{ name: '4 PM', value: 16 }, { name: '5 PM', value: 17 }, { name: '6 PM', value: 18 }, { name: '7 PM', value: 19 },
|
||||
{ name: '8 PM', value: 20 }, { name: '9 PM', value: 21 }, { name: '10 PM', value: 22 }, { name: '11 PM', value: 23 }
|
||||
];
|
||||
|
||||
$scope.formats = [
|
||||
@@ -128,9 +140,20 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
|
||||
}
|
||||
};
|
||||
|
||||
$scope.prettyBackupInterval = function (interval) {
|
||||
var tmp = $scope.intervalTimes.find(function (i) { return i.value === interval; });
|
||||
return tmp ? tmp.name : '';
|
||||
$scope.prettyBackupSchedule = function (pattern) {
|
||||
if (!pattern) return '';
|
||||
var tmp = pattern.split(' ');
|
||||
var hours = tmp[2].split(','), days = tmp[5].split(',');
|
||||
var prettyDay;
|
||||
if (days.length === 7 || days[0] === '*') {
|
||||
prettyDay = 'Everyday';
|
||||
} else {
|
||||
prettyDay = days.map(function (day) { return $scope.backupDays[parseInt(day, 10)].name.substr(0, 3); }).join(',');
|
||||
}
|
||||
|
||||
var prettyHour = hours.map(function (hour) { return $scope.backupHours[parseInt(hour, 10)].name; }).join(',');
|
||||
|
||||
return prettyDay + ' at ' + prettyHour;
|
||||
};
|
||||
|
||||
$scope.prettyBackupRetentionPolicy = function (retentionPolicy) {
|
||||
@@ -206,7 +229,7 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
|
||||
});
|
||||
},
|
||||
|
||||
cleanupBackups: function (backup) {
|
||||
cleanupBackups: function () {
|
||||
$('#cleanupBackupsModal').modal('show');
|
||||
},
|
||||
|
||||
@@ -301,7 +324,8 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
|
||||
error: {},
|
||||
|
||||
retentionPolicy: $scope.retentionPolicies[0],
|
||||
intervalSecs: 24 * 60 * 60,
|
||||
days: [],
|
||||
hours: [],
|
||||
|
||||
show: function () {
|
||||
$scope.configureScheduleAndRetention.error = {};
|
||||
@@ -311,7 +335,11 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
|
||||
if (!selectedPolicy) selectedPolicy = $scope.retentionPolicies[0];
|
||||
|
||||
$scope.configureScheduleAndRetention.retentionPolicy = selectedPolicy.value;
|
||||
$scope.configureScheduleAndRetention.intervalSecs = $scope.backupConfig.intervalSecs;
|
||||
|
||||
var tmp = $scope.backupConfig.schedulePattern.split(' ');
|
||||
var hours = tmp[2].split(','), days = tmp[5].split(',');
|
||||
$scope.configureScheduleAndRetention.days = days.map(function (day) { return $scope.backupDays[parseInt(day, 10)]; });
|
||||
$scope.configureScheduleAndRetention.hours = hours.map(function (hour) { return $scope.backupHours[parseInt(hour, 10)]; });
|
||||
|
||||
$('#configureScheduleAndRetentionModal').modal('show');
|
||||
},
|
||||
@@ -323,7 +351,16 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
|
||||
// start with the full backupConfig since the api requires all fields
|
||||
var backupConfig = $scope.backupConfig;
|
||||
backupConfig.retentionPolicy = $scope.configureScheduleAndRetention.retentionPolicy;
|
||||
backupConfig.intervalSecs = $scope.configureScheduleAndRetention.intervalSecs;
|
||||
|
||||
var daysPattern;
|
||||
if ($scope.configureScheduleAndRetention.days.length === 7) daysPattern = '*';
|
||||
else daysPattern = $scope.configureScheduleAndRetention.days.map(function (d) { return d.value; });
|
||||
|
||||
var hoursPattern;
|
||||
if ($scope.configureScheduleAndRetention.hours.length === 24) hoursPattern = '*';
|
||||
else hoursPattern = $scope.configureScheduleAndRetention.hours.map(function (d) { return d.value; });
|
||||
|
||||
backupConfig.schedulePattern ='* * ' + hoursPattern + ' * * ' + daysPattern;
|
||||
|
||||
Client.setBackupConfig(backupConfig, function (error) {
|
||||
$scope.configureScheduleAndRetention.busy = false;
|
||||
@@ -421,7 +458,7 @@ angular.module('Application').controller('BackupsController', ['$scope', '$locat
|
||||
provider: $scope.configureBackup.provider,
|
||||
format: $scope.configureBackup.format,
|
||||
// required for api call to provide all fields
|
||||
intervalSecs: $scope.backupConfig.intervalSecs,
|
||||
schedulePattern: $scope.backupConfig.schedulePattern,
|
||||
retentionPolicy: $scope.backupConfig.retentionPolicy
|
||||
};
|
||||
if ($scope.configureBackup.password) backupConfig.password = $scope.configureBackup.password;
|
||||
|
||||
Reference in New Issue
Block a user