mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 14:40:27 +00:00
Completed first-found updates for the users list view.
This commit is contained in:
parent
0e67366c5f
commit
9ac81363e3
@ -1,237 +1,243 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% set active_page = "admin_users" %}
|
||||
|
||||
{% block title %}
|
||||
<title>
|
||||
User Management - {{ SITE_NAME }}
|
||||
</title>
|
||||
{% endblock %}
|
||||
{% block title %}<title>Users - {{ SITE_NAME }}</title>{% endblock %}
|
||||
|
||||
{% block dashboard_stat %}
|
||||
<div class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1 class="m-0 text-dark">
|
||||
User
|
||||
<small>Manage user privileges</small>
|
||||
</h1>
|
||||
<div class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1 class="m-0 text-dark">Users</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="{{ url_for('dashboard.dashboard') }}">Home</a></li>
|
||||
<li class="breadcrumb-item active">Users</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="{{ url_for('dashboard.dashboard') }}">Home</a></li>
|
||||
<li class="breadcrumb-item active">User</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">User Management</h3>
|
||||
<a href="{{ url_for('admin.edit_user') }}">
|
||||
<button type="button" class="btn btn-primary float-right button_add_user">
|
||||
<i class="fa-solid fa-plus"></i> Add User
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table id="tbl_users" class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>First Name</th>
|
||||
<th>Last Name</th>
|
||||
<th>Email</th>
|
||||
<th>Role</th>
|
||||
<th>Privileges</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in users %}
|
||||
<tr class="odd gradeX">
|
||||
<td>{{ user.username }}</td>
|
||||
<td>{{ user.firstname }}</td>
|
||||
<td>{{ user.lastname }}</td>
|
||||
<td>{{ user.email }}</td>
|
||||
<td>
|
||||
<select id="{{ user.username }}" class="user_role"
|
||||
{% if user.username==current_user.username or (current_user.role.name=='Operator' and user.role.name=='Administrator') %}disabled{% endif %}>
|
||||
{% for role in roles %}
|
||||
<option value="{{ role.name }}"
|
||||
{% if role.id==user.role.id %}selected{% endif %}>
|
||||
{{ role.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td width="6%">
|
||||
<button type="button" class="btn btn-warning button_revoke"
|
||||
id="{{ user.username }}"
|
||||
{% if current_user.role.name=='Operator' and user.role.name=='Administrator' %}disabled{% endif %}>
|
||||
<i class="fa-solid fa-link-slash"></i> Revoke
|
||||
</button>
|
||||
</td>
|
||||
<td width="15%">
|
||||
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
|
||||
{% if current_user.role.name=='Operator' and user.role.name=='Administrator' %}disabled{% endif %}>
|
||||
<i class="fa-solid fa-bars"></i> Actions
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenu">
|
||||
<button type="button" class="dropdown-item btn-warning" onclick="window.location.href='{{ url_for('admin.edit_user', user_username=user.username) }}'">
|
||||
<i class="fa-solid fa-edit"></i> Edit User
|
||||
</button>
|
||||
{% if not user.username==current_user.username or (current_user.role.name=='Operator' and user.role.name=='Administrator') %}
|
||||
<div class="dropdown-divider"></div>
|
||||
<button type="button"class="dropdown-item btn-secondary button_delete" id="{{ user.username }}">
|
||||
<font color="red">
|
||||
<i class="fa-solid fa-trash"></i> Delete User
|
||||
</font>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card card-outline card-primary shadow">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Users</h3>
|
||||
<div class="card-tools">
|
||||
<a href="{{ url_for('admin.edit_user') }}">
|
||||
<button type="button" class="btn btn-primary button_add_user" title="Create User">
|
||||
<i class="fa-solid fa-plus"></i> Create User
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
<!-- /.card-tools -->
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- /.card-header -->
|
||||
<div class="card-body table-responsive">
|
||||
<table id="tbl_users"
|
||||
class="table table-bordered table-striped table-hover table-sm records">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>First Name</th>
|
||||
<th>Last Name</th>
|
||||
<th>Email</th>
|
||||
<th>Role</th>
|
||||
<th>Privileges</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in users %}
|
||||
<tr class="odd gradeX">
|
||||
<td>{{ user.username }}</td>
|
||||
<td>{{ user.firstname }}</td>
|
||||
<td>{{ user.lastname }}</td>
|
||||
<td>{{ user.email }}</td>
|
||||
<td>
|
||||
<select id="{{ user.username }}" class="user_role"
|
||||
{% if user.username==current_user.username or (current_user.role.name=='Operator' and user.role.name=='Administrator') %}disabled{% endif %}>
|
||||
{% for role in roles %}
|
||||
<option value="{{ role.name }}"
|
||||
{% if role.id==user.role.id %}selected{% endif %}>
|
||||
{{ role.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-warning button_revoke"
|
||||
title="Revoke Privileges"
|
||||
id="{{ user.username }}"
|
||||
{% if current_user.role.name=='Operator' and user.role.name=='Administrator' %}disabled{% endif %}>
|
||||
<i class="fa-solid fa-link-slash"></i>
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-primary dropdown-toggle" type="button"
|
||||
id="dropdownMenu" data-toggle="dropdown" aria-haspopup="true"
|
||||
aria-expanded="false"
|
||||
{% if current_user.role.name=='Operator' and user.role.name=='Administrator' %}disabled{% endif %}>
|
||||
<i class="fa-solid fa-bars"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenu">
|
||||
<button type="button" class="dropdown-item btn-warning"
|
||||
onclick="window.location.href='{{ url_for('admin.edit_user', user_username=user.username) }}'">
|
||||
<i class="fa-solid fa-edit"></i> Edit User
|
||||
</button>
|
||||
{% if not user.username==current_user.username or (current_user.role.name=='Operator' and user.role.name=='Administrator') %}
|
||||
<div class="dropdown-divider"></div>
|
||||
<button type="button"
|
||||
class="dropdown-item btn-secondary button_delete"
|
||||
id="{{ user.username }}">
|
||||
<span style="color: red;">
|
||||
<i class="fa-solid fa-trash"></i> Delete User
|
||||
</span>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- /.card-body -->
|
||||
</div>
|
||||
<!-- /.card -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!-- /.container-fluid -->
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
||||
{% block extrascripts %}
|
||||
<script>
|
||||
// set up user data table
|
||||
$("#tbl_users").DataTable({
|
||||
"paging": true,
|
||||
"lengthChange": true,
|
||||
"searching": true,
|
||||
"ordering": true,
|
||||
"info": false,
|
||||
"autoWidth": false,
|
||||
"lengthMenu": [
|
||||
[10, 25, 50, 100, -1],
|
||||
[10, 25, 50, 100, "All"]
|
||||
],
|
||||
"pageLength": 10
|
||||
});
|
||||
<script>
|
||||
// set up user data table
|
||||
$("#tbl_users").DataTable({
|
||||
"paging": true,
|
||||
"lengthChange": true,
|
||||
"searching": true,
|
||||
"ordering": true,
|
||||
"info": false,
|
||||
"autoWidth": false,
|
||||
"lengthMenu": [
|
||||
[10, 25, 50, 100, -1],
|
||||
[10, 25, 50, 100, "All"]
|
||||
],
|
||||
"pageLength": 10
|
||||
});
|
||||
|
||||
// handle revocation of privileges
|
||||
$(document.body).on('click', '.button_revoke', function () {
|
||||
var modal = $("#modal_revoke");
|
||||
var username = $(this).prop('id');
|
||||
var info = "Are you sure you want to revoke all privileges for user " + username +
|
||||
"? They will not able to access any domain.";
|
||||
modal.find('.modal-body p').text(info);
|
||||
modal.find('#button_revoke_confirm').click(function () {
|
||||
var postdata = {
|
||||
'action': 'revoke_user_privileges',
|
||||
'data': username,
|
||||
'_csrf_token': '{{ csrf_token() }}'
|
||||
}
|
||||
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manage-user', true);
|
||||
modal.modal('hide');
|
||||
})
|
||||
modal.modal('show');
|
||||
});
|
||||
// handle revocation of privileges
|
||||
$(document.body).on('click', '.button_revoke', function () {
|
||||
var modal = $("#modal_revoke");
|
||||
var username = $(this).prop('id');
|
||||
var info = "Are you sure you want to revoke all privileges for user " + username +
|
||||
"? They will not able to access any domain.";
|
||||
modal.find('.modal-body p').text(info);
|
||||
modal.find('#button_revoke_confirm').click(function () {
|
||||
var postdata = {
|
||||
'action': 'revoke_user_privileges',
|
||||
'data': username,
|
||||
'_csrf_token': '{{ csrf_token() }}'
|
||||
}
|
||||
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manage-user', true);
|
||||
modal.modal('hide');
|
||||
})
|
||||
modal.modal('show');
|
||||
});
|
||||
|
||||
// handle deletion of user
|
||||
$(document.body).on('click', '.button_delete', function () {
|
||||
var modal = $("#modal_delete");
|
||||
var username = $(this).prop('id');
|
||||
var info = "Are you sure you want to delete user " + username + "?";
|
||||
modal.find('.modal-body p').text(info);
|
||||
modal.find('#button_delete_confirm').click(function () {
|
||||
var postdata = {
|
||||
'action': 'delete_user',
|
||||
'data': username,
|
||||
'_csrf_token': '{{ csrf_token() }}'
|
||||
}
|
||||
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manage-user', false, true);
|
||||
modal.modal('hide');
|
||||
})
|
||||
modal.modal('show');
|
||||
});
|
||||
// handle deletion of user
|
||||
$(document.body).on('click', '.button_delete', function () {
|
||||
var modal = $("#modal_delete");
|
||||
var username = $(this).prop('id');
|
||||
var info = "Are you sure you want to delete user " + username + "?";
|
||||
modal.find('.modal-body p').text(info);
|
||||
modal.find('#button_delete_confirm').click(function () {
|
||||
var postdata = {
|
||||
'action': 'delete_user',
|
||||
'data': username,
|
||||
'_csrf_token': '{{ csrf_token() }}'
|
||||
}
|
||||
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manage-user', false, true);
|
||||
modal.modal('hide');
|
||||
})
|
||||
modal.modal('show');
|
||||
});
|
||||
|
||||
// handle user role changing
|
||||
$(document.body).on('change', '.user_role', function () {
|
||||
var role_name = this.value;
|
||||
var username = $(this).prop('id');
|
||||
var postdata = {
|
||||
'action': 'update_user_role',
|
||||
'data': {
|
||||
'username': username,
|
||||
'role_name': role_name
|
||||
},
|
||||
'_csrf_token': '{{ csrf_token() }}'
|
||||
};
|
||||
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manage-user', showResult = true);
|
||||
});
|
||||
</script>
|
||||
// handle user role changing
|
||||
$(document.body).on('change', '.user_role', function () {
|
||||
var role_name = this.value;
|
||||
var username = $(this).prop('id');
|
||||
var postdata = {
|
||||
'action': 'update_user_role',
|
||||
'data': {
|
||||
'username': username,
|
||||
'role_name': role_name
|
||||
},
|
||||
'_csrf_token': '{{ csrf_token() }}'
|
||||
};
|
||||
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manage-user', showResult = true);
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block modals %}
|
||||
<div class="modal fade" id="modal_revoke">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Confirmation</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<div class="modal fade" id="modal_revoke">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Confirmation</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary float-right" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger float-right" id="button_revoke_confirm">
|
||||
Revoke
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary float-right" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger float-right" id="button_revoke_confirm">
|
||||
Revoke
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="modal_delete">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Confirmation</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<div class="modal fade" id="modal_delete">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Confirmation</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default float-right" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger float-right" id="button_delete_confirm">
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default float-right" data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger float-right" id="button_delete_confirm">
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user