summaryrefslogtreecommitdiff
path: root/pages/jobs.inc
blob: 109b4847f07ada74d3a4ec786c44b5d399b2b203 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?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><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["queue"])) ?></li>
                            <?php if (isset($item["tracking"]["pickup"])): ?><li><b>Picked up by the runner</b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["pickup"])) ?></li><?php endif; ?>
                            <?php if (isset($item["tracking"]["start"])): ?><li><b>Started</b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["start"])) ?></li><?php endif; ?>
                            <?php if (isset($item["tracking"]["end"])): ?><li><b><?= $item["completed"] ? "Finished" : "Failed" ?></b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["end"])) ?></li><?php endif; ?>
                            <?php if (isset($item["tracking"]["logged"])): ?><li><b>Tracking logged</b><br><?= date('M jS Y, G:i:s', strtotime($item["tracking"]["logged"])) ?></li><?php endif; ?>
                        </ul>
                    </div>
                </div>
            </details>
            <?php endforeach; ?>
        </div>
    </div>
</div>

<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/components/footer.inc'; ?>