Fix busy state for automatic updates and backups

This commit is contained in:
Johannes Zellner
2020-05-20 12:16:35 +02:00
parent d2a81ce907
commit 2b36a2f8cb
2 changed files with 8 additions and 6 deletions
+2 -2
View File
@@ -965,7 +965,7 @@
<label class="control-label">Automatic Updates</label>
<p>Cloudron periodically polls the App Store to check for updates. If you disable automatic updates, be sure to manually check for updates.</p>
<p>Automatic Updates is currently <b>{{ updates.enableAutomaticUpdate ? 'enabled' : 'disabled' }}</b>.</p>
<button class="btn btn-primary pull-right" uib-tooltip="{{ app.appStoreId ? '' : 'Not available for custom apps' }}" ng-class="{ 'btn-danger': updates.enableAutomaticUpdate }" ng-click="updates.toggleAutomaticUpdates()" ng-disabled="updates.busy || !app.appStoreId"><i class="fa fa-circle-notch fa-spin" ng-show="updates.busy"></i> {{ updates.enableAutomaticUpdate ? 'Disable' : 'Enable' }} Automatic Updates</button>
<button class="btn btn-primary pull-right" uib-tooltip="{{ app.appStoreId ? '' : 'Not available for custom apps' }}" ng-class="{ 'btn-danger': updates.enableAutomaticUpdate }" ng-click="updates.toggleAutomaticUpdates()" ng-disabled="updates.busyAutomaticUpdates || !app.appStoreId"><i class="fa fa-circle-notch fa-spin" ng-show="updates.busyAutomaticUpdates"></i> {{ updates.enableAutomaticUpdate ? 'Disable' : 'Enable' }} Automatic Updates</button>
</div>
</div>
</div>
@@ -1031,7 +1031,7 @@
<p>Cloudron periodically creates a backup based on the <a href="/#/backups">backup</a> settings.
Automatic Backups is currently <b ng-class="backups.enableBackup ? 'text-success' : 'text-danger'">{{ backups.enableBackup ? 'enabled' : 'disabled' }}</b>.</p>
<button class="btn btn-primary pull-right" ng-class="{ 'btn-danger': backups.enableBackup }" ng-click="backups.toggleAutomaticBackups()" ng-disabled="backups.busy"><i class="fa fa-circle-notch fa-spin" ng-show="backups.busy"></i> {{ backups.enableBackup ? 'Disable' : 'Enable' }} Automatic Backups</button>
<button class="btn btn-primary pull-right" ng-class="{ 'btn-danger': backups.enableBackup }" ng-click="backups.toggleAutomaticBackups()" ng-disabled="backups.busyAutomaticBackups"><i class="fa fa-circle-notch fa-spin" ng-show="backups.busyAutomaticBackups"></i> {{ backups.enableBackup ? 'Disable' : 'Enable' }} Automatic Backups</button>
</div>
</div>
</div>
+6 -4
View File
@@ -759,6 +759,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
busy: false,
busyCheck: false,
busyUpdate: false,
busyAutomaticUpdates: false,
skipBackup: false,
enableAutomaticUpdate: false,
@@ -770,14 +771,14 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
},
toggleAutomaticUpdates: function () {
$scope.updates.busy = true;
$scope.updates.busyAutomaticUpdates = true;
Client.configureApp($scope.app.id, 'automatic_update', { enable: !$scope.updates.enableAutomaticUpdate }, function (error) {
if (error) return Client.error(error);
$timeout(function () {
$scope.updates.enableAutomaticUpdate = !$scope.updates.enableAutomaticUpdate;
$scope.updates.busy = false;
$scope.updates.busyAutomaticUpdates = false;
}, 1000);
});
},
@@ -813,6 +814,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.backups = {
busy: false,
busyCreate: false,
busyAutomaticBackups: false,
error: {},
enableBackup: false,
@@ -850,7 +852,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
},
toggleAutomaticBackups: function () {
$scope.backups.busy = true;
$scope.backups.busyAutomaticBackups = true;
$scope.backups.error = {};
Client.configureApp($scope.app.id, 'automatic_backup', { enable: !$scope.backups.enableBackup }, function (error) {
@@ -858,7 +860,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$timeout(function () {
$scope.backups.enableBackup = !$scope.backups.enableBackup;
$scope.backups.busy = false;
$scope.backups.busyAutomaticBackups = false;
}, 1000);
});
}