Refactor update functions

This commit is contained in:
Girish Ramakrishnan
2019-08-29 11:33:22 -07:00
parent e08f072d95
commit 5387054000
2 changed files with 29 additions and 29 deletions

View File

@@ -496,7 +496,33 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
error: {},
app: {},
manifest: {},
portBindings: {}
portBindings: {},
show: function (app, updateManifest) {
$scope.reset();
$scope.appUpdate.app = app;
$scope.appUpdate.manifest = angular.copy(updateManifest);
$('#appUpdateModal').modal('show');
},
submit: function () {
$scope.appUpdate.busy = true;
Client.updateApp($scope.appUpdate.app.id, $scope.appUpdate.manifest, function (error) {
if (error) {
Client.error(error);
} else {
$scope.appUpdate.app = {};
$('#appUpdateModal').modal('hide');
}
$scope.appUpdate.busy = false;
Client.refreshAppCache($scope.appUpdate.app.id); // reflect the new app state immediately
});
}
};
$scope.reset = function () {
@@ -609,32 +635,6 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
return false; // prevent propagation and default
};
$scope.showUpdate = function (app, updateManifest) {
$scope.reset();
$scope.appUpdate.app = app;
$scope.appUpdate.manifest = angular.copy(updateManifest);
$('#appUpdateModal').modal('show');
};
$scope.doUpdate = function () {
$scope.appUpdate.busy = true;
Client.updateApp($scope.appUpdate.app.id, $scope.appUpdate.manifest, function (error) {
if (error) {
Client.error(error);
} else {
$scope.appUpdate.app = {};
$('#appUpdateModal').modal('hide');
}
$scope.appUpdate.busy = false;
Client.refreshAppCache($scope.appUpdate.app.id); // reflect the new app state immediately
});
};
$scope.renderAccessRestrictionUser = function (userId) {
var user = $scope.users.filter(function (u) { return u.id === userId; })[0];