Get permission changing working
This commit is contained in:
parent
98dc20542c
commit
240cf243ac
3 changed files with 88 additions and 4 deletions
|
@ -98,3 +98,25 @@ p.editable:hover i {
|
|||
margin-top: 6px;
|
||||
padding-left: 36px;
|
||||
}
|
||||
|
||||
.repo-admin .panel {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.repo-admin .user i {
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.repo-admin .user {
|
||||
font-size: 1.2em;
|
||||
min-width: 300px;
|
||||
}
|
||||
|
||||
.repo-admin thead td {
|
||||
padding: 4px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.repo-admin td {
|
||||
padding: 6px;
|
||||
}
|
|
@ -45,6 +45,30 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope) {
|
|||
});
|
||||
}
|
||||
|
||||
function RepoAdminCtrl() {
|
||||
|
||||
function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
|
||||
var namespace = $routeParams.namespace;
|
||||
var name = $routeParams.name;
|
||||
|
||||
$scope.setRole = function(username, role) {
|
||||
var permission = $scope.permissions[username];
|
||||
permission.role = role;
|
||||
|
||||
var permissionPut = Restangular.one('repository/' + namespace + '/' + name + '/permissions/' + username);
|
||||
permissionPut.customPUT(permission);
|
||||
};
|
||||
|
||||
var permissionsFetch = Restangular.one('repository/' + namespace + '/' + name + '/permissions');
|
||||
permissionsFetch.get().then(function(resp) {
|
||||
$rootScope.title = 'Permissions - ' + namespace + '/' + name;
|
||||
$scope.repo = {
|
||||
'namespace': namespace,
|
||||
'name': name
|
||||
};
|
||||
|
||||
$scope.permissions = resp.permissions;
|
||||
}, function() {
|
||||
$scope.repo = null;
|
||||
$scope.permissions = null;
|
||||
$rootScope.title = 'Unknown Repository';
|
||||
});
|
||||
}
|
|
@ -1,3 +1,41 @@
|
|||
<div class="container">
|
||||
<h2>Permissions</h2>
|
||||
<div class="container" ng-show="!repo || !permissions">
|
||||
No repository found
|
||||
</div>
|
||||
|
||||
<div class="container repo repo-admin" ng-show="repo && permissions">
|
||||
<div class="header">
|
||||
<h3>
|
||||
<i class="icon-hdd icon-large"></i> <span style="color: #aaa;"> {{repo.namespace}}</span> <span style="color: #ccc">/</span> {{repo.name}}
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Access Permissions</div>
|
||||
<div class="panel-body">
|
||||
|
||||
<table class="permissions">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>User</td>
|
||||
<td>Permissions</td>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tr ng-repeat="(username, permission) in permissions">
|
||||
<td class="user">
|
||||
<i class="icon-user"></i>
|
||||
<span>{{username}}</span>
|
||||
</td>
|
||||
<td class="user-permissions">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<button type="button" class="btn btn-default" ng-click="setRole(username, 'read')" ng-class="{read: 'active', write: '', admin: ''}[permission.role]">Read only</button>
|
||||
<button type="button" class="btn btn-default" ng-click="setRole(username, 'write')" ng-class="{read: '', write: 'active', admin: ''}[permission.role]">Write</button>
|
||||
<button type="button" class="btn btn-default" ng-click="setRole(username, 'admin')" ng-class="{read: '', write: '', admin: 'active'}[permission.role]">Admin</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
Reference in a new issue