updates for toggling project publicity and block user remove admin role with himself.

This commit is contained in:
kunw 2016-08-08 17:31:57 +08:00
parent 5cf6f99025
commit a7f0037156
5 changed files with 12 additions and 8 deletions

View File

@ -12,5 +12,5 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<button ng-if="vm.isPublic" ng-disabled="!vm.owned" class="btn btn-success" ng-click="vm.toggle()">// 'button_on' | tr //</button> <button ng-if="vm.isPublic" class="btn btn-success" ng-click="vm.toggle()">// 'button_on' | tr //</button>
<button ng-if="!vm.isPublic" ng-disabled="!vm.owned" class="btn btn-danger" ng-click="vm.toggle()">// 'button_off' | tr //</button> <button ng-if="!vm.isPublic" class="btn btn-danger" ng-click="vm.toggle()">// 'button_off' | tr //</button>

View File

@ -44,10 +44,10 @@
<td width="20%">//u.email//</td> <td width="20%">//u.email//</td>
<td width="35%">//u.creation_time | dateL : 'YYYY-MM-DD HH:mm:ss'//</td> <td width="35%">//u.creation_time | dateL : 'YYYY-MM-DD HH:mm:ss'//</td>
<td width="15%"> <td width="15%">
<toggle-admin has-admin-role="u.has_admin_role" user-id="//u.user_id//"></toggle-admin> <toggle-admin current-user="vm.currentUser" has-admin-role="u.has_admin_role" user-id="//u.user_id//"></toggle-admin>
</td> </td>
<td width="20%"> <td width="20%">
&nbsp;&nbsp;<a href="javascript:void(0)" ng-click="vm.confirmToDelete(u.user_id, u.username)"><span class="glyphicon glyphicon-trash"></span></a> &nbsp;&nbsp;<a ng-if="vm.currentUser.user_id != u.user_id" href="javascript:void(0)" ng-click="vm.confirmToDelete(u.user_id, u.username)"><span class="glyphicon glyphicon-trash"></span></a>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@ -20,9 +20,9 @@
.module('harbor.user') .module('harbor.user')
.directive('listUser', listUser); .directive('listUser', listUser);
ListUserController.$inject = ['$scope', 'ListUserService', 'DeleteUserService', '$filter', 'trFilter']; ListUserController.$inject = ['$scope', 'ListUserService', 'DeleteUserService', 'currentUser', '$filter', 'trFilter'];
function ListUserController($scope, ListUserService, DeleteUserService, $filter, $trFilter) { function ListUserController($scope, ListUserService, DeleteUserService, currentUser, $filter, $trFilter) {
$scope.subsSubPane = 226; $scope.subsSubPane = 226;
@ -33,6 +33,8 @@
vm.deleteUser = deleteUser; vm.deleteUser = deleteUser;
vm.confirmToDelete = confirmToDelete; vm.confirmToDelete = confirmToDelete;
vm.retrieve = retrieve; vm.retrieve = retrieve;
vm.currentUser = currentUser.get();
vm.retrieve(); vm.retrieve();

View File

@ -12,5 +12,5 @@
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<button ng-show="vm.isAdmin" class="btn btn-success" ng-click="vm.toggle()">// 'button_on' | tr //</button> <button ng-show="vm.isAdmin" ng-disabled="!vm.editable" class="btn btn-success" ng-click="vm.toggle()">// 'button_on' | tr //</button>
<button ng-show="!vm.isAdmin" class="btn btn-danger" ng-click="vm.toggle()">// 'button_off' | tr //</button> <button ng-show="!vm.isAdmin" class="btn btn-danger" ng-click="vm.toggle()">// 'button_off' | tr //</button>

View File

@ -28,6 +28,7 @@
vm.isAdmin = (vm.hasAdminRole === 1); vm.isAdmin = (vm.hasAdminRole === 1);
vm.enabled = vm.isAdmin ? 0 : 1; vm.enabled = vm.isAdmin ? 0 : 1;
vm.toggle = toggle; vm.toggle = toggle;
vm.editable = (vm.currentUser.user_id != vm.userId);
function toggle() { function toggle() {
ToggleAdminService(vm.userId, vm.enabled) ToggleAdminService(vm.userId, vm.enabled)
@ -63,7 +64,8 @@
'templateUrl': '/static/resources/js/components/user/toggle-admin.directive.html', 'templateUrl': '/static/resources/js/components/user/toggle-admin.directive.html',
'scope': { 'scope': {
'hasAdminRole': '=', 'hasAdminRole': '=',
'userId': '@' 'userId': '@',
'currentUser': '='
}, },
'link': link, 'link': link,
'controller': ToggleAdminController, 'controller': ToggleAdminController,