Refactor uninstall functions

This commit is contained in:
Girish Ramakrishnan
2019-08-29 11:12:14 -07:00
parent 44db2ca02a
commit e08f072d95
2 changed files with 29 additions and 29 deletions

View File

@@ -278,7 +278,33 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
$scope.appUninstall = {
busy: false,
error: {},
app: {}
app: {},
show: function (app) {
$scope.reset();
$scope.appUninstall.app = app;
$('#appUninstallModal').modal('show');
},
submit: function () {
$scope.appUninstall.busy = true;
Client.uninstallApp($scope.appUninstall.app.id, function (error) {
if (error && error.statusCode === 402) { // unpurchase failed
Client.error('Relogin to Cloudron App Store');
} else if (error) {
Client.error(error);
} else {
$('#appUninstallModal').modal('hide');
Client.refreshAppCache($scope.appUninstall.app.id); // reflect the new app state immediately
$scope.reset();
}
$scope.appUninstall.busy = false;
});
}
};
$scope.appClone = {
@@ -583,32 +609,6 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
return false; // prevent propagation and default
};
$scope.showUninstall = function (app) {
$scope.reset();
$scope.appUninstall.app = app;
$('#appUninstallModal').modal('show');
};
$scope.doUninstall = function () {
$scope.appUninstall.busy = true;
Client.uninstallApp($scope.appUninstall.app.id, function (error) {
if (error && error.statusCode === 402) { // unpurchase failed
Client.error('Relogin to Cloudron App Store');
} else if (error) {
Client.error(error);
} else {
$('#appUninstallModal').modal('hide');
Client.refreshAppCache($scope.appUninstall.app.id); // reflect the new app state immediately
$scope.reset();
}
$scope.appUninstall.busy = false;
});
};
$scope.showUpdate = function (app, updateManifest) {
$scope.reset();