Add a button to check updates instantly

Part of #293
This commit is contained in:
Girish Ramakrishnan
2017-04-12 18:06:18 -07:00
parent 1029402d1e
commit 1f55bb52fc
3 changed files with 29 additions and 6 deletions

View File

@@ -432,6 +432,13 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
}).error(defaultErrorHandler(callback));
};
Client.prototype.checkForUpdates = function (callback) {
post('/api/v1/cloudron/check_for_updates', { }).success(function(data, status) {
if (status !== 200) return callback(new ClientError(status, data));
callback(null);
}).error(defaultErrorHandler(callback));
};
Client.prototype.getAutoupdatePattern = function (callback) {
get('/api/v1/settings/autoupdate_pattern').success(function(data, status) {
if (status !== 200) return callback(new ClientError(status, data));

View File

@@ -423,19 +423,19 @@
<div class="col-md-12">
<div class="radio">
<label>
<input type="radio" name="scheduleRadio" ng-model="autoUpdate.pattern" value="00 00 1,3,5,23 * * *">
<input type="radio" name="scheduleRadio" ng-change="autoUpdate.success = false" ng-model="autoUpdate.pattern" value="00 00 1,3,5,23 * * *">
Every night
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="scheduleRadio" ng-model="autoUpdate.pattern" value="00 00 1,3,5,23 * * 6">
<input type="radio" name="scheduleRadio" ng-change="autoUpdate.success = false" ng-model="autoUpdate.pattern" value="00 00 1,3,5,23 * * 6">
Saturday night
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="scheduleRadio" ng-model="autoUpdate.pattern" value="never">
<input type="radio" name="scheduleRadio" ng-change="autoUpdate.success = false" ng-model="autoUpdate.pattern" value="never">
Update manually (Not recommended)
</label>
</div>
@@ -443,9 +443,15 @@
</div>
<div class="row">
<div class="col-md-12">
<p class="text-success pull-right text-bold" ng-show="autoUpdate.success && autoUpdate.pattern === autoUpdate.currentPattern">Saved</p>
<button class="btn btn-outline btn-primary pull-right" ng-hide="autoUpdate.success && autoUpdate.pattern === autoUpdate.currentPattern" ng-click="autoUpdate.submit()" ng-disabled="autoUpdate.busy || autoUpdate.pattern === autoUpdate.currentPattern"><i class="fa fa-circle-o-notch fa-spin" ng-show="autoUpdate.busy"></i> Save</button>
<div class="col-md-6">
<i class="fa fa-circle-o-notch fa-spin" ng-show="autoUpdate.busy"></i>
<span class="text-success text-bold" ng-show="autoUpdate.success && autoUpdate.pattern === autoUpdate.currentPattern">Saved</span>
</div>
<div class="col-md-6 text-right">
<button class="btn btn-outline btn-primary pull-right" ng-click="autoUpdate.submit()" ng-disabled="autoUpdate.busy || autoUpdate.pattern === autoUpdate.currentPattern"> Save</button>
<button class="btn btn-outline btn-primary" ng-click="autoUpdate.checkNow()" ng-disabled="autoUpdate.busy" style="margin-right: 10px">Check now</button>
</div>
</div>
</div>

View File

@@ -433,6 +433,16 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
pattern: '',
currentPattern: '',
checkNow: function () {
$scope.autoUpdate.busy = true;
Client.checkForUpdates(function (error) {
if (error) $scope.autoUpdate.error = error.message;
$scope.autoUpdate.busy = false;
});
},
submit: function () {
if ($scope.autoUpdate.pattern === $scope.autoUpdate.currentPattern) return;