Compare commits

..

No commits in common. "8eae00253c5d09cdcb2a1130dfc84c673bee9b87" and "d1a7d5743e08fd1e214b256da348b34c7ab5eca6" have entirely different histories.

2 changed files with 88 additions and 142 deletions

View File

@ -13,20 +13,6 @@ $.prototype.getCellText = function()
return a; return a;
}; };
String.prototype.includesAll = function(parts)
{
var parent = this;
var parts = parts.split(" ");
var contains = true;
parts.forEach((part, i) => {
if (!parent.toLowerCase().includes(part.toLowerCase()))
contains = false;
});
return contains;
};
// Trigger downloading a table as CSV: // Trigger downloading a table as CSV:
$.prototype.exportCSV = function(options) $.prototype.exportCSV = function(options)
{ {

View File

@ -5,23 +5,10 @@
$strQueryDir = "files/sql"; $strQueryDir = "files/sql";
// $varFiles = is_dir($strQueryDir)? scandir($strQueryDir) : []; $varFiles = is_dir($strQueryDir)? scandir($strQueryDir) : [];
// $varFiles = array_diff($varFiles, [".", ".."]); $varFiles = array_diff($varFiles, [".", ".."]);
function removeQueryDir(&$strInput)
{
global $strQueryDir;
$strInput = substr($strInput, strlen($strQueryDir) + 1);
}
$strFind = shell_exec("find files/sql | grep -Ei \"\.sql$\"");
$varFiles = explode("\n", $strFind);
$varFiles = array_filter($varFiles);
array_walk($varFiles, "removeQueryDir");
$strSelection = implode("/", Request::getArgs());
$strSelection = Request::getArg(0);
$varInputs = [[]]; $varInputs = [[]];
$varRows = null; $varRows = null;
$strError = null; $strError = null;
@ -210,7 +197,9 @@
<div class="navbar navbar-expand bg-primary navbar-dark d-print-none"> <div class="navbar navbar-expand bg-primary navbar-dark d-print-none">
<div class="container-fluid justify-content-between"> <div class="container-fluid justify-content-between">
<div class="d-inline-flex align-items-center"> <div class="d-inline-flex align-items-center">
<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> <a class="navbar-brand"><?= $strTitle; ?></a>
<a class="nav-item btn btn-outline-light me-2" onclick="fnShowPage('#page-input');"><i class="fa fa-fw fa-edit"></i> <span class="d-none d-lg-inline">Setup</span></a>
<?php if ($varRows !== null && count($varRows) > 0): ?> <?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="fnShowPage('#page-output');"><i class="fa fa-fw fa-table"></i> <span class="d-none d-lg-inline">Results</span></a>
@ -262,143 +251,128 @@
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
</div> </div>
</div>
</div>
<?php if ($intAllowed == 1): ?> <?php if ($intAllowed == 1): ?>
<?php foreach (["description"] as $strClass): ?>
<?php if (array_key_exists($strClass, $varOptions)): ?>
<?php foreach (["description"] as $strClass): ?>
<?php if (array_key_exists($strClass, $varOptions)): ?>
<div class="row">
<div class="col-md-6">
<div class="mb-3"> <div class="mb-3">
<?= $varOptions[$strClass]; ?> <?= $varOptions[$strClass]; ?>
</div> </div>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?> <?php foreach (["danger", "warning", "info"] as $strClass): ?>
<?php endforeach; ?> <?php if (array_key_exists($strClass, $varOptions)): ?>
<div class="row">
<?php foreach (["danger", "warning", "info"] as $strClass): ?> <div class="col-md-6">
<?php if (array_key_exists($strClass, $varOptions)): ?>
<div class="alert alert-<?= $strClass; ?>"> <div class="alert alert-<?= $strClass; ?>">
<strong><?= ucfirst($strClass); ?>:</strong> <?= $varOptions[$strClass]; ?> <strong><?= ucfirst($strClass); ?>:</strong> <?= $varOptions[$strClass]; ?>
</div> </div>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endif; ?> <form method="get">
<?php endforeach; ?> <?php if (count($varInputs[0]) > 0): ?>
<?php for ($i = 0; $i < count($varInputs[0]); $i++): ?>
<?php
$strInputName = $varInputs[1][$i];
$strInputType = $varInputs[2][$i];
<form method="get"> $strInputTypeHTML = "text";
<?php if (count($varInputs[0]) > 0): ?>
<?php for ($i = 0; $i < count($varInputs[0]); $i++): ?>
<?php
$strInputName = $varInputs[1][$i];
$strInputType = $varInputs[2][$i];
$strInputTypeHTML = "text"; if ($strInputType == "datetime")
$strInputTypeHTML = "date";
if ($strInputType == "datetime") $strInputDefaultValue = "";
$strInputTypeHTML = "date"; if (strtolower($varInputs[4][$i]) == "default")
if (strlen($varInputs[5][$i]) > 0)
$strInputDefaultValue = $varInputs[5][$i];
$strInputDefaultValue = ""; $varOptions = [];
if (strtolower($varInputs[4][$i]) == "default") if (strtolower($varInputs[4][$i]) == "options")
if (strlen($varInputs[5][$i]) > 0) {
$strInputDefaultValue = $varInputs[5][$i]; $strOptionsList = $varInputs[5][$i];
$varOptions = explode(",", $strOptionsList);
$varOptions = []; }
if (strtolower($varInputs[4][$i]) == "options") ?>
{
$strOptionsList = $varInputs[5][$i];
$varOptions = explode(",", $strOptionsList);
}
?>
<div class="row">
<div class="col-md-6">
<div class="mb-3"> <div class="mb-3">
<label><?= $strInputName; ?> <code><?= $strInputType; ?></code></label> <label><?= $strInputName; ?> <code><?= $strInputType; ?></code></label>
<?php if (count($varOptions) > 0): ?> <?php if (count($varOptions) > 0): ?>
<div class="input-group"> <select class="form-select" name="<?= $strInputName; ?>">
<span class="input-group-text"><i class="fa fa-fw fa-at"></i></span> <?php foreach ($varOptions as $o): ?>
<?php
$strLabel = $o;
$strValue = $o;
<select class="form-select" name="<?= $strInputName; ?>"> if (preg_match("/=.+$/i", $o))
<?php foreach ($varOptions as $o): ?> {
<?php preg_match("/(.+)=(.+)$/i", $o, $varTempMatches);
$strLabel = $o; $strLabel = $varTempMatches[1];
$strValue = $o; $strValue = $varTempMatches[2];
}
?>
if (preg_match("/=.+$/i", $o)) <option
{ value="<?= $strValue; ?>"
preg_match("/(.+)=(.+)$/i", $o, $varTempMatches); <?= Request::getParam($strInputName) == $strValue? "selected": ""; ?>
$strLabel = $varTempMatches[1]; ><?= $strLabel; ?></option>
$strValue = $varTempMatches[2]; <?php endforeach; ?>
} </select>
?>
<option
value="<?= $strValue; ?>"
<?= Request::getParam($strInputName) == $strValue? "selected": ""; ?>
><?= $strLabel; ?></option>
<?php endforeach; ?>
</select>
</div>
<?php else: ?> <?php else: ?>
<div class="input-group"> <div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-at"></i></span> <span class="input-group-text"><i class="fa fa-fw fa-at"></i></span>
<input type="<?= $strInputTypeHTML; ?>" class="form-control" name="<?= $strInputName; ?>" value="<?= Request::getParam($strInputName) ?? $strInputDefaultValue; ?>" /> <input type="<?= $strInputTypeHTML; ?>" class="form-control" name="<?= $strInputName; ?>" value="<?= Request::getParam($strInputName) ?? $strInputDefaultValue; ?>" />
</div> </div>
<?php endif; ?> <?php endif; ?>
</div> </div>
<?php endfor; ?> </div>
<?php endif; ?> </div>
<?php endfor; ?>
<?php endif; ?>
<div class="row">
<div class="col-md-6">
<div class="mb-3"> <div class="mb-3">
<label>Actions</label> <label>Actions</label>
<div> <div>
<a class="btn btn-primary" onclick="fnSubmit(this);"><i class="fa fa-fw fa-server me-1"></i> Execute</a> <a class="btn btn-primary" onclick="fnSubmit(this);"><i class="fa fa-fw fa-server me-1"></i> Execute</a>
</div> </div>
</div> </div>
</div>
</div>
<input type="hidden" name="run" value="1" /> <input type="hidden" name="run" value="1" />
</form> </form>
<?php else: ?> <?php else: ?>
<div class="row">
<div class="col-md-6">
<div class="text-danger mb-3"> <div class="text-danger mb-3">
The selected report requires being logged in as a user with permission to run it. The selected report requires being logged in as a user with permission to run it.
</div> </div>
<?php endif; ?>
</div>
<?php
$varDirectories = [];
foreach ($varFiles as $f)
{
preg_match("/^(.*\/)[^\/]/", $f, $varMatches);
$strDirectory = $varMatches[1];
if (strlen($strDirectory) > 0)
$varDirectories[$strDirectory] = 1;
}
?>
<div class="col-md-6">
<div class="mb-3">
<label>Directories</label>
<div class="">
<?php foreach ($varDirectories as $d => $a): ?>
<div class="border p-3">
<a class="link-underline link-underline-opacity-0" href="/run?q=<?= $d; ?>">
<i class="fa fa-fw fa-folder me-2"></i>
<?= $d; ?>
</a>
</div>
<?php endforeach; ?>
</div>
</div> </div>
</div> </div>
</div> <?php endif; ?>
</div> </div>
</div> </div>
@ -416,7 +390,7 @@
<div class="d-none d-print-block"> <div class="d-none d-print-block">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-6">
<h1><?= $strTitle; ?></h1> <h1><?= $strTitle; ?></h1>
<?php foreach (["description"] as $strClass): ?> <?php foreach (["description"] as $strClass): ?>
@ -424,7 +398,9 @@
<p><?= $varOptions[$strClass]; ?></p> <p><?= $varOptions[$strClass]; ?></p>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
</div>
<div class="col-md-6">
<ul> <ul>
<?php foreach ($varPosted as $k => $v): ?> <?php foreach ($varPosted as $k => $v): ?>
<li><?= $k; ?>: <?= $v; ?></li> <li><?= $k; ?>: <?= $v; ?></li>
@ -438,7 +414,7 @@
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-sm table-striped table-bordered w-100" id="table"> <table class="table table-sm table-striped table-bordered w-100" id="table">
<thead class="sticky-top"> <thead>
<tr> <tr>
<?php foreach ($varColumns as $col): ?> <?php foreach ($varColumns as $col): ?>
<?php <?php
@ -516,7 +492,7 @@
var fileName = x.text(); var fileName = x.text();
if (fileName.includesAll(q)) if (fileName.toLowerCase().includes(q.toLowerCase()))
x.removeClass("d-none"); x.removeClass("d-none");
}); });
}); });
@ -563,19 +539,3 @@
}); });
</script> </script>
<?php endif; ?> <?php endif; ?>
<?php
$strSearchQuery = Request::getParam("q");
?>
<?php if ($strSearchQuery !== null && strlen($strSearchQuery) > 0): ?>
<script>
$(function() {
$("#query-search")
.first()
.val("<?= $strSearchQuery; ?>")
.trigger("input");
});
</script>
<?php endif; ?>