- replace default Onyx surfaces with paper/ink, signal orange and Archivo - make /plan answer peak, staff-hours, cost vs flat and coverage above the fold - add the weekly shift board, shared plan helpers and a pulse line - rebuild /live as a phone-first dark board and /stage as a full-bleed projector - label the real 14-20 Nov window; remove 'next week' claims - keep Onyx components, SSR, live scenario updates and accessible states
This commit is contained in:
1 parent
66b80a62fb
commit
33063afbdf
18 files changed
+4300
-1452
No files matched your search
+1
-1
@@ -18,7 +18,7 @@ const usingMock = computed(() => ['1', 'true'].includes(String(config.public.use
|
||||
<p class="eyebrow">About · method, data and limits</p>
|
||||
<OnyxHeadline is="h1">A decision aid, not a city-wide truth.</OnyxHeadline>
|
||||
<p class="lede">
|
||||
PulseCast turns a footfall forecast into a next-week staffing plan. The forecast is a model output; the
|
||||
PulseCast turns a footfall forecast into a weekly staffing plan. The forecast is a model output; the
|
||||
staffing rule is a transparent heuristic. Both are shown, editable, and bounded.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -114,7 +114,7 @@ const total = computed(() => days.value.reduce((sum, day) => sum + day.mean, 0))
|
||||
<header class="page-header">
|
||||
<div>
|
||||
<p class="eyebrow">Forecast · {{ forecastWindow }}</p>
|
||||
<OnyxHeadline is="h1">Next week peaks on {{ weekPeak ? formatWeekday(weekPeak.date) : '—' }}.</OnyxHeadline>
|
||||
<OnyxHeadline is="h1">The window peaks on {{ weekPeak ? formatWeekday(weekPeak.date) : '—' }}.</OnyxHeadline>
|
||||
<p class="lede">
|
||||
A 168-hour forecast for <strong>{{ activeSensor?.name ?? 'the selected store' }}</strong>, aggregated by
|
||||
day. The decision, shift blocks and hourly coverage are on <NuxtLink to="/plan">Plan</NuxtLink>.
|
||||
|
||||
+546
-233
@@ -1,31 +1,34 @@
|
||||
<script setup lang="ts">
|
||||
import { iconArrowRight, iconTriangleWarning } from '@sit-onyx/icons'
|
||||
import { addDays, berlinParts, planWeekStart } from '#shared/staffing'
|
||||
import type { MetaResponse, ScenarioState, Sensor, SeriesResponse, StaffingResponse } from '#shared/types'
|
||||
import {
|
||||
iconCalendar,
|
||||
iconCloud,
|
||||
iconLocationPin,
|
||||
iconSunny,
|
||||
iconTriangleWarning,
|
||||
} from '@sit-onyx/icons'
|
||||
import { weatherKind } from '#shared/insights'
|
||||
import { berlinParts } from '#shared/staffing'
|
||||
import type { ContextResponse, MetaResponse, Sensor, SeriesResponse } from '#shared/types'
|
||||
import {
|
||||
formatDate,
|
||||
formatDateTime,
|
||||
formatEuro,
|
||||
formatNumber,
|
||||
formatPercent,
|
||||
formatShortDate,
|
||||
formatTime,
|
||||
formatWeekday,
|
||||
weekLabel,
|
||||
} from '~/utils/format'
|
||||
|
||||
useHead({ title: 'Now in Heilbronn — PulseCast' })
|
||||
import {
|
||||
numberWord,
|
||||
peakHourOf,
|
||||
peakShiftOf,
|
||||
planDays,
|
||||
savingOf,
|
||||
savingPctOf,
|
||||
totalStaffHoursOf,
|
||||
} from '~/utils/plan'
|
||||
|
||||
const config = useRuntimeConfig()
|
||||
const demoNow = String(config.public.demoNow)
|
||||
|
||||
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: liveScenarioState } = await useFetch<ScenarioState>('/api/scenario')
|
||||
const live = useLiveScenario(liveScenarioState.value)
|
||||
|
||||
const sensorId = ref(
|
||||
sensors.value?.find((sensor) => sensor.id === 'hn-stadtgalerie-01')?.id ??
|
||||
sensors.value?.[0]?.id ??
|
||||
@@ -35,235 +38,545 @@ const { data: series } = await useFetch<SeriesResponse>('/api/series', {
|
||||
query: computed(() => ({ sensor: sensorId.value, step: '1h' })),
|
||||
})
|
||||
|
||||
const activeSensor = computed(() => sensors.value?.find((sensor) => sensor.id === sensorId.value))
|
||||
const sensorOptions = computed(() =>
|
||||
(sensors.value ?? []).map((sensor) => ({ value: sensor.id, label: sensor.name })),
|
||||
const { data: planData, status, refresh } = await useFetch<StaffingResponse>('/api/staffing', {
|
||||
query: computed(() => ({ sensor: sensorId.value, scenario: live.scenarioId, standard: 'standard' })),
|
||||
})
|
||||
|
||||
let lastScenarioId = live.scenarioId
|
||||
watch(
|
||||
() => live.revision,
|
||||
() => {
|
||||
if (live.scenarioId === lastScenarioId) void refresh()
|
||||
lastScenarioId = live.scenarioId
|
||||
},
|
||||
)
|
||||
|
||||
const plan = computed(() => planData.value ?? null)
|
||||
const activeSensor = computed(() => sensors.value?.find((sensor) => sensor.id === sensorId.value))
|
||||
const peakShift = computed(() => peakShiftOf(plan.value))
|
||||
const peakHour = computed(() => peakHourOf(plan.value))
|
||||
const totalStaffHours = computed(() => totalStaffHoursOf(plan.value))
|
||||
const savingEur = computed(() => savingOf(plan.value))
|
||||
const savingPct = computed(() => savingPctOf(plan.value))
|
||||
const daySummaries = computed(() => planDays(plan.value))
|
||||
|
||||
const weekStart = computed(() => {
|
||||
const first = plan.value?.hours[0]
|
||||
return first ? berlinParts(first.t).date : planWeekStart(demoNow)
|
||||
})
|
||||
const weekEnd = computed(() => addDays(weekStart.value, 6))
|
||||
const today = computed(() => berlinParts(demoNow).date)
|
||||
const windowTag = computed(() => {
|
||||
if (!plan.value) return 'No plan'
|
||||
return weekStart.value <= today.value && today.value <= weekEnd.value ? 'Today–Friday' : 'Seven days'
|
||||
})
|
||||
const windowLabel = computed(() => (plan.value ? weekLabel(weekStart.value, weekEnd.value) : 'Window unavailable'))
|
||||
|
||||
const lastPoint = computed(() => series.value?.points.at(-1))
|
||||
const previousPoint = computed(() => series.value?.points.at(-25))
|
||||
const deltaPct = computed(() => {
|
||||
if (!lastPoint.value || !previousPoint.value || previousPoint.value.v === 0) return 0
|
||||
return ((lastPoint.value.v - previousPoint.value.v) / previousPoint.value.v) * 100
|
||||
})
|
||||
const last24 = computed(() => series.value?.points.slice(-24) ?? [])
|
||||
const barMax = computed(() => Math.max(...last24.value.map((point) => point.v), 1))
|
||||
const lastMeasured = computed(() => (lastPoint.value ? formatDateTime(lastPoint.value.t) : '—'))
|
||||
const latestReading = computed(() => (lastPoint.value ? formatNumber(lastPoint.value.v) : '—'))
|
||||
|
||||
const nowWeather = computed(() => context.value?.weather.now)
|
||||
const weatherIcon = computed(() =>
|
||||
nowWeather.value && weatherKind(nowWeather.value) === 'sunny' ? iconSunny : iconCloud,
|
||||
)
|
||||
const weatherLabel = computed(() => {
|
||||
if (!nowWeather.value) return '—'
|
||||
const kind = weatherKind(nowWeather.value)
|
||||
return kind === 'sunny' ? 'Sunny' : kind === 'partly-cloudy' ? 'Partly cloudy' : kind === 'rain' ? 'Rain' : 'Cloudy'
|
||||
})
|
||||
|
||||
const today = berlinParts(demoNow).date
|
||||
const todayHoliday = computed(() => context.value?.holidays.find((holiday) => holiday.date === today))
|
||||
const lastHoliday = computed(() =>
|
||||
context.value?.holidays.filter((holiday) => holiday.date < today).at(-1),
|
||||
)
|
||||
const nextHoliday = computed(() =>
|
||||
context.value?.holidays.find((holiday) => holiday.date > today),
|
||||
)
|
||||
|
||||
const latestPulse = computed(() => {
|
||||
if (!sensors.value?.length) return 0
|
||||
return Math.round(sensors.value.reduce((sum, sensor) => sum + sensor.mean, 0) / sensors.value.length)
|
||||
})
|
||||
useHead(() => ({
|
||||
title: peakShift.value
|
||||
? `${numberWord(peakShift.value.staff)} on ${formatWeekday(peakShift.value.date)} — PulseCast`
|
||||
: 'PulseCast — footfall to shifts',
|
||||
}))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page page-stack">
|
||||
<header class="page-header">
|
||||
<div>
|
||||
<p class="eyebrow">Now · replay clock {{ formatDateTime(demoNow) }}</p>
|
||||
<OnyxHeadline is="h1">The pulse is in the pedestrian core.</OnyxHeadline>
|
||||
<p class="lede">
|
||||
Eight fixed sensors around Stadtgalerie and Kaiserstraße. This is estimated device density, not people,
|
||||
and not a city-wide heatmap. The decision lives on <NuxtLink to="/plan">Plan</NuxtLink>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="hero-actions">
|
||||
<OnyxBadge color="warning">Replay, not live</OnyxBadge>
|
||||
<OnyxBadge color="neutral" density="compact">{{ sensors?.length ?? 8 }} sensors</OnyxBadge>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="split-grid">
|
||||
<div class="card-stack">
|
||||
<OnyxCard>
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<OnyxHeadline is="h2">Latest replay reading</OnyxHeadline>
|
||||
<p class="small muted" style="margin: 0">Last available hour in the API series.</p>
|
||||
</div>
|
||||
<div style="min-width: 12rem">
|
||||
<OnyxSelect
|
||||
v-model="sensorId"
|
||||
label="Sensor"
|
||||
list-label="Inner-city sensors"
|
||||
:options="sensorOptions"
|
||||
density="compact"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="reading-row">
|
||||
<p class="reading-value">{{ lastPoint ? formatNumber(lastPoint.v) : '—' }}</p>
|
||||
<div>
|
||||
<p style="margin: 0; font-weight: 600">estimated devices / hour</p>
|
||||
<p class="small muted" style="margin: 0">
|
||||
{{ activeSensor?.name }} · {{ activeSensor?.id }}
|
||||
</p>
|
||||
<OnyxBadge :color="deltaPct >= 0 ? 'success' : 'warning'" density="compact">
|
||||
{{ deltaPct >= 0 ? '+' : '' }}{{ formatPercent(deltaPct, 0) }} vs 24 h earlier
|
||||
</OnyxBadge>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bar-chart" role="img" :aria-label="`Last 24 hours for ${activeSensor?.name}`">
|
||||
<div
|
||||
v-for="(point, index) in last24"
|
||||
:key="point.t"
|
||||
class="bar-chart__bar"
|
||||
:class="{ 'bar-chart__bar--now': index === last24.length - 1 }"
|
||||
:style="{ height: `${Math.max(4, (point.v / barMax) * 100)}%` }"
|
||||
:title="`${formatTime(point.t)} · ${point.v}`"
|
||||
/>
|
||||
</div>
|
||||
<div class="legend" style="justify-content: space-between; margin-top: var(--onyx-density-2xs)">
|
||||
<span class="small muted">{{ last24[0] ? formatTime(last24[0].t) : '—' }}</span>
|
||||
<span class="small muted">{{ lastPoint ? formatDateTime(lastPoint.t) : '—' }}</span>
|
||||
</div>
|
||||
|
||||
<p class="small muted table-note">
|
||||
This is a replay snapshot, not a live sensor feed. The replay clock is
|
||||
{{ formatDateTime(demoNow) }}; the last measured point is
|
||||
{{ lastPoint ? formatDateTime(lastPoint.t) : '—' }}.
|
||||
</p>
|
||||
</OnyxCard>
|
||||
|
||||
<OnyxCard>
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<OnyxHeadline is="h2">Sensor cluster</OnyxHeadline>
|
||||
<p class="small muted" style="margin: 0">
|
||||
Select a sensor to update the reading. Positions are relative; this is not a geographic map.
|
||||
</p>
|
||||
</div>
|
||||
<OnyxBadge color="info" density="compact">580 m cluster</OnyxBadge>
|
||||
</div>
|
||||
<SensorClusterMap :sensors="sensors ?? []" :active-id="sensorId" @select="sensorId = $event" />
|
||||
</OnyxCard>
|
||||
</div>
|
||||
|
||||
<aside class="card-stack">
|
||||
<OnyxCard>
|
||||
<div class="card-header">
|
||||
<OnyxHeadline is="h2">Heilbronn weather</OnyxHeadline>
|
||||
<OnyxBadge color="neutral" density="compact">Open-Meteo context</OnyxBadge>
|
||||
</div>
|
||||
<div class="reading-row">
|
||||
<OnyxIcon :icon="weatherIcon" size="48px" color="primary" />
|
||||
<div>
|
||||
<p style="margin: 0; font-size: 2rem; font-weight: 700; line-height: 1">
|
||||
{{ nowWeather ? `${nowWeather.temp_c} °C` : '—' }}
|
||||
</p>
|
||||
<p class="small muted" style="margin: 0">{{ weatherLabel }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<dl class="metric-list" style="margin-top: var(--onyx-density-md)">
|
||||
<div><dt>Precipitation</dt><dd>{{ nowWeather?.precip_mm ?? '—' }} mm</dd></div>
|
||||
<div><dt>Cloud cover</dt><dd>{{ nowWeather?.cloud_pct ?? '—' }}%</dd></div>
|
||||
<div><dt>Wind</dt><dd>{{ nowWeather?.wind_kmh ?? '—' }} km/h</dd></div>
|
||||
<div><dt>Humidity</dt><dd>{{ nowWeather?.humidity_pct ?? '—' }}%</dd></div>
|
||||
</dl>
|
||||
<p class="small muted table-note">
|
||||
Updated {{ context ? formatDateTime(context.updated_at) : '—' }} · context
|
||||
{{ context?.cached ? 'cached' : 'live' }}
|
||||
</p>
|
||||
</OnyxCard>
|
||||
|
||||
<OnyxCard>
|
||||
<div class="card-header">
|
||||
<OnyxHeadline is="h2">Holiday context</OnyxHeadline>
|
||||
<OnyxIcon :icon="iconCalendar" size="24px" color="primary" />
|
||||
</div>
|
||||
<OnyxBadge v-if="todayHoliday" color="warning">{{ todayHoliday.name }} today</OnyxBadge>
|
||||
<OnyxBadge v-else color="success">No public holiday today</OnyxBadge>
|
||||
<p class="small muted" style="margin: var(--onyx-density-sm) 0 0">
|
||||
<template v-if="nextHoliday">
|
||||
Next: <strong>{{ nextHoliday.name }}</strong> on {{ formatDate(nextHoliday.date) }}.
|
||||
</template>
|
||||
<template v-else>No upcoming holiday in the holiday calendar.</template>
|
||||
</p>
|
||||
<p v-if="lastHoliday" class="small muted" style="margin: var(--onyx-density-xs) 0 0">
|
||||
Last: {{ lastHoliday.name }} on {{ formatShortDate(lastHoliday.date) }}.
|
||||
</p>
|
||||
<p class="small muted table-note">
|
||||
Baden-Württemberg public holidays; used as model context, not as a causal claim.
|
||||
</p>
|
||||
</OnyxCard>
|
||||
|
||||
<OnyxCard>
|
||||
<div class="card-header">
|
||||
<OnyxHeadline is="h3">What to do next</OnyxHeadline>
|
||||
<OnyxIcon :icon="iconLocationPin" size="24px" color="primary" />
|
||||
</div>
|
||||
<p class="small" style="margin-top: 0">
|
||||
The average sensor is at <strong>{{ latestPulse }}</strong> estimated devices/hour. That is context,
|
||||
not a staffing decision. Open the plan to turn next week’s forecast into shifts.
|
||||
</p>
|
||||
<OnyxButton label="Open the staffing plan" link="/plan" color="primary" />
|
||||
</OnyxCard>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
<OnyxCard>
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<OnyxHeadline is="h2">Eight sensors</OnyxHeadline>
|
||||
<p class="small muted" style="margin: 0">Measured points, stable order by ID. Battery may be null in the API.</p>
|
||||
<div class="pc-page landing">
|
||||
<section class="landing__hero" aria-labelledby="landing-title">
|
||||
<div class="landing__copy">
|
||||
<div class="landing__meta">
|
||||
<span class="pc-tag">{{ windowTag }}</span>
|
||||
<LiveStatusBadge :status="live.status" :last-event-at="live.lastEventAt" compact />
|
||||
</div>
|
||||
<OnyxBadge color="neutral" density="compact">measured points only</OnyxBadge>
|
||||
|
||||
<h1 id="landing-title" class="landing__title">
|
||||
<template v-if="peakShift">{{ numberWord(peakShift.staff) }} on {{ formatWeekday(peakShift.date) }}.</template>
|
||||
<template v-else>The week, shifted.</template>
|
||||
</h1>
|
||||
|
||||
<p class="landing__lede">
|
||||
<template v-if="plan">
|
||||
PulseCast turns inner-city footfall into a shift plan you can defend.
|
||||
This window: <strong>{{ totalStaffHours }} staff-hours</strong>,
|
||||
<strong>{{ formatEuro(plan.summary.cost_eur) }}</strong>,
|
||||
<strong>{{ formatPercent(plan.summary.coverage_pct, 1) }} coverage</strong>.
|
||||
</template>
|
||||
<template v-else>
|
||||
PulseCast turns inner-city footfall into a transparent shift plan for the week.
|
||||
</template>
|
||||
</p>
|
||||
|
||||
<div class="landing__actions">
|
||||
<OnyxButton label="Open the plan" link="/plan" color="primary" :icon="iconArrowRight" icon-position="right" />
|
||||
<OnyxButton label="See the forecast" link="/forecast" mode="outline" />
|
||||
</div>
|
||||
|
||||
<ol class="landing__chain" aria-label="How the plan is made">
|
||||
<li><span>Measured</span> footfall</li>
|
||||
<li><span>Modelled</span> forecast</li>
|
||||
<li><span>Declared</span> assumptions</li>
|
||||
<li><span>Shift</span> plan</li>
|
||||
</ol>
|
||||
|
||||
<dl class="landing__proof" aria-label="What the plan is built on">
|
||||
<div>
|
||||
<dt>Latest reading</dt>
|
||||
<dd>
|
||||
{{ latestReading }} <span>est. devices/hour</span>
|
||||
<small>{{ activeSensor?.name ?? 'Stadtgalerie' }} · last point {{ lastMeasured }}</small>
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Modelled peak</dt>
|
||||
<dd>
|
||||
{{ peakHour ? formatNumber(peakHour.footfall) : '—' }} <span>est. devices/hour</span>
|
||||
<small>{{ peakHour ? `${formatWeekday(berlinParts(peakHour.t).date)} ${formatTime(peakHour.t)}` : 'waiting for the forecast' }}</small>
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Assumed</dt>
|
||||
<dd>
|
||||
{{ plan?.assumptions.labor_cost_eur_h ?? 16 }} <span>€/staff-hour</span>
|
||||
<small>{{ plan?.assumptions.visitors_per_staff_hour ?? 25 }} visitors/staff-h · ×{{ plan?.assumptions.safety_factor ?? 1.15 }} safety</small>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
<OnyxTable striped with-page-scrolling :table-attrs="{ style: 'min-width: 36rem' }">
|
||||
<template #head>
|
||||
<tr>
|
||||
<th scope="col">Sensor</th>
|
||||
<th scope="col">Mean</th>
|
||||
<th scope="col">P95</th>
|
||||
<th scope="col">Battery</th>
|
||||
<th scope="col">Source ID</th>
|
||||
</tr>
|
||||
|
||||
<aside class="landing__board" aria-label="Live weekly shift board">
|
||||
<div class="landing__board-head">
|
||||
<div>
|
||||
<p class="pc-label">The week, block by block</p>
|
||||
<p class="landing__board-window">{{ windowLabel }} · {{ windowTag }}</p>
|
||||
</div>
|
||||
<span class="pc-tag pc-tag--signal">Live plan</span>
|
||||
</div>
|
||||
|
||||
<template v-if="plan && daySummaries.length">
|
||||
<WeekBoard
|
||||
:days="daySummaries"
|
||||
:peak-date="peakShift?.date"
|
||||
show-pulse
|
||||
label="Live weekly shift board"
|
||||
/>
|
||||
|
||||
<div class="landing__board-receipt">
|
||||
<div>
|
||||
<span class="pc-label">Peak shift</span>
|
||||
<strong>
|
||||
<template v-if="peakShift">
|
||||
{{ peakShift.staff }} staff · {{ peakShift.start }}–{{ peakShift.end }}
|
||||
</template>
|
||||
<template v-else>—</template>
|
||||
</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span class="pc-label">Cost vs flat</span>
|
||||
<strong>{{ formatEuro(plan.summary.cost_eur) }} <span>vs {{ formatEuro(plan.summary.flat_schedule_cost_eur) }}</span></strong>
|
||||
<small>{{ formatEuro(savingEur) }} saved · {{ Math.round(savingPct) }}% lower</small>
|
||||
</div>
|
||||
<div>
|
||||
<span class="pc-label">Coverage</span>
|
||||
<strong>{{ formatPercent(plan.summary.coverage_pct, 1) }}</strong>
|
||||
<small>{{ plan.summary.understaffed_hours }} h short · {{ plan.summary.overstaffed_hours }} h over</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="landing__board-foot">
|
||||
<span>{{ totalStaffHours }} staff-hours · {{ plan.assumptions.shift_length_h }} h blocks</span>
|
||||
<NuxtLink to="/plan">Open the plan <span aria-hidden="true">→</span></NuxtLink>
|
||||
</div>
|
||||
</template>
|
||||
<tr v-for="sensor in sensors" :key="sensor.id">
|
||||
<th scope="row" style="text-align: left; font-weight: 600">
|
||||
{{ sensor.name }}
|
||||
<OnyxBadge v-if="sensor.id === sensorId" color="primary" density="compact" style="margin-left: 0.35rem">selected</OnyxBadge>
|
||||
</th>
|
||||
<td>{{ sensor.mean }}</td>
|
||||
<td>{{ sensor.p95 }}</td>
|
||||
<td>
|
||||
<OnyxBadge :color="sensor.battery === null ? 'neutral' : sensor.battery >= 60 ? 'success' : 'warning'" density="compact">
|
||||
{{ sensor.battery === null ? 'n/a' : `${sensor.battery}%` }}
|
||||
</OnyxBadge>
|
||||
</td>
|
||||
<td class="mono">{{ sensor.id }}</td>
|
||||
</tr>
|
||||
</OnyxTable>
|
||||
|
||||
<p v-if="meta" class="small muted table-note">
|
||||
Coverage {{ formatDate(meta.coverage.from) }} → {{ formatDate(meta.coverage.to) }} ·
|
||||
{{ meta.coverage.cadence_min }}-min cadence · data {{ meta.data_version }} · model {{ meta.model_version }}
|
||||
</p>
|
||||
</OnyxCard>
|
||||
<div v-else-if="status === 'error'" class="landing__board-empty" role="alert">
|
||||
<OnyxIcon :icon="iconTriangleWarning" size="18px" color="warning" />
|
||||
<p>The live plan is unavailable. Retry when the connection is back.</p>
|
||||
<OnyxButton label="Retry" mode="outline" density="compact" @click="refresh()" />
|
||||
</div>
|
||||
|
||||
<div v-if="!sensors?.length" class="callout callout--warning">
|
||||
<OnyxIcon :icon="iconTriangleWarning" size="16px" color="warning" />
|
||||
Sensor data is missing. Check that the Go API is running and that NUXT_API_INTERNAL_BASE points to it.
|
||||
</div>
|
||||
<div v-else class="landing__board-empty" aria-busy="true">
|
||||
<div class="pc-skeleton" style="width: 100%; height: 9rem" />
|
||||
<div class="pc-skeleton" style="width: 76%; height: 1.1rem; margin-top: 0.8rem" />
|
||||
<p class="pc-small pc-muted">Loading the current plan…</p>
|
||||
</div>
|
||||
|
||||
<div class="landing__board-note">
|
||||
<span>Live demo plan · not a city-wide claim.</span>
|
||||
<span>{{ meta?.coverage.sensors ?? 8 }} sensors · 580 m · no POS data</span>
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.landing {
|
||||
min-height: calc(100dvh - 8rem);
|
||||
justify-content: space-between;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.landing__hero {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.02fr) minmax(26rem, 0.98fr);
|
||||
gap: clamp(1.5rem, 4vw, 4rem);
|
||||
align-items: stretch;
|
||||
padding-block: clamp(0.5rem, 2vw, 1.5rem);
|
||||
}
|
||||
|
||||
.landing__copy {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 1.1rem;
|
||||
}
|
||||
|
||||
.landing__meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.55rem;
|
||||
}
|
||||
|
||||
.landing__title {
|
||||
max-width: 10ch;
|
||||
margin: 0;
|
||||
font-size: clamp(3.6rem, 7.1vw, 6.7rem);
|
||||
font-stretch: 76%;
|
||||
font-weight: 850;
|
||||
line-height: 0.84;
|
||||
letter-spacing: -0.04em;
|
||||
text-wrap: balance;
|
||||
}
|
||||
|
||||
.landing__lede {
|
||||
max-width: 48ch;
|
||||
margin: 0;
|
||||
color: var(--pc-ink-2);
|
||||
font-size: clamp(1.05rem, 1.35vw, 1.22rem);
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.landing__lede strong {
|
||||
font-weight: 780;
|
||||
}
|
||||
|
||||
.landing__actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.landing__chain {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.35rem;
|
||||
margin: 0;
|
||||
padding: 0.65rem 0;
|
||||
border-block: 1px solid var(--pc-line);
|
||||
list-style: none;
|
||||
counter-reset: none;
|
||||
}
|
||||
|
||||
.landing__chain li {
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 0.3rem;
|
||||
color: var(--pc-muted);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.landing__chain li + li::before {
|
||||
content: "→";
|
||||
margin-inline-end: 0.2rem;
|
||||
color: var(--pc-signal-text);
|
||||
}
|
||||
|
||||
.landing__chain li span {
|
||||
color: var(--pc-ink);
|
||||
font-weight: 750;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.landing__chain li span::after {
|
||||
content: "";
|
||||
}
|
||||
|
||||
.landing__proof {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 0;
|
||||
margin: 0;
|
||||
border-top: 2px solid var(--pc-ink);
|
||||
}
|
||||
|
||||
.landing__proof > div {
|
||||
min-width: 0;
|
||||
padding: 0.7rem 0.75rem 0;
|
||||
border-inline-end: 1px solid var(--pc-line);
|
||||
}
|
||||
|
||||
.landing__proof > div:first-child {
|
||||
padding-inline-start: 0;
|
||||
}
|
||||
|
||||
.landing__proof > div:last-child {
|
||||
border-inline-end: 0;
|
||||
padding-inline-end: 0;
|
||||
}
|
||||
|
||||
.landing__proof dt {
|
||||
margin: 0;
|
||||
color: var(--pc-muted);
|
||||
font-size: 0.62rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.1em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.landing__proof dd {
|
||||
margin: 0.25rem 0 0;
|
||||
font-size: 1.35rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.02em;
|
||||
line-height: 1;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.landing__proof dd span {
|
||||
display: block;
|
||||
margin-top: 0.15rem;
|
||||
color: var(--pc-muted);
|
||||
font-size: 0.62rem;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.landing__proof dd small {
|
||||
display: block;
|
||||
margin-top: 0.35rem;
|
||||
color: var(--pc-muted);
|
||||
font-size: 0.65rem;
|
||||
font-weight: 450;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.landing__board {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-direction: column;
|
||||
border: 2px solid var(--pc-ink);
|
||||
background: var(--pc-paper);
|
||||
}
|
||||
|
||||
.landing__board-head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
padding: 0.85rem 0.85rem 0.55rem;
|
||||
}
|
||||
|
||||
.landing__board-head p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.landing__board-window {
|
||||
margin-top: 0.2rem !important;
|
||||
color: var(--pc-muted);
|
||||
font-size: 0.78rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.landing__board .pc-board {
|
||||
border-inline: 0;
|
||||
}
|
||||
|
||||
.landing__board-receipt {
|
||||
display: grid;
|
||||
grid-template-columns: 1.1fr 1.6fr 0.8fr;
|
||||
gap: 0;
|
||||
border-top: 2px solid var(--pc-ink);
|
||||
border-bottom: 1px solid var(--pc-line);
|
||||
}
|
||||
|
||||
.landing__board-receipt > div {
|
||||
min-width: 0;
|
||||
padding: 0.7rem 0.75rem;
|
||||
border-inline-end: 1px solid var(--pc-line);
|
||||
}
|
||||
|
||||
.landing__board-receipt > div:last-child {
|
||||
border-inline-end: 0;
|
||||
}
|
||||
|
||||
.landing__board-receipt .pc-label {
|
||||
display: block;
|
||||
margin-bottom: 0.25rem;
|
||||
font-size: 0.58rem;
|
||||
}
|
||||
|
||||
.landing__board-receipt strong {
|
||||
display: block;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 800;
|
||||
line-height: 1.2;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.landing__board-receipt strong span {
|
||||
color: var(--pc-muted);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.landing__board-receipt small {
|
||||
display: block;
|
||||
margin-top: 0.2rem;
|
||||
color: var(--pc-muted);
|
||||
font-size: 0.62rem;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.landing__board-foot {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
padding: 0.55rem 0.85rem;
|
||||
color: var(--pc-muted);
|
||||
font-size: 0.68rem;
|
||||
}
|
||||
|
||||
.landing__board-foot a {
|
||||
color: var(--pc-ink);
|
||||
font-weight: 750;
|
||||
text-decoration-color: var(--pc-signal-text);
|
||||
}
|
||||
|
||||
.landing__board-note {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
gap: 0.35rem;
|
||||
margin-top: auto;
|
||||
padding: 0.45rem 0.85rem;
|
||||
border-top: 1px solid var(--pc-line);
|
||||
color: var(--pc-muted);
|
||||
font-size: 0.6rem;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.landing__board-empty {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
min-height: 16rem;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 0.6rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.landing__board-empty p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.landing__hero {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.2rem;
|
||||
}
|
||||
|
||||
.landing__copy {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.landing__meta {
|
||||
order: 1;
|
||||
}
|
||||
|
||||
.landing__title {
|
||||
order: 2;
|
||||
max-width: 14ch;
|
||||
}
|
||||
|
||||
.landing__lede {
|
||||
order: 3;
|
||||
}
|
||||
|
||||
.landing__actions {
|
||||
order: 4;
|
||||
}
|
||||
|
||||
.landing__board {
|
||||
order: 5;
|
||||
max-width: 46rem;
|
||||
}
|
||||
|
||||
.landing__chain {
|
||||
order: 6;
|
||||
}
|
||||
|
||||
.landing__proof {
|
||||
order: 7;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.landing {
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.landing__title {
|
||||
max-width: 11ch;
|
||||
font-size: clamp(3rem, 14vw, 4rem);
|
||||
}
|
||||
|
||||
.landing__proof {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.landing__proof > div {
|
||||
display: grid;
|
||||
grid-template-columns: 7rem minmax(0, 1fr);
|
||||
gap: 0.4rem;
|
||||
padding: 0.55rem 0;
|
||||
border-inline-end: 0;
|
||||
border-bottom: 1px solid var(--pc-line);
|
||||
}
|
||||
|
||||
.landing__proof > div:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.landing__proof dd {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.landing__proof dd small {
|
||||
margin-top: 0.15rem;
|
||||
}
|
||||
|
||||
.landing__board-receipt {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.landing__board-receipt > div {
|
||||
border-inline-end: 0;
|
||||
border-bottom: 1px solid var(--pc-line);
|
||||
}
|
||||
|
||||
.landing__board-receipt > div:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+415
-234
@@ -1,17 +1,28 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
iconArrowRight,
|
||||
iconCircleInformation,
|
||||
iconMobileSignal,
|
||||
iconSync,
|
||||
iconTriangleWarning,
|
||||
iconUserGroup,
|
||||
} from '@sit-onyx/icons'
|
||||
import { iconSync, iconTriangleWarning } from '@sit-onyx/icons'
|
||||
import { addDays, berlinParts, planWeekStart } from '#shared/staffing'
|
||||
import { scenarioLabel } from '#shared/live'
|
||||
import type { ScenarioState, Sensor, Shift, StaffingResponse } from '#shared/types'
|
||||
import { formatDateTime, formatEuro, formatNumber, formatPercent, formatShortDate, formatWeekday } from '~/utils/format'
|
||||
import type { ScenarioState, Sensor, StaffingResponse } from '#shared/types'
|
||||
import {
|
||||
formatDateTime,
|
||||
formatEuro,
|
||||
formatNumber,
|
||||
formatPercent,
|
||||
formatShortDate,
|
||||
formatTime,
|
||||
formatWeekday,
|
||||
weekLabel,
|
||||
} from '~/utils/format'
|
||||
import {
|
||||
peakHourOf,
|
||||
peakShiftOf,
|
||||
planDays,
|
||||
savingOf,
|
||||
totalStaffHoursOf,
|
||||
} from '~/utils/plan'
|
||||
|
||||
useHead({ title: 'Live recommendation — PulseCast' })
|
||||
const config = useRuntimeConfig()
|
||||
const demoNow = String(config.public.demoNow)
|
||||
|
||||
const { data: sensors } = await useFetch<Sensor[]>('/api/sensors')
|
||||
const { data: initialScenario } = await useFetch<ScenarioState>('/api/scenario')
|
||||
@@ -25,7 +36,6 @@ const live = useLiveScenario(initialScenario.value)
|
||||
|
||||
const {
|
||||
data: planData,
|
||||
status: planStatus,
|
||||
error: planError,
|
||||
refresh: refreshPlan,
|
||||
} = await useFetch<StaffingResponse>('/api/staffing', {
|
||||
@@ -36,7 +46,6 @@ const {
|
||||
})),
|
||||
})
|
||||
|
||||
// Same scenario id with a new version: refresh because the query string does not move.
|
||||
let lastScenarioId = live.scenarioId
|
||||
watch(
|
||||
() => live.revision,
|
||||
@@ -48,278 +57,450 @@ watch(
|
||||
|
||||
const plan = computed(() => planData.value ?? null)
|
||||
const activeSensor = computed(() => sensors.value?.find((sensor) => sensor.id === sensorId.value))
|
||||
const peakShift = computed(() => peakShiftOf(plan.value))
|
||||
const peakHour = computed(() => peakHourOf(plan.value))
|
||||
const totalStaffHours = computed(() => totalStaffHoursOf(plan.value))
|
||||
const savingEur = computed(() => savingOf(plan.value))
|
||||
const savingPct = computed(() => savingPctOf(plan.value))
|
||||
const daySummaries = computed(() => planDays(plan.value))
|
||||
|
||||
function maxOf<T>(items: T[], score: (item: T) => number): T | undefined {
|
||||
let best: T | undefined
|
||||
for (const item of items) if (!best || score(item) > score(best)) best = item
|
||||
return best
|
||||
}
|
||||
const weekStart = computed(() => {
|
||||
const first = plan.value?.hours[0]
|
||||
return first ? berlinParts(first.t).date : planWeekStart(demoNow)
|
||||
})
|
||||
const weekEnd = computed(() => addDays(weekStart.value, 6))
|
||||
const today = computed(() => berlinParts(demoNow).date)
|
||||
const windowTag = computed(() => {
|
||||
if (!plan.value) return 'No plan'
|
||||
return weekStart.value <= today.value && today.value <= weekEnd.value ? 'Today–Friday' : 'Seven days'
|
||||
})
|
||||
const windowLabel = computed(() => (plan.value ? weekLabel(weekStart.value, weekEnd.value) : 'Window unavailable'))
|
||||
|
||||
const peakShift = computed<Shift | undefined>(() =>
|
||||
plan.value ? maxOf(plan.value.shifts, (shift) => shift.staff) : undefined,
|
||||
const freshness = computed(() => live.lastEventAt || live.scenarioAt || plan.value?.context_version || '')
|
||||
const scenarioName = computed(() => scenarioLabel(live.scenarioId))
|
||||
const reason = computed(() => {
|
||||
if (peakHour.value) {
|
||||
return `Peak forecast ${formatNumber(peakHour.value.footfall)} est. devices/hour at ${formatTime(peakHour.value.t)}.`
|
||||
}
|
||||
return plan.value?.why[0] ?? 'Waiting for the forecast.'
|
||||
})
|
||||
|
||||
const changed = ref(false)
|
||||
let changedTimer: ReturnType<typeof setTimeout> | undefined
|
||||
let mounted = false
|
||||
watch(
|
||||
() => live.revision,
|
||||
() => {
|
||||
if (!mounted) return
|
||||
changed.value = true
|
||||
if (changedTimer) clearTimeout(changedTimer)
|
||||
changedTimer = setTimeout(() => {
|
||||
changed.value = false
|
||||
}, 8000)
|
||||
},
|
||||
)
|
||||
const peakStaff = computed(() => peakShift.value?.staff ?? 0)
|
||||
const totalStaffHours = computed(() =>
|
||||
plan.value ? plan.value.hours.reduce((sum, hour) => sum + hour.scheduled_staff, 0) : 0,
|
||||
)
|
||||
const currentReason = computed(() => plan.value?.why[0] ?? '')
|
||||
const lastUpdate = computed(() => {
|
||||
if (live.scenarioAt) return live.scenarioAt
|
||||
return plan.value?.context_version ?? ''
|
||||
|
||||
onMounted(() => {
|
||||
mounted = true
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
if (changedTimer) clearTimeout(changedTimer)
|
||||
})
|
||||
|
||||
useHead({
|
||||
title: 'Live plan — PulseCast',
|
||||
meta: [{ name: 'theme-color', content: '#0e100e' }],
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="page page-stack live-page">
|
||||
<header class="live-header">
|
||||
<div>
|
||||
<p class="eyebrow">Live · no login</p>
|
||||
<OnyxHeadline is="h1">The plan on your phone.</OnyxHeadline>
|
||||
<p class="lede">
|
||||
{{ activeSensor?.name ?? 'Stadtgalerie' }} · {{ scenarioLabel(live.scenarioId) }}. Updates arrive over SSE;
|
||||
if the stream drops, this page polls every 5 seconds.
|
||||
</p>
|
||||
</div>
|
||||
<div class="live-header__status">
|
||||
<LiveStatusBadge :status="live.status" :last-event-at="live.lastEventAt" />
|
||||
<OnyxBadge color="neutral" density="compact">v{{ live.version || '—' }}</OnyxBadge>
|
||||
</div>
|
||||
<div class="pc-dark live">
|
||||
<header class="live__top">
|
||||
<NuxtLink to="/" class="live__wordmark">
|
||||
<span class="live__mark" aria-hidden="true" />
|
||||
PulseCast
|
||||
</NuxtLink>
|
||||
<span class="live__top-status">
|
||||
<LiveStatusBadge :status="live.status" :last-event-at="live.lastEventAt" dark />
|
||||
</span>
|
||||
</header>
|
||||
|
||||
<div v-if="planError" class="callout callout--warning" role="alert">
|
||||
<OnyxIcon :icon="iconTriangleWarning" size="18px" color="warning" />
|
||||
<div>
|
||||
<strong>The live plan is unavailable.</strong>
|
||||
<span class="muted"> {{ planError.statusMessage ?? 'The API did not answer.' }}</span>
|
||||
<main class="live__main">
|
||||
<div v-if="planError" class="pc-alert pc-alert--dark live__alert" role="alert">
|
||||
<OnyxIcon :icon="iconTriangleWarning" size="18px" color="warning" />
|
||||
<span>The live plan is unavailable. Retry, or keep the last known plan on screen.</span>
|
||||
<OnyxButton label="Retry" mode="outline" density="compact" :icon="iconSync" @click="refreshPlan()" />
|
||||
</div>
|
||||
<OnyxButton label="Retry" mode="outline" density="compact" :icon="iconSync" @click="refreshPlan()" />
|
||||
</div>
|
||||
|
||||
<div v-else-if="planStatus === 'pending' && !plan" class="callout">
|
||||
<OnyxIcon :icon="iconSync" size="18px" color="primary" />
|
||||
<span>Loading the current recommendation…</span>
|
||||
</div>
|
||||
<section class="live__hero" aria-labelledby="live-title">
|
||||
<div class="live__hero-top">
|
||||
<span class="pc-tag pc-tag--dark">{{ windowTag }}</span>
|
||||
<span v-if="changed" class="pc-tag pc-tag--signal" role="status">Plan updated</span>
|
||||
</div>
|
||||
|
||||
<div v-else-if="plan && !plan.shifts.length" class="callout callout--warning" role="status">
|
||||
<OnyxIcon :icon="iconTriangleWarning" size="18px" color="warning" />
|
||||
<span>No shift blocks are available yet. The presenter may still be preparing the plan.</span>
|
||||
</div>
|
||||
<p class="live__day">
|
||||
<template v-if="peakShift">
|
||||
{{ formatWeekday(peakShift.date) }} {{ formatShortDate(peakShift.date) }} · peak shift
|
||||
</template>
|
||||
<template v-else>Waiting for the plan</template>
|
||||
</p>
|
||||
|
||||
<section class="live-hero" aria-labelledby="live-decision">
|
||||
<p class="live-hero__kicker"><OnyxIcon :icon="iconUserGroup" size="18px" color="primary" /> Current recommendation</p>
|
||||
<p id="live-decision" class="live-hero__value">
|
||||
<template v-if="plan">{{ peakStaff }} staff</template>
|
||||
<template v-else>No plan yet</template>
|
||||
<h1 id="live-title" class="live__number">
|
||||
<template v-if="peakShift">{{ peakShift.staff }}<span class="live__unit">staff</span></template>
|
||||
<template v-else><span class="live__number-empty">No plan</span></template>
|
||||
</h1>
|
||||
|
||||
<p class="live__shift">
|
||||
<template v-if="peakShift">{{ peakShift.start }}–{{ peakShift.end }}</template>
|
||||
<template v-else>The next shift appears here.</template>
|
||||
</p>
|
||||
|
||||
<p class="live__reason">{{ reason }}</p>
|
||||
|
||||
<p class="live__fresh">
|
||||
<span>{{ freshness ? `Updated ${formatDateTime(freshness)}` : 'Waiting for the live stream' }}</span>
|
||||
<span>v{{ live.version || '—' }}</span>
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<section class="live__board" aria-labelledby="live-week-title">
|
||||
<div class="live__section-head">
|
||||
<h2 id="live-week-title" class="pc-label">The week</h2>
|
||||
<span>{{ windowLabel }} · {{ windowTag }}</span>
|
||||
</div>
|
||||
<WeekBoard
|
||||
v-if="daySummaries.length"
|
||||
:days="daySummaries"
|
||||
:peak-date="peakShift?.date"
|
||||
dense
|
||||
dark
|
||||
label="The week at a glance"
|
||||
/>
|
||||
<div v-else class="pc-skeleton pc-skeleton--dark" style="height: 7rem" aria-busy="true" />
|
||||
</section>
|
||||
|
||||
<section class="live__receipt" aria-label="Plan cost and coverage">
|
||||
<div>
|
||||
<span class="pc-label">Staff-hours</span>
|
||||
<strong>{{ plan ? totalStaffHours : '—' }}</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span class="pc-label">Planned cost</span>
|
||||
<strong>{{ plan ? formatEuro(plan.summary.cost_eur) : '—' }}</strong>
|
||||
<small v-if="plan">vs {{ formatEuro(plan.summary.flat_schedule_cost_eur) }} flat · {{ formatEuro(savingEur) }} saved</small>
|
||||
<small v-else>Waiting for the plan</small>
|
||||
</div>
|
||||
<div>
|
||||
<span class="pc-label">Coverage</span>
|
||||
<strong>{{ plan ? formatPercent(plan.summary.coverage_pct, 1) : '—' }}</strong>
|
||||
<small v-if="plan">{{ plan.summary.understaffed_hours }} h short · {{ plan.summary.overstaffed_hours }} h over</small>
|
||||
<small v-else>Waiting for the plan</small>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="live__context" aria-label="Live context">
|
||||
<div><span>Scenario</span><strong>{{ scenarioName }}</strong></div>
|
||||
<div>
|
||||
<span>Transport</span>
|
||||
<strong>{{ live.statusLabel }}<template v-if="live.status === 'polling'"> · 5 s</template></strong>
|
||||
</div>
|
||||
<div><span>Updated</span><strong>{{ freshness ? formatDateTime(freshness) : '—' }}</strong></div>
|
||||
</section>
|
||||
|
||||
<NuxtLink class="pc-link-button pc-link-button--primary live__cta" to="/plan">
|
||||
Open the full plan <span aria-hidden="true">→</span>
|
||||
</NuxtLink>
|
||||
|
||||
<p class="live__note">
|
||||
Estimated devices, not people. {{ plan?.assumptions.visitors_per_staff_hour ?? 25 }} visitors/staff-hour ·
|
||||
×{{ plan?.assumptions.safety_factor ?? 1.15 }} safety · €{{ plan?.assumptions.labor_cost_eur_h ?? 16 }}/h.
|
||||
No login. If the stream drops, this page polls every five seconds.
|
||||
</p>
|
||||
<p class="live-hero__shift">
|
||||
<template v-if="peakShift">
|
||||
<strong>{{ formatWeekday(peakShift.date) }} {{ formatShortDate(peakShift.date) }}</strong><br />
|
||||
{{ peakShift.start }}–{{ peakShift.end }} · peak shift
|
||||
</template>
|
||||
<template v-else>Waiting for the peak shift</template>
|
||||
</p>
|
||||
<p v-if="currentReason" class="live-hero__why">
|
||||
<OnyxIcon :icon="iconCircleInformation" size="16px" color="primary" />
|
||||
<span>{{ currentReason }}</span>
|
||||
</p>
|
||||
<OnyxButton
|
||||
label="Open the full plan"
|
||||
:link="`/plan?scenario=${live.scenarioId}`"
|
||||
color="primary"
|
||||
:icon="iconArrowRight"
|
||||
icon-position="right"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section class="live-metrics" aria-label="Plan at a glance">
|
||||
<div class="live-metric">
|
||||
<p class="live-metric__label">Staff-hours</p>
|
||||
<p class="live-metric__value">{{ plan ? formatNumber(totalStaffHours) : '—' }}</p>
|
||||
</div>
|
||||
<div class="live-metric">
|
||||
<p class="live-metric__label">Labour cost</p>
|
||||
<p class="live-metric__value">{{ plan ? formatEuro(plan.summary.cost_eur) : '—' }}</p>
|
||||
</div>
|
||||
<div class="live-metric">
|
||||
<p class="live-metric__label">Coverage</p>
|
||||
<p class="live-metric__value">{{ plan ? formatPercent(plan.summary.coverage_pct, 1) : '—' }}</p>
|
||||
</div>
|
||||
<div class="live-metric">
|
||||
<p class="live-metric__label">Understaffed</p>
|
||||
<p class="live-metric__value">{{ plan ? `${plan.summary.understaffed_hours} h` : '—' }}</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="live-status-card">
|
||||
<div class="live-status-card__row">
|
||||
<span class="live-status-card__label">Scenario</span>
|
||||
<strong>{{ scenarioLabel(live.scenarioId) }}</strong>
|
||||
</div>
|
||||
<div class="live-status-card__row">
|
||||
<span class="live-status-card__label">Version</span>
|
||||
<span>{{ live.version || '—' }}</span>
|
||||
</div>
|
||||
<div class="live-status-card__row">
|
||||
<span class="live-status-card__label">Last update</span>
|
||||
<span>{{ lastUpdate ? formatDateTime(lastUpdate) : '—' }}</span>
|
||||
</div>
|
||||
<div class="live-status-card__row">
|
||||
<span class="live-status-card__label">Transport</span>
|
||||
<span>{{ live.statusLabel }}<template v-if="live.status === 'polling'"> · 5 s</template></span>
|
||||
</div>
|
||||
<p v-if="live.error" class="small muted table-note">{{ live.error }}</p>
|
||||
</section>
|
||||
|
||||
<footer class="live-footer">
|
||||
<p>
|
||||
<strong>Decision support, not an optimizer.</strong> The plan uses
|
||||
{{ plan?.assumptions.visitors_per_staff_hour ?? 25 }} visitors per staff-hour,
|
||||
×{{ plan?.assumptions.safety_factor ?? 1.15 }} safety, {{ plan?.assumptions.shift_length_h ?? 4 }} h shift
|
||||
blocks and €{{ plan?.assumptions.labor_cost_eur_h ?? 16 }}/h.
|
||||
</p>
|
||||
<p class="muted">
|
||||
Estimated devices, not people · {{ sensors?.length ?? 8 }} sensors in a 580 m cluster · no POS, sales or
|
||||
payroll data.
|
||||
</p>
|
||||
</footer>
|
||||
<p v-if="activeSensor" class="live__sensor">{{ activeSensor.name }} · {{ activeSensor.id }}</p>
|
||||
</main>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.live-page {
|
||||
max-width: 44rem;
|
||||
gap: clamp(0.85rem, 2vw, 1.25rem);
|
||||
.live {
|
||||
min-height: 100dvh;
|
||||
padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
|
||||
max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
|
||||
}
|
||||
|
||||
.live-header {
|
||||
.live__top {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--onyx-density-sm);
|
||||
gap: 0.75rem;
|
||||
width: 100%;
|
||||
max-width: 34rem;
|
||||
margin-inline: auto;
|
||||
padding-bottom: 0.7rem;
|
||||
border-bottom: 1px solid var(--pc-dark-line);
|
||||
}
|
||||
|
||||
.live-header h1 {
|
||||
.live__wordmark {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
color: var(--pc-paper);
|
||||
font-size: 0.82rem;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.02em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.live__mark {
|
||||
display: block;
|
||||
width: 0.42rem;
|
||||
height: 1.1rem;
|
||||
background: var(--pc-signal-bright);
|
||||
}
|
||||
|
||||
.live__top-status {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.live__main {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
max-width: 34rem;
|
||||
flex-direction: column;
|
||||
gap: 0.9rem;
|
||||
margin-inline: auto;
|
||||
padding-top: 0.85rem;
|
||||
}
|
||||
|
||||
.live__alert {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.live__hero {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
padding-bottom: 0.9rem;
|
||||
border-bottom: 2px solid var(--pc-paper);
|
||||
}
|
||||
|
||||
.live__hero-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.live__hero .pc-label {
|
||||
color: var(--pc-dark-muted);
|
||||
}
|
||||
|
||||
.live__day {
|
||||
margin: 0;
|
||||
color: var(--pc-dark-muted);
|
||||
font-size: 0.8rem;
|
||||
font-weight: 750;
|
||||
letter-spacing: 0.09em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.live-header__status {
|
||||
.live__number {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 0.45rem;
|
||||
margin: 0;
|
||||
color: var(--pc-signal-bright);
|
||||
font-size: clamp(7.5rem, 38vw, 12rem);
|
||||
font-stretch: 74%;
|
||||
font-weight: 850;
|
||||
line-height: 0.78;
|
||||
letter-spacing: -0.04em;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.live__unit {
|
||||
color: var(--pc-paper);
|
||||
font-size: clamp(1rem, 4.2vw, 1.35rem);
|
||||
font-stretch: 100%;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.live__number-empty {
|
||||
color: var(--pc-paper);
|
||||
font-size: clamp(2rem, 9vw, 3rem);
|
||||
font-stretch: 100%;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.live__shift {
|
||||
margin: 0.5rem 0 0;
|
||||
color: var(--pc-paper);
|
||||
font-size: clamp(1.8rem, 8.5vw, 2.6rem);
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.03em;
|
||||
line-height: 1;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.live__reason {
|
||||
max-width: 34ch;
|
||||
margin: 0.6rem 0 0;
|
||||
color: var(--pc-dark-muted);
|
||||
font-size: 0.86rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.live__fresh {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--onyx-density-xs);
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.4rem;
|
||||
margin: 0.8rem 0 0;
|
||||
color: var(--pc-dark-muted);
|
||||
font-size: 0.7rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
|
||||
.live-hero {
|
||||
padding: clamp(1.1rem, 3vw, 1.75rem);
|
||||
border: 1px solid var(--onyx-color-base-primary-300);
|
||||
border-radius: var(--onyx-radius-component-container-soft);
|
||||
background:
|
||||
radial-gradient(circle at 100% 0%, var(--onyx-color-base-primary-200), transparent 48%),
|
||||
linear-gradient(135deg, var(--onyx-color-base-primary-100), var(--onyx-color-base-neutral-100) 72%);
|
||||
.live__fresh span:last-child {
|
||||
color: var(--pc-paper);
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.live-hero__kicker {
|
||||
.live__board {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.live__section-head {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 0.35rem;
|
||||
margin: 0;
|
||||
color: var(--onyx-color-text-icons-neutral-medium);
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: var(--pc-dark-muted);
|
||||
font-size: 0.68rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.live__section-head .pc-label {
|
||||
color: var(--pc-dark-muted);
|
||||
}
|
||||
|
||||
.live__receipt {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
border-block: 1px solid var(--pc-dark-line);
|
||||
}
|
||||
|
||||
.live__receipt > div {
|
||||
min-width: 0;
|
||||
padding: 0.55rem 0.5rem;
|
||||
border-inline-end: 1px solid var(--pc-dark-line);
|
||||
}
|
||||
|
||||
.live__receipt > div:first-child {
|
||||
padding-inline-start: 0;
|
||||
}
|
||||
|
||||
.live__receipt > div:last-child {
|
||||
border-inline-end: 0;
|
||||
padding-inline-end: 0;
|
||||
}
|
||||
|
||||
.live__receipt .pc-label {
|
||||
display: block;
|
||||
color: var(--pc-dark-muted);
|
||||
font-size: 0.58rem;
|
||||
}
|
||||
|
||||
.live__receipt strong {
|
||||
display: block;
|
||||
margin-top: 0.25rem;
|
||||
color: var(--pc-paper);
|
||||
font-size: clamp(1.15rem, 5vw, 1.5rem);
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.02em;
|
||||
line-height: 1;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.live__receipt small {
|
||||
display: block;
|
||||
margin-top: 0.25rem;
|
||||
color: var(--pc-dark-muted);
|
||||
font-size: 0.58rem;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.live__context {
|
||||
display: grid;
|
||||
gap: 0.15rem;
|
||||
padding-block: 0.55rem;
|
||||
border-bottom: 1px solid var(--pc-dark-line);
|
||||
}
|
||||
|
||||
.live__context > div {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
padding-block: 0.22rem;
|
||||
}
|
||||
|
||||
.live__context span {
|
||||
color: var(--pc-dark-muted);
|
||||
font-size: 0.68rem;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.live-hero__value {
|
||||
margin: var(--onyx-density-xs) 0 0;
|
||||
font-size: clamp(3rem, 16vw, 5.5rem);
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.04em;
|
||||
line-height: 0.95;
|
||||
color: var(--onyx-color-text-icons-primary-intense);
|
||||
.live__context strong {
|
||||
color: var(--pc-paper);
|
||||
font-size: 0.76rem;
|
||||
font-weight: 650;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.live-hero__shift {
|
||||
margin: var(--onyx-density-sm) 0 0;
|
||||
font-size: clamp(1rem, 3.5vw, 1.25rem);
|
||||
line-height: 1.4;
|
||||
.live__cta {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.live-hero__why {
|
||||
display: flex;
|
||||
gap: var(--onyx-density-xs);
|
||||
align-items: flex-start;
|
||||
margin: var(--onyx-density-md) 0;
|
||||
color: var(--onyx-color-text-icons-neutral-medium);
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.live-metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: var(--onyx-density-sm);
|
||||
}
|
||||
|
||||
.live-metric {
|
||||
min-width: 0;
|
||||
padding: var(--onyx-density-md);
|
||||
border: 1px solid var(--onyx-color-base-neutral-300);
|
||||
border-radius: var(--onyx-radius-component-container-soft);
|
||||
background: var(--onyx-color-base-neutral-100);
|
||||
}
|
||||
|
||||
.live-metric__label {
|
||||
.live__note {
|
||||
margin: 0;
|
||||
color: var(--onyx-color-text-icons-neutral-medium);
|
||||
font-size: 0.78rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.live-metric__value {
|
||||
margin: var(--onyx-density-xs) 0 0;
|
||||
font-size: clamp(1.35rem, 6vw, 1.9rem);
|
||||
font-weight: 700;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
.live-status-card {
|
||||
display: grid;
|
||||
gap: var(--onyx-density-xs);
|
||||
padding: var(--onyx-density-md);
|
||||
border: 1px solid var(--onyx-color-base-neutral-300);
|
||||
border-radius: var(--onyx-radius-component-container-soft);
|
||||
background: var(--onyx-color-base-neutral-100);
|
||||
}
|
||||
|
||||
.live-status-card__row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: var(--onyx-density-sm);
|
||||
}
|
||||
|
||||
.live-status-card__label {
|
||||
color: var(--onyx-color-text-icons-neutral-medium);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.live-footer {
|
||||
padding-top: var(--onyx-density-sm);
|
||||
border-top: 1px solid var(--onyx-color-base-neutral-300);
|
||||
color: var(--onyx-color-text-icons-neutral-medium);
|
||||
font-size: 0.75rem;
|
||||
color: var(--pc-dark-muted);
|
||||
font-size: 0.68rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.live-footer p {
|
||||
margin: 0 0 var(--onyx-density-xs);
|
||||
.live__sensor {
|
||||
margin: 0;
|
||||
color: var(--pc-dark-muted);
|
||||
font-family: var(--pc-font);
|
||||
font-size: 0.6rem;
|
||||
letter-spacing: 0.03em;
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
@media (min-width: 577px) {
|
||||
.live-metrics {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
@media (min-width: 700px) {
|
||||
.live {
|
||||
padding-block: 2rem;
|
||||
}
|
||||
|
||||
.live__top,
|
||||
.live__main {
|
||||
max-width: 36rem;
|
||||
}
|
||||
|
||||
.live__main {
|
||||
gap: 1.1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
+651
-433
File diff suppressed because it is too large.
Load diff
+534
-417
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user