feat(ui): render the CCTV frame preview, source badge and summary from the store

The frame lifecycle keeps its request state in an object instead of the
image's dataset and publishes it; the panel binds the image's src, class
and data attributes and the wrapper's loading and has-frame classes from
it, so preload tokens, kept pixels on a failed refresh and clearing on a
camera change are unchanged. The source badge is the pure
presentCctvSourceBadge(), the live switch and the typed summary are
published too. The video surface still draws into the panel's canvas.
This commit is contained in:
Sameh Khamis committed 2026-10-30 21:54:42 -07:00
1 parent 6c7035f617
commit eef3dec759
10 files changed
+306 -177

No files matched your search

+47 -5
View File
@@ -2,10 +2,10 @@ import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
/**
* The CCTV panel's buttons, CAL chip, meta line and calibration readout as
* its view renders them. CctvControls presents them (`presentCctvPanel()`)
* and publishes here; it keeps its listeners on the buttons and paints the
* picker, frame, source badge and summary itself.
* The CCTV panel as its view renders it. CctvControls presents the buttons,
* CAL chip, meta line and calibration readout (`presentCctvPanel()`), runs
* the frame preview, source badge and typed summary, and publishes them
* here; it keeps its listeners on the buttons and fills the picker itself.
*/
export const useCctvStore = defineStore('gev-cctv', () => {
/** The presented panel; null until the controls first render. */
@@ -17,6 +17,15 @@ export const useCctvStore = defineStore('gev-cctv', () => {
*/
const calEdit = shallowRef(null);
/** The preview: requested and shown frame, loading and error state. */
const frame = shallowRef(null);
/** Whether the live video surface replaces the still frame. */
const live = shallowRef(false);
/** `{label, state}` for the source badge; null until first synced. */
const sourceBadge = shallowRef(null);
/** The scene summary as typed so far; null until the first one. */
const summary = shallowRef(null);
/** @param {object} next A fresh presentation; every publish re-renders. */
function publish(next) {
view.value = markRaw(next);
@@ -29,5 +38,38 @@ export const useCctvStore = defineStore('gev-cctv', () => {
calEdit.value = edit ? markRaw({ ...edit, id: ++editCount }) : null;
}
return { view, calEdit, publish, setCalEdit };
/** @param {object} next */
function setFrame(next) {
frame.value = markRaw(next);
}
/** @param {boolean} on */
function setLive(on) {
live.value = Boolean(on);
}
/** @param {{label: string, state: string}} next */
function setSourceBadge(next) {
sourceBadge.value = markRaw(next);
}
/** @param {string} text */
function setSummary(text) {
summary.value = text;
}
return {
view,
calEdit,
frame,
live,
sourceBadge,
summary,
publish,
setCalEdit,
setFrame,
setLive,
setSourceBadge,
setSummary,
};
});