Implemented table classes for each webpage.

This commit is contained in:
2023-05-27 15:53:50 -05:00
parent 12e1f06897
commit b8ba9dc5d4
9 changed files with 95 additions and 85 deletions

View File

@@ -1,3 +1,9 @@
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
require "$root/Libraries/table/class.php";
use table\Table;
$db = new SQLite3("../webcron.db");
?>
<!Doctype html>
<!--
Color pallet: https://colorhunt.co/palette/b9eddd87cbb9569daa577d86
@@ -35,7 +41,6 @@
<?php
$user=shell_exec("whoami");
echo "User: $user<br>";
$db = new SQLite3('../webcron.db');
$res = $db->querySingle("SELECT COUNT(job_id) FROM job_history;");
echo "Job History Entries: $res<br>";
$res = $db->querySingle("SELECT COUNT(log_id) FROM logs;");
@@ -44,61 +49,31 @@
</div>
<div class="double_width_menu_bar bordered_left cell">
<div class="wrapper bordered center_text">
Log Statistics (This Week)
<div id="log_statistics_table" class="log_table bordered">
<div class="table_row">
<div class="table_header">Level</div>
<div class="table_header"># of occurances</div>
</div>
<?php
$db = new SQLite3('../webcron.db');
$res = $db->query("SELECT * FROM log_statistics_last_7_days;");
while ($row = $res->fetchArray()){
echo "<div class='table_row'>";
echo "<div class='table_cell'>{$row['log_level_name']}</div> <div class='table_cell'>{$row['count']}</div>";
echo "</div>";
}
?>
</div>
</div>
<?php
$table = new Table("log_statistics_last_7_days");
$table->set_pretty_name("Log Statistics (Last 7 Days)");
$query = $table->get_query();
$table->Load($db);
echo $query->get_query_string();
echo $table->get_html();
<div class="wrapper bordered center_text">
Script Failures (Last 10)
<div id="script_failures" class="log_table">
<div class="table_row">
<div class="table_header">Date/Time</div> <div class="table_header">Script</div> <div class="table_header">Exit Code</div>
</div>
<?php
$db = new SQLite3('../webcron.db');
$res = $db->query("SELECT * FROM last_ten_failed_jobs;");
while ($row = $res->fetchArray()){
echo "<div class='table_row'>";
echo "<div class='table_cell'>{$row['job_timestamp']}</div> <div class='table_cell'>{$row['job_source']}</div><div class='table_cell'>{$row['job_exit_code']}</div>";
echo "</div>";
}
?>
</div>
</div>
<div class="wrapper bordered center_text">
Jobs Run (Last 10)
<div id="jobs_run_table" class="log_table">
<div class="table_row">
<div class="table_header">Date/Time</div> <div class="table_header">Script</div> <div class="table_header">Exit Code</div> <div class="table_header">Job Result</div>
</div>
<?php
$db = new SQLite3('../webcron.db');
$res = $db->query("SELECT * FROM job_history ORDER BY job_timestamp DESC LIMIT 10;");
while ($row = $res->fetchArray()){
echo "<div class='table_row'>";
echo "<div class='table_cell'>{$row['job_timestamp']}</div> <div class='table_cell'>{$row['job_source']}</div><div class='table_cell'>{$row['job_exit_code']}</div><div class='table_cell'>{$row['job_result']}</div>";
echo "</div>";
}
?>
</div>
</div>
$table = new Table("last_ten_failed_jobs");
$table->set_pretty_name("Script Failures (Last 10)");
$query = $table->get_query();
$table->Load($db);
echo $query->get_query_string();
echo $table->get_html();
$table = new Table("job_history");
$table->set_pretty_name("Jobs Run (Last 10)");
$query = $table->get_query();
$query->set_order_by_column("job_timestamp DESC");
$query->set_limit(10);
$table->Load($db);
echo $query->get_query_string();
echo $table->get_html();
?>
</div>
</div>