Pipeline pages: list view, template and live-update script
Restores the first part of the pipeline pages commit that was lost in the rebase: the pipelines list template and the run page's live-update script.
This commit is contained in:
1 parent
c916ed89b5
commit
55c38e6180
2 files changed
+160
No files matched your search
@@ -0,0 +1,88 @@
|
|||||||
|
/* ==========================================================================
|
||||||
|
OpenBench - Pipeline run page
|
||||||
|
|
||||||
|
Keeps a run up to date while it is going. The server draws the page, so this
|
||||||
|
only asks for the page again, and swaps in the part that changed. It stops
|
||||||
|
once the run is over, and does nothing while the tab is hidden.
|
||||||
|
========================================================================== */
|
||||||
|
|
||||||
|
(function () {
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var live = document.getElementById('pl-live');
|
||||||
|
|
||||||
|
if (!live || live.dataset.running !== 'true')
|
||||||
|
return;
|
||||||
|
|
||||||
|
var STAMP = {
|
||||||
|
year : 'numeric', month : '2-digit', day : '2-digit',
|
||||||
|
hour : '2-digit', minute : '2-digit', second : '2-digit', hour12 : false,
|
||||||
|
};
|
||||||
|
|
||||||
|
var timer = null;
|
||||||
|
var busy = false;
|
||||||
|
|
||||||
|
// Same formatting that the base template applies when the page loads
|
||||||
|
function stamp(root) {
|
||||||
|
|
||||||
|
var nodes = root.getElementsByClassName('timestamp');
|
||||||
|
|
||||||
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
|
var seconds = Number(nodes[i].textContent);
|
||||||
|
|
||||||
|
if (isFinite(seconds) && seconds > 0)
|
||||||
|
nodes[i].textContent = new Date(1000 * seconds).toLocaleString(undefined, STAMP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop() {
|
||||||
|
clearInterval(timer);
|
||||||
|
document.removeEventListener('visibilitychange', onVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onVisible() {
|
||||||
|
if (!document.hidden)
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
function refresh() {
|
||||||
|
|
||||||
|
if (busy || document.hidden)
|
||||||
|
return;
|
||||||
|
|
||||||
|
busy = true;
|
||||||
|
|
||||||
|
fetch(window.location.href, { credentials : 'same-origin', headers : { 'Accept' : 'text/html' } })
|
||||||
|
|
||||||
|
.then(function (response) {
|
||||||
|
if (!response.ok) throw new Error('HTTP ' + response.status);
|
||||||
|
return response.text();
|
||||||
|
})
|
||||||
|
|
||||||
|
.then(function (html) {
|
||||||
|
|
||||||
|
var next = new DOMParser().parseFromString(html, 'text/html').getElementById('pl-live');
|
||||||
|
|
||||||
|
if (!next)
|
||||||
|
return; // Logged out, or the page is gone. Leave what is shown alone
|
||||||
|
|
||||||
|
if (next.dataset.signature !== live.dataset.signature) {
|
||||||
|
stamp(next);
|
||||||
|
live.replaceWith(next);
|
||||||
|
live = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (live.dataset.running !== 'true')
|
||||||
|
stop();
|
||||||
|
})
|
||||||
|
|
||||||
|
.catch(function () { /* Try again on the next tick */ })
|
||||||
|
|
||||||
|
.then(function () { busy = false; });
|
||||||
|
}
|
||||||
|
|
||||||
|
timer = setInterval(refresh, 5000);
|
||||||
|
document.addEventListener('visibilitychange', onVisible);
|
||||||
|
|
||||||
|
})();
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
{% extends "OpenBench/base.html" %}
|
||||||
|
|
||||||
|
{% block page_head %}
|
||||||
|
<div>
|
||||||
|
<h1 class="page-title">Pipelines</h1>
|
||||||
|
<p class="page-sub">Run a test, then let its result decide what runs next</p>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="stat-grid">
|
||||||
|
<div class="stat-card stat-green">
|
||||||
|
<div class="stat-icon"><i class="fa-solid fa-play"></i></div>
|
||||||
|
<div>
|
||||||
|
<div class="stat-value">{{ running }}</div>
|
||||||
|
<div class="stat-label">Running now</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="stat-icon"><i class="fa-solid fa-diagram-project"></i></div>
|
||||||
|
<div>
|
||||||
|
<div class="stat-value">{{ total }}</div>
|
||||||
|
<div class="stat-label">Pipelines</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card stat-yellow">
|
||||||
|
<div class="stat-icon"><i class="fa-solid fa-pause"></i></div>
|
||||||
|
<div>
|
||||||
|
<div class="stat-value">{{ paused }}</div>
|
||||||
|
<div class="stat-label">Paused</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if rows %}
|
||||||
|
|
||||||
|
<table class="hoverable">
|
||||||
|
|
||||||
|
<tr class="table-header">
|
||||||
|
<th>Pipeline</th>
|
||||||
|
<th>Author</th>
|
||||||
|
<th class="numeric">Steps</th>
|
||||||
|
<th>Last run</th>
|
||||||
|
<th>Status</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{% for row in rows %}
|
||||||
|
<tr data-href="/pipelines/{{ row.pipeline.id }}/">
|
||||||
|
<td class="col-test"><a href="/pipelines/{{ row.pipeline.id }}/">{{ row.pipeline.name }}</a></td>
|
||||||
|
<td>{{ row.pipeline.author|capfirst }}</td>
|
||||||
|
<td class="numeric">{{ row.steps }}</td>
|
||||||
|
<td class="col-date">{% if row.run %}<span class="timestamp">{{ row.run.started|date:"U" }}</span>{% else %}None yet{% endif %}</td>
|
||||||
|
<td><span class="badge {{ row.state.badge }}">{{ row.state.label }}</span></td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{% else %}
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="empty-state">
|
||||||
|
<i class="fa-solid fa-diagram-project"></i>
|
||||||
|
<p>No pipelines yet.</p>
|
||||||
|
<p class="muted-small">A pipeline starts a test and picks the next one from the result. An administrator adds them on the admin site for now.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
Reference in new issue
Block a user