mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +01:00
update for user settings and listing project role.
This commit is contained in:
parent
b525062cea
commit
d9825763cf
@ -292,7 +292,7 @@ func (ua *UserAPI) ChangePassword() {
|
||||
}
|
||||
}
|
||||
|
||||
// ToggleUserAdminRole handles PUT api/users/{}/toggleadmin
|
||||
// ToggleUserAdminRole handles PUT api/users/{}/sysadmin
|
||||
func (ua *UserAPI) ToggleUserAdminRole() {
|
||||
if !ua.IsAdmin {
|
||||
log.Warningf("current user, id: %d does not have admin role, can not update other user's role", ua.currentUserID)
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
function roles() {
|
||||
return [
|
||||
{'id': '0', 'name': 'N/A', 'roleName': 'n/a'},
|
||||
{'id': '1', 'name': 'Project Admin', 'roleName': 'projectAdmin'},
|
||||
{'id': '2', 'name': 'Developer', 'roleName': 'developer'},
|
||||
{'id': '3', 'name': 'Guest', 'roleName': 'guest'}
|
||||
|
@ -49,13 +49,13 @@
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-4 col-md-12 well well-sm well-custom well-split"><div class="col-md-offset-10">//vm.projects ? vm.projects.length : 0// // 'items' | tr //</div></div>
|
||||
<div class="col-xs-4 col-md-12 well well-sm well-custom well-split"><div class="col-md-offset-10">//vm.replicationPolicies ? vm.replicationPolicies.length : 0// // 'items' | tr //</div></div>
|
||||
<p class="split-handle"><span class="glyphicon glyphicon-align-justify"></span></p>
|
||||
<h4 class="h4-custom-down">Replication Jobs</h4>
|
||||
<hr class="hr-line"/>
|
||||
<div class="form-inline">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" placeholder="" ng-model="vm.repositoryName" size="30">
|
||||
<input type="text" class="form-control" placeholder="" ng-model="vm.replicationJobName" size="30">
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-primary" type="button" ng-click="vm.searchReplicationJob()"><span class="glyphicon glyphicon-search"></span></button>
|
||||
</span>
|
||||
|
@ -12,17 +12,16 @@
|
||||
<div class="sub-pane">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<th>// 'username' | tr //</th><th>// 'role' | tr //</th><th>// 'email' | tr //</th><th>// 'registration_time' | tr //</th><th>// 'operation' | tr //</th>
|
||||
<th>// 'username' | tr //</th><th>// 'email' | tr //</th><th>// 'registration_time' | tr //</th><th>// 'operation' | tr //</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="u in vm.users">
|
||||
<td>//u.username//</td>
|
||||
<td>N/A</td>
|
||||
<td>//u.email//</td>
|
||||
<td>//u.creation_time | dateL : 'YYYY-MM-DD HH:mm:ss'//</td>
|
||||
<td>
|
||||
<toggle-admin has-admin-role="u.HasAdminRole == 1" user-id="//u.UserId//"></toggle-admin>
|
||||
<a href="javascript:void(0)" ng-click="vm.deleteUser(u.UserId)"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
<toggle-admin has-admin-role="u.has_admin_role == 1" user-id="//u.user_id//"></toggle-admin>
|
||||
<a href="javascript:void(0)" ng-click="vm.deleteUser(u.user_id)"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -12,10 +12,11 @@
|
||||
var vm = this;
|
||||
|
||||
vm.isAdmin = (vm.hasAdminRole == 1) ? true : false;
|
||||
vm.enabled = vm.isAdmin ? 0 : 1;
|
||||
vm.toggle = toggle;
|
||||
|
||||
function toggle() {
|
||||
ToggleAdminService(vm.userId)
|
||||
ToggleAdminService(vm.userId, vm.enabled)
|
||||
.success(toggleAdminSuccess)
|
||||
.error(toggleAdminFailed);
|
||||
}
|
||||
|
@ -36,8 +36,11 @@
|
||||
}
|
||||
|
||||
function getProjectRole(roleId) {
|
||||
var role = getRole({'key': 'roleId', 'value': roleId});
|
||||
return role.name;
|
||||
if(roleId !== 0) {
|
||||
var role = getRole({'key': 'roleId', 'value': roleId});
|
||||
return role.name;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function listProjectFailed(e) {
|
||||
|
@ -16,7 +16,7 @@
|
||||
return $http
|
||||
.post('/api/projects/' + projectId + '/members/', {
|
||||
'roles': [ Number(roles) ],
|
||||
'user_name': username
|
||||
'username': username
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,11 @@
|
||||
|
||||
return toggleAdmin;
|
||||
|
||||
function toggleAdmin(userId) {
|
||||
function toggleAdmin(userId, enabled) {
|
||||
return $http
|
||||
.put('/api/users/' + userId);
|
||||
.put('/api/users/' + userId + '/sysadmin', {
|
||||
'has_admin_role' : enabled
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
<div class="sub-pane">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<th>// 'project_name' | tr //</th><th>// 'repositories' | tr //</th><th>// 'role' | tr //</th><th>// 'creation_time' | tr //</th><th>// 'publicity' | tr //</th>
|
||||
<th>// 'project_name' | tr //</th><th>// 'repositories' | tr //</th><th ng-if="!vm.publicity">// 'role' | tr //</th><th>// 'creation_time' | tr //</th><th>// 'publicity' | tr //</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
@ -36,7 +36,7 @@
|
||||
<tr ng-if="vm.projects.length > 0" ng-repeat="p in vm.projects">
|
||||
<td><a href="/repository#/repositories?project_id=//p.project_id//&is_public=//p.public//">//p.name//</a></td>
|
||||
<td>//p.repo_count//</td>
|
||||
<td>//vm.getProjectRole(p.current_user_role_id)//</td>
|
||||
<td ng-if="!vm.publicity">//vm.getProjectRole(p.current_user_role_id)//</td>
|
||||
<td>//p.creation_time | dateL : 'YYYY-MM-DD HH:mm:ss'//</td>
|
||||
<td><publicity-button is-public="p.public" owned="p.owner_id == vm.user.user_id" project-id="p.project_id"></publicity-button></td>
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user