Refactor uninstall functions
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user