2021-05-02 14:04:18 +00:00
|
|
|
function getVersion() {
|
|
|
|
fetch('/api/version')
|
|
|
|
.then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
})
|
|
|
|
.then(function(version) {
|
|
|
|
document.getElementById("version").innerHTML = "v" + version.version;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-05-02 14:26:23 +00:00
|
|
|
let current_job = null;
|
|
|
|
|
2021-05-02 14:04:18 +00:00
|
|
|
function runctnr() {
|
|
|
|
document.getElementById("btnlaunch").disabled = true;
|
|
|
|
document.getElementById("btnlaunchspinner").style.display = "inline-block";
|
2021-05-09 18:15:29 +00:00
|
|
|
document.getElementById("error-alert").style.display = "none";
|
2021-05-02 14:04:18 +00:00
|
|
|
|
|
|
|
fetch('/api/run')
|
2021-05-02 14:26:23 +00:00
|
|
|
.then(function(response) {
|
2021-05-09 18:15:29 +00:00
|
|
|
if (response.status >= 200 && response.status <= 299) {
|
|
|
|
return response.json();
|
|
|
|
} else {
|
|
|
|
throw response;
|
|
|
|
}
|
2021-05-02 14:26:23 +00:00
|
|
|
})
|
|
|
|
.then(function(data) {
|
|
|
|
current_job = data.jobid;
|
|
|
|
|
|
|
|
document.getElementById("jobid").textContent = current_job;
|
|
|
|
document.getElementById("started-alert").style.display = "block";
|
|
|
|
|
|
|
|
fetchLogs();
|
|
|
|
})
|
2021-05-09 18:15:29 +00:00
|
|
|
.catch(function(error) {
|
|
|
|
error.json().then(json => {
|
|
|
|
document.getElementById("errortxt").textContent = json.error;
|
|
|
|
document.getElementById("error-alert").style.display = "block";
|
|
|
|
})
|
|
|
|
|
|
|
|
document.getElementById("btnlaunch").disabled = false;
|
|
|
|
document.getElementById("btnlaunchspinner").style.display = "none";
|
|
|
|
})
|
2021-05-02 14:26:23 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
function fetchLogs() {
|
2021-05-02 15:59:55 +00:00
|
|
|
var ws = new WebSocket('ws://' + window.location.host + '/api/jobs/' + current_job + '/logs');
|
2021-05-02 14:26:23 +00:00
|
|
|
|
2021-05-02 15:59:55 +00:00
|
|
|
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.");
|
|
|
|
|
2021-05-02 17:27:30 +00:00
|
|
|
fetchVolumes()
|
|
|
|
|
2021-05-02 15:59:55 +00:00
|
|
|
current_job = null;
|
|
|
|
|
|
|
|
document.getElementById("btnlaunch").disabled = false;
|
|
|
|
document.getElementById("btnlaunchspinner").style.display = "none";
|
|
|
|
document.getElementById("started-alert").style.display = "none";
|
|
|
|
};
|
2021-05-02 14:04:18 +00:00
|
|
|
}
|
2021-05-02 17:27:30 +00:00
|
|
|
|
|
|
|
function fetchVolumes() {
|
|
|
|
fetch('/api/jobs/' + current_job + '/volumes')
|
|
|
|
.then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
})
|
|
|
|
.then(function(data) {
|
|
|
|
document.getElementById("volumes").innerHTML = "";
|
|
|
|
|
|
|
|
for (const i in data) {
|
|
|
|
let a = document.createElement("a");
|
|
|
|
a.className = "list-group-item list-group-item-action";
|
|
|
|
a.href = "/artifacts" + data[i];
|
|
|
|
a.innerText = data[i];
|
|
|
|
document.getElementById("volumes").appendChild(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (data.length > 0) {
|
|
|
|
document.getElementById("volumes-card").style.display = "block";
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|