mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Added users attached to roles on role edit page.
This commit is contained in:
parent
7dd4702680
commit
488175cc2e
@ -258,6 +258,8 @@ class PanelHandler(BaseHandler):
|
||||
elif page == 'panel_config':
|
||||
auth_servers = {}
|
||||
auth_role_servers = {}
|
||||
users_list = []
|
||||
role_users = {}
|
||||
roles = db_helper.get_all_roles()
|
||||
role_servers = []
|
||||
user_roles = {}
|
||||
@ -279,6 +281,7 @@ class PanelHandler(BaseHandler):
|
||||
data = {role['role_id']: role_servers}
|
||||
auth_role_servers.update(data)
|
||||
|
||||
|
||||
page_data['auth-servers'] = auth_servers
|
||||
page_data['role-servers'] = auth_role_servers
|
||||
page_data['user-roles'] = user_roles
|
||||
@ -341,14 +344,14 @@ class PanelHandler(BaseHandler):
|
||||
page_data['roles_all'] = db_helper.get_all_roles()
|
||||
page_data['servers_all'] = self.controller.list_defined_servers()
|
||||
|
||||
if not exec_user['superuser']:
|
||||
if user_id is None:
|
||||
self.redirect("/panel/error?error=Invalid User ID")
|
||||
return
|
||||
elif not exec_user['superuser']:
|
||||
page_data['servers'] = []
|
||||
page_data['role-servers'] = []
|
||||
page_data['roles_all'] = []
|
||||
page_data['servers_all'] = []
|
||||
elif user_id is None:
|
||||
self.redirect("/panel/error?error=Invalid User ID")
|
||||
return
|
||||
|
||||
if exec_user['user_id'] != page_data['user']['user_id']:
|
||||
page_data['user']['api_token'] = "********"
|
||||
@ -398,10 +401,20 @@ class PanelHandler(BaseHandler):
|
||||
template = "panel/panel_edit_role.html"
|
||||
|
||||
elif page == "edit_role":
|
||||
auth_servers = {}
|
||||
|
||||
user_roles = {}
|
||||
for user in db_helper.get_all_users():
|
||||
user_roles_list = db_helper.get_user_roles_names(user.user_id)
|
||||
user_servers = db_helper.get_all_authorized_servers(user.user_id)
|
||||
data = {user.user_id: user_roles_list}
|
||||
user_roles.update(data)
|
||||
page_data['new_role'] = False
|
||||
role_id = self.get_argument('id', None)
|
||||
page_data['role'] = db_helper.get_role(role_id)
|
||||
page_data['servers_all'] = self.controller.list_defined_servers()
|
||||
page_data['user-roles'] = user_roles
|
||||
page_data['users'] = db_helper.get_all_users()
|
||||
|
||||
if not exec_user['superuser']:
|
||||
self.redirect("/panel/error?error=Unauthorized access: not superuser")
|
||||
|
@ -105,6 +105,7 @@
|
||||
<tr class="rounded">
|
||||
<th>Role</th>
|
||||
<th>Allowed Servers</th>
|
||||
<th>Role Users</th>
|
||||
<th>Edit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -117,6 +118,16 @@
|
||||
<li>{{item}}</li>
|
||||
{% end %}
|
||||
</ul></td>
|
||||
<td><ul>
|
||||
{% for user in data['users'] %}
|
||||
{% for ruser in data['user-roles'][user.user_id] %}
|
||||
{% if ruser == role.role_name %}
|
||||
<li>{{ user.username }}</li>
|
||||
{% end %}
|
||||
{% end %}
|
||||
{% end %}
|
||||
</ul>
|
||||
</td>
|
||||
<td><a href="/panel/edit_role?id={{role.role_id}}"><i class="fas fa-pencil-alt"></i></a></td>
|
||||
</tr>
|
||||
{% end %}
|
||||
|
@ -48,7 +48,6 @@
|
||||
<i class="fas fa-folder-tree"></i>Other</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-sm-12">
|
||||
{% if data['new_role'] %}
|
||||
@ -97,9 +96,22 @@
|
||||
<button type="submit" class="btn btn-success mr-2">Save</button>
|
||||
<button type="reset" onclick="location.href='/panel/panel_config'" class="btn btn-light">Cancel</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 col-sm-12">
|
||||
</div>
|
||||
<div class="col-md-3 col-sm-12">
|
||||
<h6>Users Assigned to Role:</h6>
|
||||
<ul>
|
||||
{% for user in data['users'] %}
|
||||
{% for ruser in data['user-roles'][user.user_id] %}
|
||||
{% if ruser == data['role']['role_name'] %}
|
||||
<li>{{ user.username }}</li>
|
||||
{% end %}
|
||||
{% end %}
|
||||
{% end %}
|
||||
</ul>
|
||||
<br>
|
||||
</div>
|
||||
<div class="col-md-3 col-sm-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="card-title">Role Config Area</h4>
|
||||
@ -114,7 +126,9 @@
|
||||
</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
{% if data['new_role'] %}
|
||||
<a class="btn btn-sm btn-danger disabled">Delete Role</a><br />
|
||||
<small>You cannot delete something that does not yet exist</small>
|
||||
@ -123,8 +137,6 @@
|
||||
{% end %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user