2018-08-18 11:41:59 +00:00
|
|
|
{% extends "base.html" %}
|
|
|
|
{% set active_page = "admin_users" %}
|
|
|
|
{% block title %}
|
2018-08-18 15:42:18 +00:00
|
|
|
<title>User Management - {{ SITE_NAME }}</title>
|
2016-04-23 02:02:42 +00:00
|
|
|
{% endblock %} {% block dashboard_stat %}
|
|
|
|
<section class="content-header">
|
2016-06-18 04:41:01 +00:00
|
|
|
<h1>
|
|
|
|
User <small>Manage user privileges</small>
|
|
|
|
</h1>
|
|
|
|
<ol class="breadcrumb">
|
|
|
|
<li><a href="{{ url_for('dashboard') }}"><i
|
|
|
|
class="fa fa-dashboard"></i> Home</a></li>
|
|
|
|
<li class="active">User</li>
|
|
|
|
</ol>
|
2016-04-23 02:02:42 +00:00
|
|
|
</section>
|
|
|
|
{% endblock %} {% block content %}
|
|
|
|
<section class="content">
|
2016-06-18 04:41:01 +00:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-xs-12">
|
|
|
|
<div class="box">
|
|
|
|
<div class="box-header">
|
|
|
|
<h3 class="box-title">User Management</h3>
|
|
|
|
</div>
|
|
|
|
<div class="box-body">
|
2018-08-12 09:40:32 +00:00
|
|
|
<a href="{{ url_for('admin_edituser') }}">
|
2016-06-18 04:41:01 +00:00
|
|
|
<button type="button" class="btn btn-flat btn-primary pull-left button_add_user">
|
|
|
|
Add User <i class="fa fa-plus"></i>
|
|
|
|
</button>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
<div class="box-body">
|
|
|
|
<table id="tbl_users" class="table table-bordered table-striped">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Username</th>
|
|
|
|
<th>First Name</th>
|
|
|
|
<th>Last Name</th>
|
2018-03-30 23:53:57 +00:00
|
|
|
<th>Email</th>
|
2018-08-31 04:57:06 +00:00
|
|
|
<th>Role</th>
|
2016-06-18 04:41:01 +00:00
|
|
|
<th>Privileges</th>
|
2018-08-12 09:40:32 +00:00
|
|
|
<th>Action</th>
|
2016-06-18 04:41:01 +00:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{% for user in users %}
|
|
|
|
<tr class="odd gradeX">
|
|
|
|
<td>{{ user.username }}</td>
|
|
|
|
<td>{{ user.firstname }}</td>
|
|
|
|
<td>{{ user.lastname }}</td>
|
2018-03-30 23:53:57 +00:00
|
|
|
<td>{{ user.email }}</td>
|
2016-06-18 04:41:01 +00:00
|
|
|
<td>
|
2018-08-31 04:57:06 +00:00
|
|
|
<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>
|
2016-06-18 04:41:01 +00:00
|
|
|
</td>
|
|
|
|
<td width="6%">
|
2018-08-31 04:57:06 +00:00
|
|
|
<button type="button" class="btn btn-flat btn-warning button_revoke" id="{{ user.username }}" {% if current_user.role.name=='Operator' and user.role.name=='Administrator' %}disabled{% endif %}>
|
2016-06-18 04:41:01 +00:00
|
|
|
Revoke <i class="fa fa-lock"></i>
|
|
|
|
</button>
|
|
|
|
</td>
|
2018-08-12 09:40:32 +00:00
|
|
|
<td width="15%">
|
2018-08-31 04:57:06 +00:00
|
|
|
<button type="button" class="btn btn-flat btn-success button_edit" onclick="window.location.href='{{ url_for('admin_edituser', user_username=user.username) }}'" {% if current_user.role.name=='Operator' and user.role.name=='Administrator' %}disabled{% endif %}>
|
2018-08-12 09:40:32 +00:00
|
|
|
Edit <i class="fa fa-lock"></i>
|
|
|
|
</button>
|
2018-08-31 04:57:06 +00:00
|
|
|
<button type="button" class="btn btn-flat btn-danger button_delete" id="{{ user.username }}" {% if user.username==current_user.username or (current_user.role.name=='Operator' and user.role.name=='Administrator') %}disabled{% endif %}>
|
2016-06-18 04:41:01 +00:00
|
|
|
Delete <i class="fa fa-trash"></i>
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<!-- /.box-body -->
|
|
|
|
</div>
|
|
|
|
<!-- /.box -->
|
|
|
|
</div>
|
|
|
|
<!-- /.col -->
|
|
|
|
</div>
|
|
|
|
<!-- /.row -->
|
2016-04-23 02:02:42 +00:00
|
|
|
</section>
|
|
|
|
{% endblock %}
|
|
|
|
{% block extrascripts %}
|
2015-12-13 09:34:12 +00:00
|
|
|
<script>
|
2016-06-18 04:41:01 +00:00
|
|
|
// set up user data table
|
|
|
|
$("#tbl_users").DataTable({
|
|
|
|
"paging" : true,
|
2018-04-01 08:48:08 +00:00
|
|
|
"lengthChange" : true,
|
2016-06-18 04:41:01 +00:00
|
|
|
"searching" : true,
|
|
|
|
"ordering" : true,
|
2018-04-01 08:48:08 +00:00
|
|
|
"info" : false,
|
|
|
|
"autoWidth" : false,
|
|
|
|
"lengthMenu": [ [10, 25, 50, 100, -1],
|
|
|
|
[10, 25, 50, 100, "All"]],
|
|
|
|
"pageLength": 10
|
2016-06-18 04:41:01 +00:00
|
|
|
});
|
2018-04-01 08:48:08 +00:00
|
|
|
|
2016-06-18 04:41:01 +00:00
|
|
|
// handle revocation of privileges
|
2016-07-01 22:31:14 +00:00
|
|
|
$(document.body).on('click', '.button_revoke', function() {
|
2016-06-18 04:41:01 +00:00
|
|
|
var modal = $("#modal_revoke");
|
|
|
|
var username = $(this).prop('id');
|
|
|
|
var info = "Are you sure you want to revoke all privileges for " + username + ". They will not able to access any domain.";
|
|
|
|
modal.find('.modal-body p').text(info);
|
|
|
|
modal.find('#button_revoke_confirm').click(function() {
|
2018-10-02 07:23:41 +00:00
|
|
|
var postdata = {'action': 'revoke_user_privileges', 'data': username}
|
2016-07-02 00:45:42 +00:00
|
|
|
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manageuser');
|
2016-06-18 04:41:01 +00:00
|
|
|
modal.modal('hide');
|
|
|
|
})
|
|
|
|
modal.modal('show');
|
|
|
|
});
|
|
|
|
// handle deletion of user
|
2016-07-01 22:31:14 +00:00
|
|
|
$(document.body).on('click', '.button_delete', function() {
|
2016-06-18 04:41:01 +00:00
|
|
|
var modal = $("#modal_delete");
|
|
|
|
var username = $(this).prop('id');
|
|
|
|
var info = "Are you sure you want to delete " + username + "?";
|
|
|
|
modal.find('.modal-body p').text(info);
|
|
|
|
modal.find('#button_delete_confirm').click(function() {
|
|
|
|
var postdata = {'action': 'delete_user', 'data': username}
|
2016-07-02 00:45:42 +00:00
|
|
|
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manageuser', false, true);
|
2016-06-18 04:41:01 +00:00
|
|
|
modal.modal('hide');
|
|
|
|
})
|
|
|
|
modal.modal('show');
|
|
|
|
|
|
|
|
});
|
2016-04-23 02:02:42 +00:00
|
|
|
|
2018-08-31 04:57:06 +00:00
|
|
|
// handle user role changing
|
|
|
|
$('.user_role').on('change', function() {
|
|
|
|
var role_name = this.value;
|
2016-06-18 04:41:01 +00:00
|
|
|
var username = $(this).prop('id');
|
2018-09-06 04:35:54 +00:00
|
|
|
var postdata = {
|
2018-08-31 04:57:06 +00:00
|
|
|
'action' : 'update_user_role',
|
2016-06-18 04:41:01 +00:00
|
|
|
'data' : {
|
|
|
|
'username' : username,
|
2018-08-31 04:57:06 +00:00
|
|
|
'role_name' : role_name
|
2016-06-18 04:41:01 +00:00
|
|
|
}
|
|
|
|
};
|
2018-08-31 04:57:06 +00:00
|
|
|
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manageuser', showResult=true);
|
2016-06-18 04:41:01 +00:00
|
|
|
});
|
2015-12-13 09:34:12 +00:00
|
|
|
</script>
|
2016-04-23 02:02:42 +00:00
|
|
|
{% endblock %}
|
|
|
|
{% block modals %}
|
|
|
|
<div class="modal fade modal-warning" id="modal_revoke">
|
2016-06-18 04:41:01 +00:00
|
|
|
<div class="modal-dialog">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<button type="button" class="close" data-dismiss="modal"
|
|
|
|
aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
<h4 class="modal-title">Confirmation</h4>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<p></p>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-flat btn-default pull-left"
|
|
|
|
data-dismiss="modal">Close</button>
|
|
|
|
<button type="button" class="btn btn-flat btn-danger" id="button_revoke_confirm">Revoke</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- /.modal-content -->
|
|
|
|
</div>
|
|
|
|
<!-- /.modal-dialog -->
|
2016-04-23 02:02:42 +00:00
|
|
|
</div>
|
|
|
|
<div class="modal fade modal-warning" id="modal_delete">
|
2016-06-18 04:41:01 +00:00
|
|
|
<div class="modal-dialog">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<button type="button" class="close" data-dismiss="modal"
|
|
|
|
aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
<h4 class="modal-title">Confirmation</h4>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<p></p>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-flat btn-default pull-left"
|
|
|
|
data-dismiss="modal">Close</button>
|
|
|
|
<button type="button" class="btn btn-flat btn-danger" id="button_delete_confirm">Delete</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- /.modal-content -->
|
|
|
|
</div>
|
|
|
|
<!-- /.modal-dialog -->
|
2016-04-23 02:02:42 +00:00
|
|
|
</div>
|
2015-12-13 09:34:12 +00:00
|
|
|
{% endblock %}
|