Show update button and dialog in settings view

This commit is contained in:
Johannes Zellner
2018-03-30 15:12:34 +02:00
parent 0ad813cc8d
commit 8d6de76fa0
2 changed files with 129 additions and 26 deletions
+40
View File
@@ -8,6 +8,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
$scope.config = Client.getConfig();
$scope.backupConfig = {};
$scope.appstoreConfig = {};
$scope.installedApps = Client.getInstalledApps();
$scope.lastBackup = null;
$scope.backups = [];
@@ -76,6 +77,45 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
}
};
$scope.update = {
error: {},
busy: false,
show: function (form) {
$scope.update.error.generic = null;
$scope.update.busy = false;
form.$setPristine();
form.$setUntouched();
if (!$scope.config.update.box.sourceTarballUrl) {
$('#setupSubscriptionModal').modal('show');
} else {
$('#updateModal').modal('show');
}
},
submit: function () {
$scope.update.error.generic = null;
$scope.update.busy = true;
Client.update(function (error) {
if (error) {
if (error.statusCode === 409) {
$scope.update.error.generic = 'Please try again later. The Cloudron is creating a backup at the moment.';
} else {
$scope.update.error.generic = error.message;
console.error('Unable to update.', error);
}
$scope.update.busy = false;
return;
}
window.location.href = '/update.html';
});
}
};
$scope.planChange = {
busy: false,
error: {},