Added table filtering on output data, reduce dark mode flicker, refactored a few names of options
This commit is contained in:
parent
d90ce10db5
commit
76a6364a06
12
head.php
12
head.php
@ -17,11 +17,17 @@
|
||||
<script src="/js/Extensions.js"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
const colorSchemeQuery = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
fnApplyDark = function()
|
||||
{
|
||||
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
||||
|
||||
if (colorSchemeQuery)
|
||||
if (prefersDark)
|
||||
$("body").attr("data-bs-theme", "dark");
|
||||
};
|
||||
|
||||
$(function() {
|
||||
// Guarantee this function runs after a page load:
|
||||
fnApplyDark();
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
|
@ -1 +1,4 @@
|
||||
|
||||
<script>
|
||||
// Run this function as soon as the body tag is available:
|
||||
fnApplyDark();
|
||||
</script>
|
||||
|
@ -30,6 +30,7 @@
|
||||
$varOptions = [];
|
||||
|
||||
$intAllowed = 1;
|
||||
$intSortable = 1;
|
||||
|
||||
if ($strSelection !== null && strlen($strSelection) > 0)
|
||||
{
|
||||
@ -94,11 +95,6 @@
|
||||
catch (Exception $x) {}
|
||||
}
|
||||
|
||||
//Respond::json($strFileData);
|
||||
|
||||
//foreach ($varReplacements as $k => $v)
|
||||
// $strFileData = preg_replace("/\{\{{$k}\}\}/i", $v, $strFileData);
|
||||
|
||||
// Get the inputs:
|
||||
preg_match_all(
|
||||
"/declare\s+\@([A-Za-z0-9]{1,})\s+(.+)\s+=\s+\?;(\s+-- ([A-Za-z0-9]{1,})\:\s(.*))?/i",
|
||||
@ -121,6 +117,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("nosorting", $varOptions))
|
||||
$intSortable = 0;
|
||||
|
||||
if (array_key_exists("allow", $varOptions))
|
||||
{
|
||||
$intAllowed = 0;
|
||||
@ -205,15 +204,22 @@
|
||||
|
||||
<div class="navbar navbar-expand bg-primary navbar-dark d-print-none">
|
||||
<div class="container-fluid justify-content-between">
|
||||
<div class="d-inline-flex align-items-center">
|
||||
<div class="d-inline-flex align-items-center w-100 text-nowrap">
|
||||
<a class="nav-item btn btn-outline-light me-2" onclick="fnShowPage('#page-input');"><i class="fa fa-fw fa-cog"></i> <span class="d-none d-lg-inline">Options</span></a>
|
||||
|
||||
<?php if ($varRows !== null && count($varRows) > 0): ?>
|
||||
<a class="nav-item btn btn-outline-light me-2" onclick="fnShowPage('#page-output');"><i class="fa fa-fw fa-table"></i> <span class="d-none d-lg-inline">Results</span></a>
|
||||
<a class="nav-item btn btn-outline-light me-2" onclick="fnExport();" id="export-csv-button"><i class="fa fa-fw fa-download"></i> <span class="d-none d-lg-inline">.csv</span></a>
|
||||
<a class="nav-item btn btn-outline-light me-2" onclick="fnPrint();"><i class="fa fa-fw fa-print"></i> <span class="d-none d-lg-inline">Print</span></a>
|
||||
|
||||
<div class="input-group">
|
||||
<span class="input-group-text bg-primary border-white text-white"><i class="fa fa-fw fa-search"></i></span>
|
||||
<input type="text" class="form-control bg-primary border-white text-white" name="" placeholder="Search rows..." value="" id="table-search"></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -254,9 +260,9 @@
|
||||
<label>Choose Query</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-folder"></i></span>
|
||||
<input type="text" class="form-control" name="query" placeholder="Search files..." value="<?= $strSelection; ?>" id="query-search" />
|
||||
<input type="text" class="form-control" name="file" placeholder="Search files..." value="<?= $strSelection; ?>" id="file-search" />
|
||||
</div>
|
||||
<div class="query-search-results">
|
||||
<div class="file-search-results">
|
||||
<?php foreach ($varFiles as $f): ?>
|
||||
<div class="d-none border p-3">
|
||||
<a class="link-underline link-underline-opacity-0" href="/run/<?= $f; ?>">
|
||||
@ -483,6 +489,7 @@
|
||||
<li><?= $k; ?>: <?= $v; ?></li>
|
||||
<?php endforeach; ?>
|
||||
<li>Printed: <?= date("Y-m-d H:i:s"); ?></li>
|
||||
<li class="d-none">Search: <span id="search-text"></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@ -503,7 +510,7 @@
|
||||
$strNextCellClass = "";
|
||||
?>
|
||||
|
||||
<div class="<?= $strDisplayRowAs; ?>">
|
||||
<div class="<?= $strDisplayRowAs; ?> searchable">
|
||||
|
||||
<table class="table table-sm table-striped table-bordered">
|
||||
|
||||
@ -569,7 +576,7 @@
|
||||
if ($col[0] == "_")
|
||||
continue;
|
||||
?>
|
||||
<th class="text-nowrap sorting"><?= $col; ?> <?php DataTable::sortIcon(); ?></th>
|
||||
<th class="text-nowrap sorting"><?= $col; ?> <?php if ($intSortable) DataTable::sortIcon(); ?></th>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -584,7 +591,7 @@
|
||||
|
||||
$strNextCellClass = "";
|
||||
?>
|
||||
<tr>
|
||||
<tr class="searchable">
|
||||
<?php foreach ($varColumns as $col): ?>
|
||||
<?php
|
||||
$strCellClass = "";
|
||||
@ -622,7 +629,8 @@
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
var fileSearch = $("#query-search").first();
|
||||
var fileSearch = $("#file-search").first();
|
||||
var tableSearch = $("#table-search").first();
|
||||
|
||||
fileSearch.on("focus", function() {
|
||||
fileSearch.trigger("input");
|
||||
@ -632,13 +640,10 @@
|
||||
fileSearch.on("input", function() {
|
||||
var q = fileSearch.val();
|
||||
|
||||
$(".query-search-results div").each(function(i, x) {
|
||||
$(".file-search-results div").each(function(i, x) {
|
||||
x = $(x);
|
||||
x.addClass("d-none");
|
||||
|
||||
//if (q.length < 1)
|
||||
// return;
|
||||
|
||||
var fileName = x.text();
|
||||
|
||||
if (fileName.includesAll(q))
|
||||
@ -646,6 +651,40 @@
|
||||
});
|
||||
});
|
||||
|
||||
if (tableSearch)
|
||||
{
|
||||
var searchText = $("#search-text").first();
|
||||
|
||||
tableSearch.on("input", function() {
|
||||
var q = tableSearch.val();
|
||||
|
||||
searchText.html(q);
|
||||
|
||||
searchText
|
||||
.parents("li")
|
||||
.first()
|
||||
.addClass("d-none");
|
||||
|
||||
if (q.length > 0)
|
||||
{
|
||||
searchText
|
||||
.parents("li")
|
||||
.first()
|
||||
.removeClass("d-none");
|
||||
}
|
||||
|
||||
$(".searchable").each(function(i, x) {
|
||||
x = $(x);
|
||||
x.addClass("d-none");
|
||||
|
||||
var searchableText = x.text();
|
||||
|
||||
if (searchableText.includesAll(q))
|
||||
x.removeClass("d-none");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
fnShowPage = function(id)
|
||||
{
|
||||
@ -687,13 +726,18 @@
|
||||
</script>
|
||||
|
||||
<?php if ($varRows !== null && count($varRows) > 0): ?>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
fnShowPage("#page-output");
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php DataTable::js("#table"); ?>
|
||||
<?php
|
||||
// Only allow Datatables for "sortable" rowsets:
|
||||
if ($intSortable)
|
||||
DataTable::js("#table");
|
||||
?>
|
||||
|
||||
<?php if (array_key_exists("outputonly", $varOptions)): ?>
|
||||
<script>
|
||||
@ -703,11 +747,10 @@
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<?php $intAutorun = Request::getParam("autorun"); ?>
|
||||
<?php if ($intAutorun !== null && $intAutorun == 1): ?>
|
||||
<?php if (array_key_exists("autorun", $varOptions)): ?>
|
||||
<script>
|
||||
$(function() {
|
||||
$("#page-input form")
|
||||
@ -717,6 +760,7 @@
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
$strSearchQuery = Request::getParam("q");
|
||||
@ -733,7 +777,7 @@
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (array_key_exists("focusinput", $varOptions)): ?>
|
||||
<?php if (array_key_exists("inputonly", $varOptions)): ?>
|
||||
<script>
|
||||
$(function() {
|
||||
$("[data-report-chooser='1']").addClass("d-none");
|
||||
@ -742,10 +786,13 @@
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
// Load a custom view if there is one:
|
||||
if ($strQueryView !== null)
|
||||
if (file_exists($strQueryView))
|
||||
require $strQueryView;
|
||||
?>
|
||||
|
||||
<?php if (array_key_exists("autorefresh", $varOptions)): ?>
|
||||
<meta http-equiv="refresh" content="<?= $varOptions["autorefresh"]; ?>">
|
||||
<?php endif; ?>
|
||||
|
Loading…
Reference in New Issue
Block a user