Add ability for super users to rename and delete organizations

This commit is contained in:
Joseph Schorr 2015-05-11 18:03:25 -04:00
parent 27d8ea3d5c
commit 3e1abba284
5 changed files with 230 additions and 1 deletions

View file

@ -101,6 +101,21 @@
$scope.logsCounter++;
};
$scope.loadOrganizations = function() {
if ($scope.organizations) {
return;
}
$scope.loadOrganizationsInternal();
};
$scope.loadOrganizationsInternal = function() {
$scope.organizationsResource = ApiService.listAllOrganizationsAsResource().get(function(resp) {
$scope.organizations = resp['organizations'];
return $scope.organizations;
});
};
$scope.loadUsers = function() {
if ($scope.users) {
return;
@ -183,6 +198,40 @@
}, ApiService.errorDisplay('Could not change user'));
};
$scope.askDeleteOrganization = function(org) {
bootbox.confirm('Are you sure you want to delete this organization? Its data will be deleted with it.',
function(result) {
if (!result) { return; }
var params = {
'name': org.name
};
ApiService.deleteOrganization(null, params).then(function(resp) {
$scope.loadOrganizationsInternal();
}, ApiService.errorDisplay('Could not delete organization'));
});
};
$scope.askRenameOrganization = function(org) {
bootbox.prompt('Enter a new name for the organization:', function(newName) {
if (!newName) { return; }
var params = {
'name': org.name
};
var data = {
'name': newName
};
ApiService.changeOrganization(data, params).then(function(resp) {
$scope.loadOrganizationsInternal();
org.name = newName;
}, ApiService.errorDisplay('Could not rename organization'));
});
};
$scope.changeUserPassword = function(user) {
$('#changePasswordModal').modal('hide');