Add a way to disable auto updates

This commit is contained in:
Girish Ramakrishnan
2020-07-29 20:14:30 -07:00
parent 31fbffb435
commit ab3abe7e5e
2 changed files with 49 additions and 20 deletions

View File

@@ -198,32 +198,46 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
currentPattern: '',
days: [],
hours: [],
type: 'pattern',
isScheduleValid: function () {
return $scope.updateSchedule.hours.length !== 0 && $scope.updateSchedule.days !== 0;
},
show: function () {
$scope.updateSchedule.busy = false;
var tmp = $scope.updateSchedule.currentPattern.split(' ');
var hours = tmp[2].split(','), days = tmp[5].split(',');
if (days[0] === '*') {
$scope.updateSchedule.days = angular.copy($scope.cronDays, []);
if ($scope.updateSchedule.currentPattern === 'never') {
$scope.updateSchedule.type = 'never';
} else {
$scope.updateSchedule.days = days.map(function (day) { return $scope.cronDays[parseInt(day, 10)]; });
$scope.updateSchedule.type = 'pattern';
var tmp = $scope.updateSchedule.currentPattern.split(' ');
var hours = tmp[2].split(','), days = tmp[5].split(',');
if (days[0] === '*') {
$scope.updateSchedule.days = angular.copy($scope.cronDays, []);
} else {
$scope.updateSchedule.days = days.map(function (day) { return $scope.cronDays[parseInt(day, 10)]; });
}
$scope.updateSchedule.hours = hours.map(function (hour) { return $scope.cronHours[parseInt(hour, 10)]; });
}
$scope.updateSchedule.hours = hours.map(function (hour) { return $scope.cronHours[parseInt(hour, 10)]; });
$('#updateScheduleModal').modal('show');
},
submit: function () {
var daysPattern;
if ($scope.updateSchedule.days.length === 7) daysPattern = '*';
else daysPattern = $scope.updateSchedule.days.map(function (d) { return d.value; });
var pattern = 'never';
if ($scope.updateSchedule.type === 'pattern') {
var daysPattern;
if ($scope.updateSchedule.days.length === 7) daysPattern = '*';
else daysPattern = $scope.updateSchedule.days.map(function (d) { return d.value; });
var hoursPattern;
if ($scope.updateSchedule.hours.length === 24) hoursPattern = '*';
else hoursPattern = $scope.updateSchedule.hours.map(function (d) { return d.value; });
var hoursPattern;
if ($scope.updateSchedule.hours.length === 24) hoursPattern = '*';
else hoursPattern = $scope.updateSchedule.hours.map(function (d) { return d.value; });
var pattern ='00 00 ' + hoursPattern + ' * * ' + daysPattern;
pattern ='00 00 ' + hoursPattern + ' * * ' + daysPattern;
}
$scope.updateSchedule.busy = true;