Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion src/main/resources/static/assets/viewer/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,19 @@ function createActionButton(label, onClick) {
button.type = "button";
button.textContent = label;
button.className = "btn btn-secondary btn-compact";
button.addEventListener("click", onClick);
button.addEventListener("click", async (event) => {
const originalText = button.textContent;
button.disabled = true;
button.setAttribute("aria-busy", "true");
button.textContent = "Loading...";
try {
await Promise.resolve(onClick(event));
} finally {
button.disabled = false;
button.removeAttribute("aria-busy");
button.textContent = originalText;
}
});
return button;
}

Expand Down Expand Up @@ -270,7 +282,10 @@ async function retryActiveJob() {

const jobId = activeJobDetail.jobId;
setStatus("Requesting operator retry...");
const originalText = el.retryJobBtn.textContent;
el.retryJobBtn.disabled = true;
el.retryJobBtn.setAttribute("aria-busy", "true");
el.retryJobBtn.textContent = "Retrying...";
try {
const res = await fetch(`/api/v1/convert/jobs/${encodeURIComponent(jobId)}/retry`, {
method: "POST",
Expand Down Expand Up @@ -307,6 +322,8 @@ async function retryActiveJob() {
} catch (err) {
setError("Network error while requesting retry. Retry when the service is reachable.");
} finally {
el.retryJobBtn.removeAttribute("aria-busy");
el.retryJobBtn.textContent = originalText;
el.retryJobBtn.disabled = false;
}
}
Expand Down Expand Up @@ -380,7 +397,11 @@ async function refreshKpis() {
}

async function refreshKpiEvidence() {
const originalText = el.refreshEvidenceBtn.textContent;
try {
el.refreshEvidenceBtn.disabled = true;
el.refreshEvidenceBtn.setAttribute("aria-busy", "true");
el.refreshEvidenceBtn.textContent = "Refreshing...";
const { res, data } = await fetchJson(KPI_EXPORTS_ENDPOINT);
if (!res.ok) {
el.kpiExportStatus.textContent = "Snapshot evidence is unavailable for the current tenant claim.";
Expand All @@ -390,6 +411,10 @@ async function refreshKpiEvidence() {
renderKpiEvidence(data);
} catch (err) {
el.kpiExportStatus.textContent = "Snapshot evidence is unavailable while the service is unreachable.";
} finally {
el.refreshEvidenceBtn.removeAttribute("aria-busy");
el.refreshEvidenceBtn.textContent = originalText;
el.refreshEvidenceBtn.disabled = false;
}
}

Expand Down Expand Up @@ -435,7 +460,10 @@ async function submitDocument(event) {
return;
}

const originalText = el.submitBtn.textContent;
el.submitBtn.disabled = true;
el.submitBtn.setAttribute("aria-busy", "true");
el.submitBtn.textContent = "Submitting...";
setStatus("Submitting document...");

try {
Expand Down Expand Up @@ -478,6 +506,8 @@ async function submitDocument(event) {
addFailedHistory(file.name, "FAILED");
setError("Network error while submitting. Retry when the service is reachable.");
} finally {
el.submitBtn.removeAttribute("aria-busy");
el.submitBtn.textContent = originalText;
el.submitBtn.disabled = false;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/static/assets/viewer/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function setLoading(message) {
el.liveStatus.textContent = message;
el.preview.setAttribute("aria-busy", "true");
el.retryBtn.disabled = true;
el.retryBtn.setAttribute("aria-busy", "true");
el.retryBtn.textContent = "Refreshing...";
}

Expand All @@ -60,6 +61,7 @@ function showError(message) {
el.liveStatus.textContent = "";
el.preview.setAttribute("aria-busy", "false");
el.errorTitle.focus();
el.retryBtn.removeAttribute("aria-busy");
el.retryBtn.disabled = false;
el.retryBtn.textContent = "Refresh";
}
Expand Down Expand Up @@ -209,6 +211,7 @@ async function poll(docId, abortSignal) {

el.preview.setAttribute("aria-busy", "false");
el.liveStatus.textContent = "Ready.";
el.retryBtn.removeAttribute("aria-busy");
el.retryBtn.disabled = false;
el.retryBtn.textContent = "Refresh";

Expand Down
Loading