Disable role selection for Cloudrons with user restriction

This commit is contained in:
Johannes Zellner
2020-02-26 16:48:51 +01:00
parent a3830d23e8
commit e7b9c2d294
3 changed files with 20 additions and 9 deletions
+4 -4
View File
@@ -44,10 +44,10 @@
</div>
</div>
<div class="form-group">
<div class="form-group" ng-show="userInfo.isAtLeastOwner">
<label class="control-label">Role</label>
<div class="control-label">
<select class="form-control" ng-model="useradd.role" ng-options="a.id as a.name for a in roles" ng-disabled="!userInfo.isAtLeastOwner"></select>
<select class="form-control" ng-model="useradd.role" ng-options="role.id as role.name disable when role.disabled for role in roles"></select>
</div>
</div>
@@ -128,10 +128,10 @@
</div>
<input type="fallbackEmail" class="form-control" ng-model="useredit.fallbackEmail" name="fallbackEmail" required>
</div>
<div class="form-group" ng-hide="isMe(useredit.userInfo) || userInfo.role === 'user' || userInfo.role === 'usermanager'">
<div class="form-group" ng-show="!isMe(useredit.userInfo) && userInfo.isAtLeastOwner">
<label class="control-label">Role</label>
<div class="control-label">
<select class="form-control" ng-model="useredit.role" ng-options="a.id as a.name for a in roles"></select>
<select class="form-control" ng-model="useredit.role" ng-options="role.id as role.name disable when role.disabled for role in roles"></select>
</div>
</div>
<div class="form-group">
+15 -4
View File
@@ -26,10 +26,10 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$scope.userInfo = Client.getUserInfo();
$scope.roles = [
{ id: 'user', name: 'User' },
{ id: 'usermanager', name: 'User Manager' },
{ id: 'admin', name: 'Administrator' },
{ id: 'owner', name: 'Owner' }
{ id: 'user', name: 'User', disabled: false },
{ id: 'usermanager', name: 'User Manager', disabled: true },
{ id: 'admin', name: 'Administrator', disabled: true },
{ id: 'owner', name: 'Owner', disabled: true }
];
$scope.allUsers = [];
@@ -681,6 +681,17 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
}
});
});
Client.onReady(function () {
// Update available roles depending on features
if ($scope.config.features.userMaxCount === null) {
$scope.roles = [
{ id: 'user', name: 'User', disabled: false },
{ id: 'usermanager', name: 'User Manager', disabled: false },
{ id: 'admin', name: 'Administrator', disabled: false },
{ id: 'owner', name: 'Owner', disabled: false }
];
}
});
// setup all the dialog focus handling
['userAddModal', 'userRemoveModal', 'userEditModal', 'groupAddModal', 'groupEditModal', 'groupRemoveModal'].forEach(function (id) {