Started first-round of updates on the activity feature AKA history, but it's a very broken implementation that will require a complete re-build. Saving that for later.

This commit is contained in:
Matt Scott 2023-02-19 20:41:26 -05:00
parent 761909f0f8
commit c4d9bf3a9c
2 changed files with 473 additions and 446 deletions

View File

@ -1,22 +1,13 @@
{% extends "base.html" %} {% extends "base.html" %}
{% set active_page = "admin_history" %} {% set active_page = "admin_history" %}
{% block title %}<title>Activity - {{ SITE_NAME }}</title>{% endblock %}
{% block title %}
<title>
History - {{ 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">Activity</h1>
History
<small>Recent Events</small>
</h1>
</div> </div>
<div class="col-sm-6"> <div class="col-sm-6">
<ol class="breadcrumb float-sm-right"> <ol class="breadcrumb float-sm-right">
@ -37,12 +28,15 @@
<div class="col-12"> <div class="col-12">
<div class="card card-outline card-secondary"> <div class="card card-outline card-secondary">
<div class="card-header with-border"> <div class="card-header with-border">
<h3 class="card-title">History Management</h3> <h3 class="card-title">Activity Search</h3>
{% if current_user.role.name != 'User' %} {% if current_user.role.name == 'Administrator' %}
<button type="button" class="btn btn-danger float-right" data-toggle="modal" data-target="#modal_clear_history" {% if current_user.role.name != 'Administrator' %}disabled{% endif %}> <div class="card-tools">
<button type="button" class="btn btn-danger" data-toggle="modal"
data-target="#modal_clear_history" title="Clear Activity">
<i class="fa-solid fa-trash"></i> <i class="fa-solid fa-trash"></i>
&nbsp;Clear History Clear Activity
</button> </button>
</div>
{% endif %} {% endif %}
</div> </div>
<div class="card-body clearfix"> <div class="card-body clearfix">
@ -59,7 +53,8 @@
</a> </a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link with-border" href="#tabs-account" data-toggle="pill" role="tab"> <a class="nav-link with-border" href="#tabs-account" data-toggle="pill"
role="tab">
Search By Account Search By Account
</a> </a>
</li> </li>
@ -80,15 +75,19 @@
</td> </td>
<td> <td>
<div class="autocomplete" style="width:250px;"> <div class="autocomplete" style="width:250px;">
<input type="text" class="form-control" id="domain_name_filter" name="domain_name_filter" placeholder="Enter * to search for any domain" value=""> <input type="text" class="form-control" id="domain_name_filter"
name="domain_name_filter"
placeholder="Enter * to search for any domain" value="">
</div> </div>
</td> </td>
<td> <td>
<div style="position: relative; top:10px;"> <div style="position: relative; top:10px;">
<td>Record Changelog only &nbsp</td> <td>Record Changelog only &nbsp</td>
<td> <td>
<input type="checkbox" id="domain_changelog_only_checkbox" name="domain_changelog_only_checkbox" <input type="checkbox" id="domain_changelog_only_checkbox"
class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;"> name="domain_changelog_only_checkbox"
class="checkbox"
style="border:2px dotted #00f;display:block;background:#ff0000;">
</td> </td>
</div> </div>
</td> </td>
@ -97,7 +96,9 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
<td><label>Account Name</label></td> <td><label>Account Name</label></td>
<td> <td>
<div class="autocomplete" style="width:250px;"> <div class="autocomplete" style="width:250px;">
<input type="text" class="form-control" id="account_name_filter" name="account_name_filter" placeholder="Enter * to search for any account" value=""> <input type="text" class="form-control" id="account_name_filter"
name="account_name_filter"
placeholder="Enter * to search for any account" value="">
</div> </div>
</td> </td>
</div> </div>
@ -105,7 +106,9 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
<td><label>Username</label></td> <td><label>Username</label></td>
<td> <td>
<div class="autocomplete" style="width:250px;"> <div class="autocomplete" style="width:250px;">
<input type="text" class="form-control" id="auth_name_filter" name="auth_name_filter" placeholder="Enter * to search for any username" value=""> <input type="text" class="form-control" id="auth_name_filter"
name="auth_name_filter"
placeholder="Enter * to search for any username" value="">
</div> </div>
</td> </td>
@ -115,22 +118,29 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
<td>&nbsp All</td> <td>&nbsp All</td>
<td> <td>
<input type="checkbox" checked id="auth_all_checkbox" name="auth_all_checkbox" <input type="checkbox" checked id="auth_all_checkbox" name="auth_all_checkbox"
class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;"> class="checkbox"
style="border:2px dotted #00f;display:block;background:#ff0000;">
</td> </td>
<td>&nbsp LOCAL</td> <td>&nbsp LOCAL</td>
<td> <td>
<input type="checkbox" checked id="auth_local_only_checkbox" name="auth_local_only_checkbox" <input type="checkbox" checked id="auth_local_only_checkbox"
class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;"> name="auth_local_only_checkbox"
class="checkbox"
style="border:2px dotted #00f;display:block;background:#ff0000;">
</td> </td>
<td>&nbsp OAuth</td> <td>&nbsp OAuth</td>
<td> <td>
<input type="checkbox" checked id="auth_oauth_only_checkbox" name="auth_oauth_only_checkbox" <input type="checkbox" checked id="auth_oauth_only_checkbox"
class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;"> name="auth_oauth_only_checkbox"
class="checkbox"
style="border:2px dotted #00f;display:block;background:#ff0000;">
</td> </td>
<td>&nbsp SAML</td> <td>&nbsp SAML</td>
<td> <td>
<input type="checkbox" checked id="auth_saml_only_checkbox" name="auth_saml_only_checkbox" <input type="checkbox" checked id="auth_saml_only_checkbox"
class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;"> name="auth_saml_only_checkbox"
class="checkbox"
style="border:2px dotted #00f;display:block;background:#ff0000;">
</td> </td>
</div> </div>
</td> </td>
@ -146,7 +156,8 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
<td><label>Changed by: &nbsp</label></td> <td><label>Changed by: &nbsp</label></td>
<td> <td>
<div class="autocomplete" style="width:250px;"> <div class="autocomplete" style="width:250px;">
<input type="text" style=" border:1px solid #d2d6de; width:250px; height: 34px;" id="user_name_filter" name="user_name_filter" value=""> <input type="text" style=" border:1px solid #d2d6de; width:250px; height: 34px;"
id="user_name_filter" name="user_name_filter" value="">
</div> </div>
</td> </td>
</tr> </tr>
@ -155,7 +166,8 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
<label>Minimum date: &nbsp</label> <label>Minimum date: &nbsp</label>
</td> </td>
<td style="position: relative; top:10px;"> <td style="position: relative; top:10px;">
<input type="text" id="min" name="min" class="datepicker" autocomplete="off" style=" border:1px solid #d2d6de; width:250px; height: 34px;"> <input type="text" id="min" name="min" class="datepicker" autocomplete="off"
style=" border:1px solid #d2d6de; width:250px; height: 34px;">
</td> </td>
</tr> </tr>
<tr> <tr>
@ -163,17 +175,27 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
<label>Maximum date: &nbsp</label> <label>Maximum date: &nbsp</label>
</td> </td>
<td style="position: relative; top:20px;"> <td style="position: relative; top:20px;">
<input type="text" id="max" name="max" class="datepicker" autocomplete="off" style=" border:1px solid #d2d6de; width:250px; height: 34px;"> <input type="text" id="max" name="max" class="datepicker" autocomplete="off"
style=" border:1px solid #d2d6de; width:250px; height: 34px;">
</td> </td>
</tr> </tr>
<tr><td>&nbsp</td></tr> <tr>
<tr><td>&nbsp</td></tr> <td>&nbsp</td>
</tr>
<tr>
<td>&nbsp</td>
</tr>
<tr> <tr>
<td> <td>
<button type="submit" id="search-submit" name="search-submit" class="btn btn-primary button-filter"><i class="fa fa-search"></i>&nbsp;Search</button> <button type="submit" id="search-submit" name="search-submit"
class="btn btn-primary button-filter"><i class="fa fa-search"></i>&nbsp;Search
</button>
</td> </td>
<td> <td>
<button id="clear-filters" name="clear-filters" class="btn btn-warning button-clearf"><i class="fa fa-trash"></i>&nbsp;Clear Filters</button> <button id="clear-filters" name="clear-filters"
class="btn btn-warning button-clearf"><i class="fa fa-trash"></i>&nbsp;Clear
Filters
</button>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -184,6 +206,7 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
</div> </div>
</section> </section>
{% endblock %} {% endblock %}
{% block extrascripts %} {% block extrascripts %}
<script> <script>
@ -254,8 +277,7 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
$('#auth_all_checkbox').on('ifUnchecked', function () { $('#auth_all_checkbox').on('ifUnchecked', function () {
//check if all were checked //check if all were checked
if($('#auth_local_only_checkbox').is(':checked') && $('#auth_oauth_only_checkbox').is(':checked') && $('#auth_saml_only_checkbox').is(':checked')) if ($('#auth_local_only_checkbox').is(':checked') && $('#auth_oauth_only_checkbox').is(':checked') && $('#auth_saml_only_checkbox').is(':checked')) {
{
$('#auth_local_only_checkbox').iCheck('uncheck'); $('#auth_local_only_checkbox').iCheck('uncheck');
$('#auth_oauth_only_checkbox').iCheck('uncheck'); $('#auth_oauth_only_checkbox').iCheck('uncheck');
$('#auth_saml_only_checkbox').iCheck('uncheck'); $('#auth_saml_only_checkbox').iCheck('uncheck');
@ -317,7 +339,9 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
var a, b, i, val = this.value; var a, b, i, val = this.value;
/*close any already open lists of autocompleted values*/ /*close any already open lists of autocompleted values*/
closeAllLists(); closeAllLists();
if (!val) { return false;} if (!val) {
return false;
}
currentFocus = -1; currentFocus = -1;
/*create a DIV element that will contain the items (values):*/ /*create a DIV element that will contain the items (values):*/
a = document.createElement("DIV"); a = document.createElement("DIV");
@ -373,6 +397,7 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
} }
} }
}); });
function addActive(x) { function addActive(x) {
/*a function to classify an item as "active":*/ /*a function to classify an item as "active":*/
if (!x) return false; if (!x) return false;
@ -383,12 +408,14 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
/*add class "autocomplete-active":*/ /*add class "autocomplete-active":*/
x[currentFocus].classList.add("autocomplete-active"); x[currentFocus].classList.add("autocomplete-active");
} }
function removeActive(x) { function removeActive(x) {
/*a function to remove the "active" class from all autocomplete items:*/ /*a function to remove the "active" class from all autocomplete items:*/
for (var i = 0; i < x.length; i++) { for (var i = 0; i < x.length; i++) {
x[i].classList.remove("autocomplete-active"); x[i].classList.remove("autocomplete-active");
} }
} }
function closeAllLists(elmnt) { function closeAllLists(elmnt) {
/*close all autocomplete lists in the document, /*close all autocomplete lists in the document,
except the one passed as an argument:*/ except the one passed as an argument:*/
@ -399,6 +426,7 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
} }
} }
} }
/*execute a function when someone clicks in the document:*/ /*execute a function when someone clicks in the document:*/
document.addEventListener("click", function (e) { document.addEventListener("click", function (e) {
closeAllLists(e.target); closeAllLists(e.target);
@ -458,12 +486,9 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
$("#history-search-form").submit(function (e) { // ajax call to load results on submition $("#history-search-form").submit(function (e) { // ajax call to load results on submition
e.preventDefault(); // prevent page reloading e.preventDefault(); // prevent page reloading
if(!canSearch) if (!canSearch) {
{
showErrorModal("Please fill out the " + main_field + " field."); showErrorModal("Please fill out the " + main_field + " field.");
} } else {
else
{
var form = $(this); var form = $(this);
var tzoffset = (new Date()).getTimezoneOffset(); var tzoffset = (new Date()).getTimezoneOffset();
$.ajax({ $.ajax({
@ -484,6 +509,7 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
</script> </script>
{% endblock %} {% endblock %}
{% block modals %} {% block modals %}
<!-- Clear History Confirmation Box --> <!-- Clear History Confirmation Box -->
<div class="modal fade modal-warning" id="modal_clear_history"> <div class="modal fade modal-warning" id="modal_clear_history">
@ -500,7 +526,8 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-danger float-right" onclick="applyChanges({'_csrf_token': '{{ csrf_token() }}'}, $SCRIPT_ROOT + '/admin/history', false, true);"> <button type="button" class="btn btn-danger float-right"
onclick="applyChanges({'_csrf_token': '{{ csrf_token() }}'}, $SCRIPT_ROOT + '/admin/history', false, true);">
Clear History Clear History
</button> </button>
</div> </div>

View File

@ -136,7 +136,7 @@
<li class="{{ 'nav-item active' if active_page == 'admin_history' else 'nav-item' }}"> <li class="{{ 'nav-item active' if active_page == 'admin_history' else 'nav-item' }}">
<a href="{{ url_for('admin.history') }}" class="nav-link"> <a href="{{ url_for('admin.history') }}" class="nav-link">
<i class="nav-icon fa-solid fa-timeline"></i> <i class="nav-icon fa-solid fa-timeline"></i>
<p>History</p> <p>Activity</p>
</a> </a>
</li> </li>
<li class="{{ 'nav-item active' if active_page == 'admin_domain_template' else 'nav-item' }}"> <li class="{{ 'nav-item active' if active_page == 'admin_domain_template' else 'nav-item' }}">