|
@@ -655,6 +655,7 @@ async function loadVarv() {
|
|
|
renderVarvTimeline(history);
|
|
renderVarvTimeline(history);
|
|
|
renderVarvSpectrum();
|
|
renderVarvSpectrum();
|
|
|
renderVarvChroma(varvLatest);
|
|
renderVarvChroma(varvLatest);
|
|
|
|
|
+ renderVarvCalibLive();
|
|
|
const upd = document.getElementById("varv-updated");
|
|
const upd = document.getElementById("varv-updated");
|
|
|
if (upd) upd.textContent = varvLatest.length ? "Viimane mõõtmine " + varvLatest[0].ts : "Andmeid pole";
|
|
if (upd) upd.textContent = varvLatest.length ? "Viimane mõõtmine " + varvLatest[0].ts : "Andmeid pole";
|
|
|
if (hint) hint.hidden = true;
|
|
if (hint) hint.hidden = true;
|
|
@@ -915,6 +916,15 @@ async function loadVarvCalib() {
|
|
|
} catch (e) { console.error(e); }
|
|
} catch (e) { console.error(e); }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function renderVarvCalibLive() {
|
|
|
|
|
+ const el = document.getElementById("varv-calib-live");
|
|
|
|
|
+ if (!el) return;
|
|
|
|
|
+ if (!varvLatest.length) { el.textContent = ""; return; }
|
|
|
|
|
+ const c = varvLatest[0];
|
|
|
|
|
+ const sum = Object.values(c.bands || {}).reduce((a, v) => a + (Number(v) || 0), 0);
|
|
|
|
|
+ el.textContent = `Viimane mõõtmine: ${(c.rgb_hex || "").toUpperCase()} · heledus (kanalite summa) ${Math.round(sum)}`;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
async function captureVarvCalib(kind) {
|
|
async function captureVarvCalib(kind) {
|
|
|
if (!state.authed) return;
|
|
if (!state.authed) return;
|
|
|
const hint = document.getElementById("varv-calib-hint");
|
|
const hint = document.getElementById("varv-calib-hint");
|
|
@@ -924,7 +934,14 @@ async function captureVarvCalib(kind) {
|
|
|
headers: { "Content-Type": "application/json" },
|
|
headers: { "Content-Type": "application/json" },
|
|
|
body: JSON.stringify({ kind, last: 5 }),
|
|
body: JSON.stringify({ kind, last: 5 }),
|
|
|
});
|
|
});
|
|
|
- if (!res.ok) throw new Error("HTTP " + res.status);
|
|
|
|
|
|
|
+ if (!res.ok) {
|
|
|
|
|
+ let msg = `Salvestamine ebaõnnestus (HTTP ${res.status}).`;
|
|
|
|
|
+ try {
|
|
|
|
|
+ const e = await res.json();
|
|
|
|
|
+ if (typeof e.detail === "string") msg = e.detail;
|
|
|
|
|
+ } catch (ignored) { /* ignore */ }
|
|
|
|
|
+ throw new Error(msg);
|
|
|
|
|
+ }
|
|
|
const d = await res.json();
|
|
const d = await res.json();
|
|
|
if (hint) {
|
|
if (hint) {
|
|
|
hint.hidden = false;
|
|
hint.hidden = false;
|
|
@@ -935,7 +952,7 @@ async function captureVarvCalib(kind) {
|
|
|
loadVarv();
|
|
loadVarv();
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.error(e);
|
|
console.error(e);
|
|
|
- if (hint) { hint.hidden = false; hint.textContent = "Salvestamine ebaõnnestus."; }
|
|
|
|
|
|
|
+ if (hint) { hint.hidden = false; hint.textContent = e.message || "Salvestamine ebaõnnestus."; }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|