mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-27 04:35:16 +01:00
updates for changing user's role feature.
This commit is contained in:
parent
ca2b71bd6d
commit
fd9f7d0e64
@ -0,0 +1,6 @@
|
||||
<ng-switch on="vm.editMode">
|
||||
<span ng-switch-default>//vm.currentRole.name//</span>
|
||||
<select ng-switch-when="true" >
|
||||
<option value="//role.id//" ng-click="vm.selectRole(role)" ng-repeat="role in vm.roles">//role.name//</option>
|
||||
</select>
|
||||
</ng-switch>
|
@ -0,0 +1,51 @@
|
||||
(function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('harbor.details')
|
||||
.directive('switchRoles', switchRoles);
|
||||
|
||||
|
||||
SwitchRolesController.$inject = [];
|
||||
|
||||
function SwitchRolesController() {
|
||||
var vm = this;
|
||||
|
||||
vm.currentRole = getRoleById(vm.roleId);
|
||||
vm.selectRole = selectRole;
|
||||
|
||||
function selectRole(role) {
|
||||
vm.roleId = role.id;
|
||||
vm.currentRole = getRoleById(vm.roleId);
|
||||
}
|
||||
|
||||
function getRoleById(roleId) {
|
||||
for(var i = 0; i < vm.roles.length; i++) {
|
||||
var role = vm.roles[i];
|
||||
if(role.id == roleId) {
|
||||
return role;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function switchRoles() {
|
||||
var directive = {
|
||||
'restrict': 'E',
|
||||
'templateUrl': '/static/ng/resources/js/components/details/switch-roles.directive.html',
|
||||
'scope': {
|
||||
'roles': '=',
|
||||
'editMode': '=',
|
||||
'userId': '=',
|
||||
'roleId': '=',
|
||||
},
|
||||
'controller' : SwitchRolesController,
|
||||
'controllerAs': 'vm',
|
||||
'bindToController': true
|
||||
};
|
||||
return directive;
|
||||
}
|
||||
|
||||
})();
|
@ -1,15 +0,0 @@
|
||||
(function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('harbor.projectmember')
|
||||
.controller('EditProjectMemberController', EditProjectMemberController);
|
||||
|
||||
EditProjectMemberController.$inject = ['EditProjectMemberService'];
|
||||
|
||||
function EditProjectMemberController(EditProjectMemberService) {
|
||||
|
||||
}
|
||||
|
||||
})();
|
@ -0,0 +1,11 @@
|
||||
<td>user1</td>
|
||||
<td><switch-roles roles="vm.roles" edit-mode="vm.editMode" user-id="vm.userId" role-id="vm.roleId"></switch-roles></td>
|
||||
<td>
|
||||
<a href="javascript:;" ng-click="vm.update({roleId: vm.roleId})">
|
||||
<ng-switch on="vm.editMode">
|
||||
<span ng-switch-default class="glyphicon glyphicon-pencil"></span>
|
||||
<span ng-switch-when="true" class="glyphicon glyphicon-ok"></span>
|
||||
</ng-switch>
|
||||
</a>
|
||||
<a href="#"><span class="glyphicon glyphicon-trash"></span></a>
|
||||
</td>
|
@ -0,0 +1,52 @@
|
||||
(function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('harbor.projectmember')
|
||||
.constant('roles', roles)
|
||||
.directive('editProjectMember', editProjectMember);
|
||||
|
||||
function roles() {
|
||||
return [
|
||||
{'id': '1', 'name': 'Project Admin'},
|
||||
{'id': '2', 'name': 'Developer'},
|
||||
{'id': '3', 'name': 'Guest'}
|
||||
];
|
||||
}
|
||||
|
||||
EditProjectMemberController.$inject = ['roles', 'EditProjectMemberService'];
|
||||
|
||||
function EditProjectMemberController(roles, EditProjectMemberService) {
|
||||
var vm = this;
|
||||
vm.roles = roles();
|
||||
vm.editMode = false;
|
||||
vm.update = update;
|
||||
|
||||
function update(e) {
|
||||
if(vm.editMode) {
|
||||
vm.editMode = false;
|
||||
}else {
|
||||
vm.editMode = true;
|
||||
}
|
||||
vm.roleId = e.roleId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function editProjectMember() {
|
||||
var directive = {
|
||||
'restrict': 'A',
|
||||
'templateUrl': '/static/ng/resources/js/components/projectmember/edit-projectmember.directive.html',
|
||||
'scope': {
|
||||
'userId': '=',
|
||||
'roleId': '='
|
||||
},
|
||||
'controller': EditProjectMemberController,
|
||||
'controllerAs': 'vm',
|
||||
'bindToController': true
|
||||
};
|
||||
return directive;
|
||||
}
|
||||
|
||||
})();
|
@ -44,15 +44,7 @@
|
||||
<th>Username</th><th>Role</th><th>Operation</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>user1</td><td>3</td><td>Project Admin</td><td><a href="#"><span class="glyphicon glyphicon-pencil"></span></a><a href="#"><span class="glyphicon glyphicon-trash"></span></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>tester1</td><td>3</td><td>Project Admin</td><td><a href="#"><span class="glyphicon glyphicon-pencil"></span></a><a href="#"><span class="glyphicon glyphicon-trash"></span></a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>user1</td><td>3</td><td>Project Admin</td><td><a href="#"><span class="glyphicon glyphicon-pencil"></span></a><a href="#"><span class="glyphicon glyphicon-trash"></span></a></td>
|
||||
</tr>
|
||||
<tr edit-project-member user-id="1" role-id="2"></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
@ -9,10 +9,12 @@
|
||||
'harbor.layout.log',
|
||||
'harbor.services.user',
|
||||
'harbor.services.repository',
|
||||
'harbor.services.projectmember',
|
||||
'harbor.session',
|
||||
'harbor.header',
|
||||
'harbor.details',
|
||||
'harbor.repository',
|
||||
'harbor.projectmember',
|
||||
'harbor.user',
|
||||
'harbor.log'
|
||||
]);
|
||||
|
@ -55,6 +55,9 @@
|
||||
<script src="/static/ng/resources/js/services/repository/services.repository.module.js"></script>
|
||||
<script src="/static/ng/resources/js/services/repository/services.list-repository.js"></script>
|
||||
|
||||
<script src="/static/ng/resources/js/services/projectmember/services.projectmember.module.js"></script>
|
||||
<script src="/static/ng/resources/js/services/projectmember/services.edit-projectmember.js"></script>
|
||||
|
||||
<script src="/static/ng/resources/js/services/log/services.log.module.js"></script>
|
||||
<script src="/static/ng/resources/js/services/log/services.list-log.js"></script>
|
||||
|
||||
@ -66,6 +69,7 @@
|
||||
|
||||
<script src="/static/ng/resources/js/components/details/switch-pane-projects.directive.js"></script>
|
||||
<script src="/static/ng/resources/js/components/details/retrieve-projects.directive.js"></script>
|
||||
<script src="/static/ng/resources/js/components/details/switch-roles.directive.js"></script>
|
||||
|
||||
<script src="/static/ng/resources/js/components/repository/repository.module.js"></script>
|
||||
<script src="/static/ng/resources/js/components/repository/list-repository.directive.js"></script>
|
||||
@ -73,6 +77,9 @@
|
||||
<script src="/static/ng/resources/js/components/user/user.module.js"></script>
|
||||
<script src="/static/ng/resources/js/components/user/list-user.directive.js"></script>
|
||||
|
||||
<script src="/static/ng/resources/js/components/projectmember/projectmember.module.js"></script>
|
||||
<script src="/static/ng/resources/js/components/projectmember/edit-projectmember.directive.js"></script>
|
||||
|
||||
<script src="/static/ng/resources/js/components/log/log.module.js"></script>
|
||||
<script src="/static/ng/resources/js/components/log/list-log.directive.js"></script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user