feat: live SSE stage, phone view and presenter control
- proxy Go /api/stream through Nitro; drive /stage, /live, /plan and /forecast from scenario events - fall back to 5 s polling after SSE failures or heartbeat silence; show Live/Polling/Offline - authenticate /control and POST /api/scenario in Nitro with server-side control credentials - add big-screen stage with local QR and a no-login phone recommendation view - add SSE unit tests and a live smoke test; refresh README/Makefile
This commit is contained in:
1 parent
7181562e0f
commit
233fdbf66c
24 files changed
+2757
-49
No files matched your search
+25
-5
@@ -24,6 +24,7 @@ import type {
|
||||
MetaResponse,
|
||||
Scenario,
|
||||
ScenarioPreset,
|
||||
ScenarioState,
|
||||
Sensor,
|
||||
Shift,
|
||||
StaffingHour,
|
||||
@@ -68,9 +69,13 @@ const { data: sensors } = await useFetch<Sensor[]>('/api/sensors')
|
||||
const { data: context } = await useFetch<ContextResponse>('/api/context')
|
||||
const { data: meta } = await useFetch<MetaResponse>('/api/meta')
|
||||
const { data: presets } = await useFetch<ScenarioPreset[]>('/api/scenarios')
|
||||
const { data: liveScenarioState } = await useFetch<ScenarioState>('/api/scenario')
|
||||
const live = useLiveScenario(liveScenarioState.value)
|
||||
|
||||
const sensorId = ref(preferredSensor(sensors.value))
|
||||
const scenario = ref<Scenario>(initialScenario())
|
||||
// The stage scenario wins unless the URL explicitly asks for another one.
|
||||
if (!route.query.scenario) scenario.value = live.scenarioId
|
||||
const standard = ref<Standard>('standard')
|
||||
const approved = ref(false)
|
||||
const generating = ref(false)
|
||||
@@ -128,6 +133,16 @@ watch(
|
||||
},
|
||||
)
|
||||
|
||||
// A scenario event changes the plan. If the enum is unchanged (same scenario,
|
||||
// new override/version), the query string does not move, so refresh it here.
|
||||
watch(
|
||||
() => live.revision,
|
||||
() => {
|
||||
if (live.scenarioId !== scenario.value) scenario.value = live.scenarioId
|
||||
else void refresh()
|
||||
},
|
||||
)
|
||||
|
||||
const apiPlan = computed(() => apiPlanData.value ?? EMPTY_PLAN)
|
||||
const activeSensor = computed(() => sensors.value?.find((sensor) => sensor.id === sensorId.value))
|
||||
const activeScenario = computed(() => presets.value?.find((preset) => preset.id === scenario.value))
|
||||
@@ -383,6 +398,7 @@ function exportPlan() {
|
||||
@click="approved = !approved"
|
||||
/>
|
||||
<OnyxButton label="Export CSV" :icon="iconDownload" mode="outline" @click="exportPlan" />
|
||||
<LiveStatusBadge :status="live.status" :last-event-at="live.lastEventAt" />
|
||||
<OnyxBadge v-if="approved" color="success">Approved · demo</OnyxBadge>
|
||||
<span v-else class="small muted">Draft for manager review</span>
|
||||
</div>
|
||||
@@ -392,8 +408,8 @@ function exportPlan() {
|
||||
Local preview · the Go API plan is unchanged.
|
||||
</template>
|
||||
<template v-else>
|
||||
Go `/api/staffing` · updated {{ context ? formatDateTime(context.updated_at) : '—' }} · no POS, sales
|
||||
or labour-cost feed.
|
||||
Go /api/staffing · scenario v{{ live.version }} · broadcast
|
||||
{{ live.scenarioAt ? formatDateTime(live.scenarioAt) : '—' }} · no POS, sales or labour-cost feed.
|
||||
</template>
|
||||
</p>
|
||||
</div>
|
||||
@@ -426,6 +442,10 @@ function exportPlan() {
|
||||
The staffing API could not be loaded. Check that the Go API is running and that NUXT_API_INTERNAL_BASE points
|
||||
to it. <span v-if="error" class="muted">{{ error.statusMessage }}</span>
|
||||
</div>
|
||||
<div v-else-if="status === 'success' && !apiPlan.hours.length" class="callout callout--warning">
|
||||
<OnyxIcon :icon="iconTriangleWarning" size="16px" color="warning" />
|
||||
No open hours are available for this store and scenario yet. Pick another sensor or check the data window.
|
||||
</div>
|
||||
|
||||
<section class="summary-grid" aria-label="Plan summary">
|
||||
<MetricCard
|
||||
@@ -463,7 +483,7 @@ function exportPlan() {
|
||||
<div>
|
||||
<OnyxHeadline is="h2">Plan inputs</OnyxHeadline>
|
||||
<p class="small muted" style="margin: 0">
|
||||
Store, service standard and scenario are sent to Go `/api/staffing`. Local assumption edits render a
|
||||
Store, service standard and scenario are sent to Go /api/staffing. Local assumption edits render a
|
||||
preview from the API forecast.
|
||||
</p>
|
||||
</div>
|
||||
@@ -555,7 +575,7 @@ function exportPlan() {
|
||||
message="Assumption only. No payroll or POS data exists."
|
||||
/>
|
||||
<p class="small muted" style="grid-column: 1 / -1; margin: 0">
|
||||
These four values are not query inputs of Go `/api/staffing`. Changing them shows a local preview;
|
||||
These four values are not query inputs of Go /api/staffing. Changing them shows a local preview;
|
||||
“Use API plan” restores the server values.
|
||||
</p>
|
||||
<div class="form-actions" style="grid-column: 1 / -1">
|
||||
@@ -720,7 +740,7 @@ function exportPlan() {
|
||||
<p class="stat-label" style="margin-bottom: var(--onyx-density-xs)">Weather during the plan week</p>
|
||||
<WeatherStrip :days="weekWeather" />
|
||||
<p v-if="!weekWeather.length" class="small muted table-note">
|
||||
The weather forecast from `/api/context` does not cover this plan window yet.
|
||||
The weather forecast from /api/context does not cover this plan window yet.
|
||||
</p>
|
||||
<p class="small muted table-note">
|
||||
{{ activeScenario?.description ?? 'Base scenario uses the API forecast weather.' }}
|
||||
|
||||
Reference in new issue
Block a user