Completed first-found updates for the accounts list view.

This commit is contained in:
Matt Scott 2023-02-20 08:50:17 -05:00
parent a42d610759
commit 8c6fc5e262

View File

@ -1,159 +1,167 @@
{% extends "base.html" %} {% extends "base.html" %}
{% set active_page = "admin_accounts" %} {% set active_page = "admin_accounts" %}
{% block title %}<title>Accounts - {{ SITE_NAME }}</title>{% endblock %}
{% block title %}
<title>
Account Management - {{ SITE_NAME }}
</title>
{% endblock %}
{% block dashboard_stat %} {% block dashboard_stat %}
<div class="content-header"> <div class="content-header">
<div class="container-fluid"> <div class="container-fluid">
<div class="row mb-2"> <div class="row mb-2">
<div class="col-sm-6"> <div class="col-sm-6">
<h1 class="m-0 text-dark"> <h1 class="m-0 text-dark">Accounts</h1>
Accounts </div>
<small>Manage</small> <div class="col-sm-6">
</h1> <ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ url_for('dashboard.dashboard') }}">Home</a></li>
<li class="breadcrumb-item active">Accounts</li>
</ol>
</div>
</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">Accounts</li>
</ol>
</div>
</div>
</div> </div>
</div>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<section class="content"> <section class="content">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card card-outline card-primary shadow">
<div class="card-header"> <div class="card-header">
<h3 class="card-title">Account Management</h3> <h3 class="card-title">Accounts</h3>
<a href="{{ url_for('admin.edit_account') }}"> <div class="card-tools">
<button type="button" class="btn btn-primary float-right button_add_account"> <a href="{{ url_for('admin.edit_account') }}">
<i class="fa-solid fa-plus"></i>&nbsp;Add Account <button type="button" class="btn btn-primary button_add_account"
</button> title="Add Account">
</a> <i class="fa-solid fa-plus"></i>&nbsp;Add Account
</div> </button>
<div class="card-body"> </a>
<table id="tbl_accounts" class="table table-bordered table-striped"> </div>
<thead> </div>
<tr> <!-- /.card-header -->
<th>Name</th> <div class="card-body table-responsive">
<th>Description</th> <table id="tbl_accounts"
<th>Contact</th> class="table table-bordered table-striped table-hover table-sm records">
<th>Mail</th> <thead>
<th>Member</th> <tr>
<th>Domain</th> <th>Name</th>
<th>Action</th> <th>Description</th>
</tr> <th>Contact</th>
</thead> <th>Mail</th>
<tbody> <th>Member</th>
{% for account in accounts %} <th>Domain</th>
<tr class="odd gradeX"> <th>Action</th>
<td>{{ account.name }}</td> </tr>
<td>{{ account.description }}</td> </thead>
<td>{{ account.contact }}</td> <tbody>
<td>{{ account.mail }}</td> {% for account in accounts %}
<td>{{ account.user_num }}</td> <tr class="odd gradeX">
<td>{{ account.domains|length }}</td> <td>{{ account.name }}</td>
<td width="15%"> <td>{{ account.description }}</td>
<div class="dropdown"> <td>{{ account.contact }}</td>
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <td>{{ account.mail }}</td>
<i class="fa-solid fa-bars"></i>&nbsp;Actions <td>{{ account.user_num }}</td>
</button> <td>{{ account.domains|length }}</td>
<div class="dropdown-menu" aria-labelledby="dropdownMenu"> <td>
<button type="button" class="dropdown-item btn-warning" onclick="window.location.href='{{ url_for('admin.edit_account', account_name=account.name) }}'"> <div class="dropdown">
<i class="fa-solid fa-edit"></i>&nbsp;Edit Account <button class="btn btn-primary dropdown-toggle" type="button"
</button> id="dropdownMenu" data-toggle="dropdown" aria-haspopup="true"
<div class="dropdown-divider"></div> aria-expanded="false">
<button type="button"class="dropdown-item btn-secondary button_delete" id="{{ account.name }}"> <i class="fa-solid fa-bars"></i>
<font color="red"> </button>
<i class="fa-solid fa-trash"></i>&nbsp;Delete Account <div class="dropdown-menu" aria-labelledby="dropdownMenu">
</font> <button type="button" class="dropdown-item btn-warning"
</button> onclick="window.location.href='{{ url_for('admin.edit_account', account_name=account.name) }}'">
</div> <i class="fa-solid fa-edit"></i>&nbsp;Edit Account
</div> </button>
</td> <div class="dropdown-divider"></div>
</tr> <button type="button"
{% endfor %} class="dropdown-item btn-secondary button_delete"
</tbody> id="{{ account.name }}">
</table> <span style="color: red;">
</div> <i class="fa-solid fa-trash"></i>&nbsp;Delete Account
</span>
</button>
</div>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div> </div>
</div> <!-- /.container-fluid -->
</div> </section>
</div>
</section>
{% endblock %} {% endblock %}
{% block extrascripts %}
<script>
// set up accounts data table
$("#tbl_accounts").DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"columnDefs": [{
"orderable": false,
"targets": [-1]
}],
"info": false,
"autoWidth": false,
"lengthMenu": [
[10, 25, 50, 100, -1],
[10, 25, 50, 100, "All"]
],
"pageLength": 10
});
// handle deletion of account {% block extrascripts %}
$(document.body).on('click', '.button_delete', function () { <script>
var modal = $("#modal_delete"); // Intialize DataTable
var accountname = $(this).prop('id'); $("#tbl_accounts").DataTable({
var info = "Are you sure you want to delete " + accountname + "?"; "paging": true,
modal.find('.modal-body p').text(info); "lengthChange": true,
modal.find('#button_delete_confirm').click(function () { "searching": true,
var postdata = { "ordering": true,
'action': 'delete_account', "columnDefs": [{
'data': accountname, "orderable": false,
'_csrf_token': '{{ csrf_token() }}' "targets": [-1]
} }],
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manage-account', false, true); "info": false,
modal.modal('hide'); "autoWidth": false,
}) "lengthMenu": [
modal.modal('show'); [10, 25, 50, 100, -1],
}); [10, 25, 50, 100, "All"]
</script> ],
"pageLength": 10
});
// handle deletion of account
$(document.body).on('click', '.button_delete', function () {
var modal = $("#modal_delete");
var accountname = $(this).prop('id');
var info = "Are you sure you want to delete " + accountname + "?";
modal.find('.modal-body p').text(info);
modal.find('#button_delete_confirm').click(function () {
var postdata = {
'action': 'delete_account',
'data': accountname,
'_csrf_token': '{{ csrf_token() }}'
}
applyChanges(postdata, $SCRIPT_ROOT + '/admin/manage-account', false, true);
modal.modal('hide');
})
modal.modal('show');
});
</script>
{% endblock %} {% endblock %}
{% block modals %} {% block modals %}
<div class="modal fade" id="modal_delete"> <div class="modal fade" id="modal_delete">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title">Confirmation</h4> <h4 class="modal-title">Confirmation</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<p></p> <p></p>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-default float-left" data-dismiss="modal">Close</button> <button type="button" class="btn btn-default float-left" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-danger" id="button_delete_confirm">Delete</button> <button type="button" class="btn btn-danger" id="button_delete_confirm">Delete</button>
</div>
</div> </div>
<!-- /.modal-content -->
</div> </div>
<!-- /.modal-content --> <!-- /.modal-dialog -->
</div> </div>
<!-- /.modal-dialog -->
</div>
{% endblock %} {% endblock %}