Use websocket to transmit logs
This commit is contained in:
parent
539cbd68a9
commit
d2a49e5740
6 changed files with 67 additions and 19 deletions
|
|
@ -23,11 +23,11 @@
|
|||
it's ID is <code id="jobid"></code>
|
||||
</div>
|
||||
|
||||
<div id="logs-card" class="card" style="display: none;">
|
||||
<div id="logs-card" class="mb-3 card" style="display: none;">
|
||||
<h5 class="card-header">
|
||||
Here is your container logs output:
|
||||
</h5>
|
||||
<pre id="logs" class="card-body bg-dark text-light"></pre>
|
||||
<pre id="logs" class="mb-0 card-body bg-dark text-light"></pre>
|
||||
</div>
|
||||
|
||||
<script src="/js/minifass.js"></script>
|
||||
|
|
|
|||
|
|
@ -30,17 +30,26 @@ function runctnr() {
|
|||
}
|
||||
|
||||
function fetchLogs() {
|
||||
fetch('/api/jobs/' + current_job + '/logs')
|
||||
.then(function(response) {
|
||||
document.getElementById("btnlaunch").disabled = false;
|
||||
document.getElementById("btnlaunchspinner").style.display = "none";
|
||||
document.getElementById("started-alert").style.display = "none";
|
||||
var ws = new WebSocket('ws://' + window.location.host + '/api/jobs/' + current_job + '/logs');
|
||||
|
||||
return response.text();
|
||||
})
|
||||
.then(function(logs) {
|
||||
document.getElementById("logs").textContent = logs;
|
||||
document.getElementById("logs-card").style.display = "block";
|
||||
current_job = null;
|
||||
})
|
||||
ws.onopen = function (evt) {
|
||||
console.log("Connection open ...");
|
||||
document.getElementById("logs-card").style.display = "block";
|
||||
document.getElementById("logs").innerText = "";
|
||||
};
|
||||
|
||||
ws.onmessage = function (evt) {
|
||||
console.log("Received Message: " + evt.data);
|
||||
document.getElementById("logs").innerText += evt.data;
|
||||
};
|
||||
|
||||
ws.onclose = function (evt) {
|
||||
console.log("Connection closed.");
|
||||
|
||||
current_job = null;
|
||||
|
||||
document.getElementById("btnlaunch").disabled = false;
|
||||
document.getElementById("btnlaunchspinner").style.display = "none";
|
||||
document.getElementById("started-alert").style.display = "none";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue