summaryrefslogtreecommitdiff
path: root/pages/jobs.inc
diff options
context:
space:
mode:
Diffstat (limited to 'pages/jobs.inc')
-rw-r--r--pages/jobs.inc123
1 files changed, 123 insertions, 0 deletions
diff --git a/pages/jobs.inc b/pages/jobs.inc
new file mode 100644
index 0000000..ae1405d
--- /dev/null
+++ b/pages/jobs.inc
@@ -0,0 +1,123 @@
+<?php
+
+require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages;
+require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/header.inc';
+
+$history = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/history.json"), true);
+
+?>
+
+<style>
+ .list-group-item {
+ color: #fff;
+ background-color: #222;
+ border: 1px solid rgba(255, 255, 255, .125);
+ }
+
+ .list-group-item.disabled {
+ color: #fff;
+ background-color: #222;
+ border-color: rgba(255, 255, 255, .125);
+ opacity: .75;
+ }
+
+ .list-group-item:hover {
+ background-color: #252525;
+ color: #ddd;
+ }
+
+ .list-group-item:active, .list-group-item:focus {
+ background-color: #272727;
+ color: #bbb;
+ }
+
+ details[open] summary {
+ font-weight: bold;
+ }
+
+ pre {
+ background: #000000;
+ color: #ffffff;
+ padding: 10px 20px;
+ margin-top: 10px;
+ }
+
+ pre.last {
+ margin-bottom: 0;
+ }
+
+ .tracking li {
+ margin-bottom: 5px;
+ }
+
+ .tracking li:nth-last-child(1), .tracking {
+ margin-bottom: 0 !important;
+ }
+</style>
+
+<br>
+<div class="container">
+ <div id="page-content">
+ <h2>Jobs history</h2>
+
+ <div class="list-group">
+ <?php foreach ($history as $item): ?>
+ <details class="list-group-item">
+ <summary style="list-style: none; display: grid; grid-template-columns: 3fr repeat(2, 1fr);">
+ <div><?= $item["name"] ?></div>
+ <div><?= timeAgo($item["tracking"]["queue"]) ?></div>
+ <div><?php if ($item["completed"]): ?><span class="text-success" style="filter: invert(1) hue-rotate(180deg);">Completed</span><?php else: ?><span class="text-danger" style="filter: invert(1) hue-rotate(180deg);">Failed</span><?php endif; ?></div>
+ </summary>
+
+ <div class="list-group" style="margin-top: 10px;">
+ <div class="list-group-item">
+ <p>
+ <b>Duration:</b> <?= $item["time"] ?>ms
+ <b></b>
+ </p>
+
+ <b>Console output:</b>
+ <pre>​<?= $item["output"] ?></pre>
+
+ <?php if (isset($item["error"])): ?>
+ <b>Server error message:</b>
+ <pre>​<?= $item["error"] ?></pre>
+ <?php endif; ?>
+
+ <b>Job lifetime:</b>
+ <ul class="tracking">
+ <li><b>Queued by PHP</b><br><?php
+ $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["queue"])), 0, -3));
+ $d[1] = (string)((float)$d[1]);
+ echo($d[0] . ":" . $d[1]);
+ ?></li>
+ <?php if (isset($item["tracking"]["pickup"])): ?><li><b>Picked up by the runner</b><br><?php
+ $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["pickup"])), 0, -3));
+ $d[1] = (string)((float)$d[1]);
+ echo($d[0] . ":" . $d[1]);
+ ?></li><?php endif; ?>
+ <?php if (isset($item["tracking"]["start"])): ?><li><b>Started</b><br><?php
+ $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["start"])), 0, -3));
+ $d[1] = (string)((float)$d[1]);
+ echo($d[0] . ":" . $d[1]);
+ ?></li><?php endif; ?>
+ <?php if (isset($item["tracking"]["end"])): ?><li><b><?= $item["completed"] ? "Finished" : "Failed" ?></b><br><?php
+ $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["end"])), 0, -3));
+ $d[1] = (string)((float)$d[1]);
+ echo($d[0] . ":" . $d[1]);
+ ?></li><?php endif; ?>
+ <?php if (isset($item["tracking"]["logged"])): ?><li><b>Tracking logged</b><br><?php
+ $d = explode("|", substr(date('M jS Y, G:i|s.u', strtotime($item["tracking"]["logged"])), 0, -3));
+ $d[1] = (string)((float)$d[1]);
+ echo($d[0] . ":" . $d[1]);
+ ?></li><?php endif; ?>
+ </ul>
+ </div>
+ </div>
+ </details>
+ <?php endforeach; ?>
+ </div>
+ </div>
+</div>
+
+<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?> \ No newline at end of file