Began working on expanding out the front-end to more pages.

This commit is contained in:
Tristan Ancelet 2023-05-09 21:42:20 -05:00
parent d28047b9df
commit 8948ce741d
3 changed files with 99 additions and 12 deletions

57
crontabs.php Normal file
View File

@ -0,0 +1,57 @@
<!Doctype html>
<html>
<head>
<!-- <script src="https://cdn.tailwindcss.com"></script> -->
<link rel="stylesheet" href="css/main.css">
<script src="main.js"> </script>
<title>This is a test</title>
</head>
<body>
<nav>
<a class="nav-button" href='/'>Logs/Statistics</a>
<a class="nav-button" href='/crontabs.php'>Crontab Management</a>
<a class="nav-button" href='contact.php'>Contact</a>
</nav>
<div class="content_area bordered rounded_border">
<div class="menu_bar bordered_right cell">
<button class="menu_button"> Check Logs </button>
<button class="menu_button"> View Crontab Statistics</button>
<button class="menu_button" onclick="setInfoSection()"> View Database Version</button>
</div>
<div id="content" class="content cell">
Total Crontabs:<br>
<?php
$crontab_counts=shell_exec('./count-crontabs.sh');
echo "$crontab_counts";
?>
</div>
<div class="double_width_menu_bar bordered_left cell">
<div class="wrapper bordered center_text">
All Crontabs
<div id="log_statistics_table" class="log_table bordered">
<div class="table_row">
<div class="table_header">Crontab</div> <div class="table_header">Created At</div><div class="table_header">Last Modified</div>
</div>
<?php
$db = new SQLite3('../webcron.db');
$res = $db->query("SELECT crontab_path, crontab_created_timestamp, crontab_modified_timestamp FROM crontabs;");
while ($row = $res->fetchArray()){
echo "<div class=\"table_row\">";
echo "<div class=\"table_cell\">{$row['crontab_path']}</div> <div class=\"table_cell\">{$row['crontab_created_timestamp']}</div><div class=\"table_cell\">{$row['crontab_modified_timestamp']}</div>";
echo "</div>";
}
?>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -26,6 +26,16 @@
<div id="content" class="content cell"> <div id="content" class="content cell">
Test Test
<br>
<?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;");
echo "Log Entries: $res<br>";
?>
</div> </div>
<div class="double_width_menu_bar bordered_left cell"> <div class="double_width_menu_bar bordered_left cell">
@ -36,15 +46,15 @@
<div class="table_header">Level</div> <div class="table_header">Level</div>
<div class="table_header"># of occurances</div> <div class="table_header"># of occurances</div>
</div> </div>
<div class="table_row"> <?php
<div class="table_cell">Warning</div> <div class="table_cell">N/A</div> $db = new SQLite3('../webcron.db');
</div> $res = $db->query("SELECT * FROM log_statistics_last_7_days;");
<div class="table_row"> while ($row = $res->fetchArray()){
<div class="table_cell">Critical</div> <div class="table_cell">N/A</div> echo "<div class='table_row'>";
</div> echo "<div class='table_cell'>{$row['log_level_name']}</div> <div class='table_cell'>{$row['count']}</div>";
<div class="table_row"> echo "</div>";
<div class="table_cell">Info</div> <div class="table_cell">N/A</div> }
</div> ?>
</div> </div>
</div> </div>
@ -52,8 +62,17 @@
Script Failures (Last 10) Script Failures (Last 10)
<div id="script_failures" class="log_table"> <div id="script_failures" class="log_table">
<div class="table_row"> <div class="table_row">
<div class="table_header">Date</div> <div class="table_header">Script</div> <div class="table_header">Date/Time</div> <div class="table_header">Script</div> <div class="table_header">Exit Code</div>
</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> </div>
@ -61,8 +80,17 @@
Jobs Run (Last 10) Jobs Run (Last 10)
<div id="jobs_run_table" class="log_table"> <div id="jobs_run_table" class="log_table">
<div class="table_row"> <div class="table_row">
<div class="table_header">Date/Time</div> <div class="table_header">Script</div> <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> </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>
</div> </div>

View File

@ -9,3 +9,5 @@ function setInfoSection (string) {
var info_section = document.getElementById("content"); var info_section = document.getElementById("content");
info_section.innerHTML = request_sqlite_version(); info_section.innerHTML = request_sqlite_version();
} }