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" %}
{% set active_page = "admin_history" %}
{% block title %}
<title>
History - {{ SITE_NAME }}
</title>
{% endblock %}
{% block title %}<title>Activity - {{ 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">
History
<small>Recent Events</small>
</h1>
<h1 class="m-0 text-dark">Activity</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
@ -37,12 +28,15 @@
<div class="col-12">
<div class="card card-outline card-secondary">
<div class="card-header with-border">
<h3 class="card-title">History Management</h3>
{% if current_user.role.name != 'User' %}
<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 %}>
<h3 class="card-title">Activity Search</h3>
{% if current_user.role.name == 'Administrator' %}
<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>
&nbsp;Clear History
Clear Activity
</button>
</div>
{% endif %}
</div>
<div class="card-body clearfix">
@ -59,7 +53,8 @@
</a>
</li>
<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
</a>
</li>
@ -80,15 +75,19 @@
</td>
<td>
<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>
</td>
<td>
<div style="position: relative; top:10px;">
<td>Record Changelog only &nbsp</td>
<td>
<input type="checkbox" id="domain_changelog_only_checkbox" name="domain_changelog_only_checkbox"
class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;">
<input type="checkbox" id="domain_changelog_only_checkbox"
name="domain_changelog_only_checkbox"
class="checkbox"
style="border:2px dotted #00f;display:block;background:#ff0000;">
</td>
</div>
</td>
@ -97,7 +96,9 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
<td><label>Account Name</label></td>
<td>
<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>
</td>
</div>
@ -105,7 +106,9 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
<td><label>Username</label></td>
<td>
<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>
</td>
@ -115,22 +118,29 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
<td>&nbsp All</td>
<td>
<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>&nbsp LOCAL</td>
<td>
<input type="checkbox" checked id="auth_local_only_checkbox" name="auth_local_only_checkbox"
class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;">
<input type="checkbox" checked id="auth_local_only_checkbox"
name="auth_local_only_checkbox"
class="checkbox"
style="border:2px dotted #00f;display:block;background:#ff0000;">
</td>
<td>&nbsp OAuth</td>
<td>
<input type="checkbox" checked id="auth_oauth_only_checkbox" name="auth_oauth_only_checkbox"
class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;">
<input type="checkbox" checked id="auth_oauth_only_checkbox"
name="auth_oauth_only_checkbox"
class="checkbox"
style="border:2px dotted #00f;display:block;background:#ff0000;">
</td>
<td>&nbsp SAML</td>
<td>
<input type="checkbox" checked id="auth_saml_only_checkbox" name="auth_saml_only_checkbox"
class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;">
<input type="checkbox" checked id="auth_saml_only_checkbox"
name="auth_saml_only_checkbox"
class="checkbox"
style="border:2px dotted #00f;display:block;background:#ff0000;">
</td>
</div>
</td>
@ -146,7 +156,8 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
<td><label>Changed by: &nbsp</label></td>
<td>
<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>
</td>
</tr>
@ -155,7 +166,8 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
<label>Minimum date: &nbsp</label>
</td>
<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>
</tr>
<tr>
@ -163,17 +175,27 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
<label>Maximum date: &nbsp</label>
</td>
<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>
</tr>
<tr><td>&nbsp</td></tr>
<tr><td>&nbsp</td></tr>
<tr>
<td>&nbsp</td>
</tr>
<tr>
<td>&nbsp</td>
</tr>
<tr>
<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>
<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>
</tr>
</tbody>
@ -184,6 +206,7 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
</div>
</section>
{% endblock %}
{% block extrascripts %}
<script>
@ -254,8 +277,7 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
$('#auth_all_checkbox').on('ifUnchecked', function () {
//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_oauth_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;
/*close any already open lists of autocompleted values*/
closeAllLists();
if (!val) { return false;}
if (!val) {
return false;
}
currentFocus = -1;
/*create a DIV element that will contain the items (values):*/
a = document.createElement("DIV");
@ -373,6 +397,7 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
}
}
});
function addActive(x) {
/*a function to classify an item as "active":*/
if (!x) return false;
@ -383,12 +408,14 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
/*add class "autocomplete-active":*/
x[currentFocus].classList.add("autocomplete-active");
}
function removeActive(x) {
/*a function to remove the "active" class from all autocomplete items:*/
for (var i = 0; i < x.length; i++) {
x[i].classList.remove("autocomplete-active");
}
}
function closeAllLists(elmnt) {
/*close all autocomplete lists in the document,
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:*/
document.addEventListener("click", function (e) {
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
e.preventDefault(); // prevent page reloading
if(!canSearch)
{
if (!canSearch) {
showErrorModal("Please fill out the " + main_field + " field.");
}
else
{
} else {
var form = $(this);
var tzoffset = (new Date()).getTimezoneOffset();
$.ajax({
@ -484,6 +509,7 @@ class="checkbox" style="border:2px dotted #00f;display:block;background:#ff0000;
</script>
{% endblock %}
{% block modals %}
<!-- Clear History Confirmation Box -->
<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 class="modal-footer">
<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
</button>
</div>

View File

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