Add ability for super users to rename and delete organizations
This commit is contained in:
parent
27d8ea3d5c
commit
3e1abba284
5 changed files with 230 additions and 1 deletions
|
@ -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');
|
||||
|
||||
|
|
|
@ -20,6 +20,10 @@
|
|||
tab-target="#users" tab-init="loadUsers()">
|
||||
<i class="fa fa-group"></i>
|
||||
</span>
|
||||
<span class="cor-tab" tab-title="Manage Organizations"
|
||||
tab-target="#organizations" tab-init="loadOrganizations()">
|
||||
<i class="fa fa-sitemap"></i>
|
||||
</span>
|
||||
<span class="cor-tab" tab-title="Dashboard" tab-target="#dashboard"
|
||||
tab-shown="setDashboardActive(true)" tab-hidden="setDashboardActive(false)">
|
||||
<i class="fa fa-tachometer"></i>
|
||||
|
@ -107,6 +111,45 @@
|
|||
For more information: <a href="https://coreos.com/products/enterprise-registry/plans/">See Here</a>.
|
||||
</div> <!-- /usage-counter tab-->
|
||||
|
||||
<!-- Organizations tab -->
|
||||
<div id="organizations" class="tab-pane">
|
||||
<div class="resource-view" resource="organizationsResource"
|
||||
error-message="'Could not load organizations'">
|
||||
<div class="manager-header" header-title="Organizations">
|
||||
</div>
|
||||
|
||||
<div class="filter-box" collection="organization" filter-model="search" filter-name="Organizations"></div>
|
||||
|
||||
<table class="cor-table">
|
||||
<thead>
|
||||
<td style="width: 24px;"></td>
|
||||
<td>Name</td>
|
||||
<td style="width: 24px;"></td>
|
||||
</thead>
|
||||
|
||||
<tr ng-repeat="current_org in (organizations | filter:search | orderBy:'name')"
|
||||
class="org-row">
|
||||
<td>
|
||||
<span class="avatar" data="current_org.avatar" size="24"></span>
|
||||
</td>
|
||||
<td>
|
||||
{{ current_org.name }}
|
||||
</td>
|
||||
<td style="text-align: center;">
|
||||
<span class="cor-options-menu">
|
||||
<span class="cor-option" option-click="askRenameOrganization(current_org)">
|
||||
<i class="fa fa-arrow-right"></i> Rename Organization
|
||||
</span>
|
||||
<span class="cor-option" option-click="askDeleteOrganization(current_org)">
|
||||
<i class="fa fa-times"></i> Delete Organization
|
||||
</span>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div> <!-- /resource -->
|
||||
</div> <!-- organizations tab -->
|
||||
|
||||
<!-- Users tab -->
|
||||
<div id="users" class="tab-pane active">
|
||||
<div class="cor-loader" ng-show="!users"></div>
|
||||
|
@ -168,6 +211,7 @@
|
|||
</table>
|
||||
</div> <!-- /show if users -->
|
||||
</div> <!-- users-tab -->
|
||||
|
||||
</div> <!-- /cor-tab-content -->
|
||||
</div> <!-- /cor-tab-panel -->
|
||||
|
||||
|
|
Reference in a new issue