Finishing touches
This commit is contained in:
parent
ce28efde7c
commit
9a0d4e2261
@ -8,13 +8,17 @@ const fetchJobState = async () => {
|
||||
}
|
||||
const data = await response.json();
|
||||
// Update UI with job state
|
||||
document.getElementById('job_state').innerText = data.state;
|
||||
document.getElementById('state-msg').innerText = data.state;
|
||||
if (data.state == "error") {
|
||||
document.getElementById('job_error').innerText = data.error;
|
||||
document.getElementById('err_msg').style = 'display: inline-block;'
|
||||
stopPolling();
|
||||
}
|
||||
if (data.state == "done") {
|
||||
stopPolling();
|
||||
showDownloadButton();
|
||||
document.title = "All Done"
|
||||
document.getElementById('title').textContent = "All Done"
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@ -25,6 +29,10 @@ function stopPolling() {
|
||||
clearInterval(pollingIntervalId)
|
||||
}
|
||||
|
||||
function showDownloadButton() {
|
||||
document.getElementById('download-button').style = 'display: inline-block;'
|
||||
}
|
||||
|
||||
// Poll the endpoint every 5 seconds (adjust as needed)
|
||||
const pollingInterval = 2000; //ms
|
||||
const pollingIntervalId = setInterval(fetchJobState, pollingInterval);
|
||||
|
@ -6,3 +6,33 @@ body {
|
||||
text-align: center;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.download-button {
|
||||
display: none;
|
||||
text-decoration: none;
|
||||
background-color: #008080; /* Teal color */
|
||||
border: 2px solid #000; /* Black border */
|
||||
color: #fff; /* White text */
|
||||
padding: 10px 20px; /* Padding */
|
||||
font-size: 16px; /* Font size */
|
||||
font-weight: bold; /* Bold text */
|
||||
cursor: pointer; /* Cursor on hover */
|
||||
outline: none; /* Remove outline on focus */
|
||||
transition: background-color 0.3s, border-color 0.3s, color 0.3s; /* Smooth transition */
|
||||
}
|
||||
|
||||
.download-button:hover {
|
||||
background-color: #fff; /* White background on hover */
|
||||
border-color: #008080; /* Teal border on hover */
|
||||
color: #008080; /* Teal text on hover */
|
||||
}
|
||||
|
||||
#state {
|
||||
padding: 30px;
|
||||
margin: 30px;
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
#err_msg {
|
||||
display: none;
|
||||
}
|
@ -9,11 +9,13 @@
|
||||
<script src="/checkjob.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Please wait</h1>
|
||||
<h1 id="title">Please wait</h1>
|
||||
<p>Job ID: <%= job_id %></p>
|
||||
<br>
|
||||
<p>Job State: <span id="job_state"></span></p>
|
||||
<p>Job Error: <span id="job_error">None</span></p>
|
||||
<p><a href="/download?job_id=<%= job_id %>">Download</a></p>
|
||||
<div id="state">
|
||||
<span class="pending" id="state-msg">pending</span>
|
||||
</div>
|
||||
<p id="err_msg">Job Error: <span id="job_error">None</span></p>
|
||||
<a id="download-button" class="download-button" href="/download?job_id=<%= job_id %>">Download</a>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user