Add persistent print queue
This commit is contained in:
@@ -44,6 +44,7 @@ const controls = {
|
||||
tapeBgText: document.getElementById("tapeBgText"),
|
||||
tapeTextSwatch: document.getElementById("tapeTextSwatch"),
|
||||
tapeTextText: document.getElementById("tapeTextText"),
|
||||
queueStatus: document.getElementById("queueStatus"),
|
||||
zoomLabel: document.getElementById("zoomLabel"),
|
||||
previewImage: document.getElementById("previewImage"),
|
||||
noSelection: document.getElementById("noSelection"),
|
||||
@@ -393,6 +394,22 @@ async function sendDesign(url) {
|
||||
}
|
||||
if (payload.image) controls.previewImage.src = `${payload.image}?t=${Date.now()}`;
|
||||
setMessage(payload.message || "Vorschau erstellt.", "success");
|
||||
updateQueueStatus();
|
||||
}
|
||||
|
||||
async function updateQueueStatus() {
|
||||
if (!controls.queueStatus) return;
|
||||
try {
|
||||
const response = await fetch("/api/queue");
|
||||
const payload = await response.json();
|
||||
if (!payload.ok) return;
|
||||
const firstWaiting = payload.jobs?.find((job) => job.lastError);
|
||||
controls.queueStatus.textContent = payload.enabled
|
||||
? `Warteschlange: ${payload.length}${firstWaiting ? " (wartet auf Drucker)" : ""}`
|
||||
: "Warteschlange: aus";
|
||||
} catch {
|
||||
controls.queueStatus.textContent = "Warteschlange: unbekannt";
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelectorAll("[data-tool]").forEach((button) => {
|
||||
@@ -552,3 +569,5 @@ function hydrateImages() {
|
||||
addObject("text", { x: 4, y: 4, w: 36, h: 10, text: "P-Touch", fontSizeMm: 5.5, bold: true });
|
||||
state.selectedId = null;
|
||||
draw();
|
||||
updateQueueStatus();
|
||||
setInterval(updateQueueStatus, 10000);
|
||||
|
||||
@@ -15,6 +15,7 @@ const fields = {
|
||||
tapeTextSwatch: document.getElementById("mobileTapeTextSwatch"),
|
||||
tapeTextText: document.getElementById("mobileTapeTextText"),
|
||||
preview: document.getElementById("mobilePreview"),
|
||||
queueStatus: document.getElementById("mobileQueueStatus"),
|
||||
message: document.getElementById("mobileMessage"),
|
||||
};
|
||||
|
||||
@@ -131,6 +132,21 @@ async function send(url) {
|
||||
}
|
||||
fields.preview.src = `${payload.image}?t=${Date.now()}`;
|
||||
setMessage(payload.message || "Vorschau erstellt.", "success");
|
||||
updateQueueStatus();
|
||||
}
|
||||
|
||||
async function updateQueueStatus() {
|
||||
try {
|
||||
const response = await fetch("/api/queue");
|
||||
const payload = await response.json();
|
||||
if (!payload.ok) return;
|
||||
const firstWaiting = payload.jobs?.find((job) => job.lastError);
|
||||
fields.queueStatus.textContent = payload.enabled
|
||||
? `Warteschlange: ${payload.length}${firstWaiting ? " (wartet auf Drucker)" : ""}`
|
||||
: "Warteschlange: aus";
|
||||
} catch {
|
||||
fields.queueStatus.textContent = "Warteschlange: unbekannt";
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("mobilePreviewBtn").addEventListener("click", () => send("/api/preview"));
|
||||
@@ -167,3 +183,5 @@ document.querySelectorAll(".stepper").forEach((stepper) => {
|
||||
});
|
||||
|
||||
mobileDesign();
|
||||
updateQueueStatus();
|
||||
setInterval(updateQueueStatus, 10000);
|
||||
|
||||
Reference in New Issue
Block a user