update for user settings and listing project role.

This commit is contained in:
kunw 2016-06-17 15:22:58 +08:00
parent b525062cea
commit d9825763cf
9 changed files with 20 additions and 16 deletions

View File

@ -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)

View File

@ -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'}

View File

@ -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>

View File

@ -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>&nbsp;&nbsp;
&nbsp;&nbsp;<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>&nbsp;&nbsp;
&nbsp;&nbsp;<a href="javascript:void(0)" ng-click="vm.deleteUser(u.user_id)"><span class="glyphicon glyphicon-trash"></span></a>
</td>
</tr>
</tbody>

View File

@ -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);
}

View File

@ -36,9 +36,12 @@
}
function getProjectRole(roleId) {
if(roleId !== 0) {
var role = getRole({'key': 'roleId', 'value': roleId});
return role.name;
}
return '';
}
function listProjectFailed(e) {
console.log('Failed to list Project:' + e);

View File

@ -16,7 +16,7 @@
return $http
.post('/api/projects/' + projectId + '/members/', {
'roles': [ Number(roles) ],
'user_name': username
'username': username
});
}

View File

@ -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
});
}
}

View File

@ -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>