Improved environment UI
This commit is contained in:
1 parent
fb23836070
commit
96bc98df97
5 files changed
+121
-125
No files matched your search
@@ -191,8 +191,8 @@
|
||||
opacity="0.55" vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
<circle
|
||||
cx={scrubPt.x} cy={scrubPt.y} r="2.5"
|
||||
fill="var(--paper, #fbf7ec)" stroke={color} stroke-width="1.25"
|
||||
cx={scrubPt.x} cy={scrubPt.y} r="0.05"
|
||||
fill="var(--paper, #fbf7ec)" stroke={color} stroke-width="4"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
{/if}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
sweep = [],
|
||||
baseline = null,
|
||||
mode = 'normalized',
|
||||
size = 220,
|
||||
size = 400,
|
||||
}: Props = $props();
|
||||
|
||||
// ── Toggle state ──────────────────────────────────────────────────────
|
||||
|
||||
+6
-4
@@ -6,13 +6,15 @@ const HOUR = 3600;
|
||||
// ── Gas Sweep Helpers ───────────────────────────────────────────────────────
|
||||
const SWEEP_PROFILE = [
|
||||
{ temp: 200, dur: 100, zone: 1 as const },
|
||||
{ temp: 220, dur: 100, zone: 1 as const },
|
||||
{ temp: 250, dur: 100, zone: 1 as const },
|
||||
{ temp: 280, dur: 100, zone: 2 as const },
|
||||
{ temp: 300, dur: 100, zone: 2 as const },
|
||||
{ temp: 350, dur: 100, zone: 2 as const },
|
||||
{ temp: 320, dur: 100, zone: 2 as const },
|
||||
{ temp: 340, dur: 100, zone: 2 as const },
|
||||
{ temp: 360, dur: 100, zone: 3 as const },
|
||||
{ temp: 380, dur: 100, zone: 3 as const },
|
||||
{ temp: 400, dur: 100, zone: 3 as const },
|
||||
{ temp: 450, dur: 100, zone: 3 as const },
|
||||
{ temp: 300, dur: 100, zone: 2 as const },
|
||||
{ temp: 250, dur: 100, zone: 1 as const },
|
||||
];
|
||||
|
||||
function genSweep(baselineR: number, drift: number, anomaly = false): GasSweepPoint[] {
|
||||
|
||||
@@ -375,6 +375,7 @@ function createStore() {
|
||||
if (chamber) {
|
||||
chamber.history = readings;
|
||||
const last = readings[readings.length - 1];
|
||||
const lastRow = rows[rows.length - 1]; // raw row for baseline/burn_in
|
||||
if (last) {
|
||||
chamber.environment.temp_c = last.temp_c;
|
||||
chamber.environment.rh_pct = last.rh_pct;
|
||||
@@ -386,6 +387,20 @@ function createStore() {
|
||||
chamber.environment.voc_ppb = last.voc_ppb;
|
||||
chamber.last_update_ts = last.ts;
|
||||
}
|
||||
// Hydrate calibration state from last history row for UI on refresh
|
||||
if (lastRow) {
|
||||
chamber.burn_in = lastRow.burn_in === 1;
|
||||
chamber.baseline = {
|
||||
established: lastRow.baseline_established === 1,
|
||||
established_at: lastRow.ts ?? null,
|
||||
n_samples: lastRow.baseline_samples ?? 0,
|
||||
R: {}, // radar chart baseline unavailable until live payload
|
||||
humidity_ref: 0,
|
||||
temp_ref: 0,
|
||||
co2_ref: null,
|
||||
bme_temp_offset: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Mirror fruiting into the legacy global env for the top-bar
|
||||
|
||||
+97
-118
@@ -23,6 +23,15 @@
|
||||
const winStep: Record<Win, number> = { '1h': 1, '6h': 4, '24h': 12 };
|
||||
const winMs: Record<Win, number> = { '1h': 0, '6h': 30_000, '24h': 120_000 };
|
||||
|
||||
// ── Responsive sizing ──────────────────────────────────────────────────
|
||||
let innerWidth = $state(typeof window !== 'undefined' ? window.innerWidth : 1200);
|
||||
const radarSize = $derived(innerWidth <= 900 ? 180 : 280);
|
||||
$effect(() => {
|
||||
const onResize = () => innerWidth = window.innerWidth;
|
||||
window.addEventListener('resize', onResize);
|
||||
return () => window.removeEventListener('resize', onResize);
|
||||
});
|
||||
|
||||
// ── Chamber selection ────────────────────────────────────────────────────
|
||||
const chambers = $derived(cultivar.state.chambers);
|
||||
const visibleChambers = $derived(chambers.filter(c => c.last_update_ts !== null));
|
||||
@@ -291,35 +300,12 @@
|
||||
? (ch.environment.co2e_ppm ?? null)
|
||||
: (ch.environment.co2_ppm ?? null)}
|
||||
<div class="scard" class:scard-burn={ch.burn_in}>
|
||||
<div class="scard-head">
|
||||
<span class="live-dot" class:live={!ch.burn_in} style="--dot-color:{ch.type === 'colonization' ? '#1c251d' : '#d5c48d'}"></span>
|
||||
<span class="scard-name font-serif">{ch.label}</span>
|
||||
<span class="scard-desc">{ch.type === 'colonization' ? 'dark & still' : 'lit & humid'}</span>
|
||||
</div>
|
||||
|
||||
<div class="scard-stats">
|
||||
<div class="sstat" class:sstat-out={!inRange(ch.environment.temp_c, RANGES.temp[ch.type])}>
|
||||
<span class="sstat-val font-serif">{ch.environment.temp_c.toFixed(1)}</span>
|
||||
<span class="sstat-unit">°C</span>
|
||||
<!-- Two-row compact design -->
|
||||
<div class="scard-main">
|
||||
<div class="scard-head">
|
||||
<span class="live-dot" class:live={!ch.burn_in} style="--dot-color:{ch.type === 'colonization' ? '#1c251d' : '#d5c48d'}"></span>
|
||||
<span class="scard-name font-serif">{ch.label}</span>
|
||||
</div>
|
||||
<span class="sstat-sep">·</span>
|
||||
<div class="sstat" class:sstat-out={!inRange(ch.environment.rh_pct, RANGES.humid[ch.type])}>
|
||||
<span class="sstat-val font-serif">{ch.environment.rh_pct.toFixed(0)}</span>
|
||||
<span class="sstat-unit">%</span>
|
||||
</div>
|
||||
{#if co2val !== null}
|
||||
<span class="sstat-sep">·</span>
|
||||
<div class="sstat" class:sstat-out={!inRange(co2val, RANGES.co2[ch.type])}>
|
||||
<span class="sstat-val font-serif">{co2val.toFixed(0)}</span>
|
||||
<span class="sstat-unit">ppm {ch.type === 'colonization' ? 'CO₂e' : 'CO₂'}</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="scard-chips">
|
||||
<span class="schip" class:schip-good={vpdOk} class:schip-dim={!vpdOk}>
|
||||
VPD {vpd.toFixed(2)} kPa
|
||||
</span>
|
||||
<span class="schip schip-status"
|
||||
class:schip-good={st.cls === 'good'}
|
||||
class:schip-watch={st.cls === 'watch'}
|
||||
@@ -328,20 +314,26 @@
|
||||
<span class="schip-dot"></span>{st.label}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="scard-footer">
|
||||
{#if ch.last_update_ts}
|
||||
<span class="scard-updated">updated {formatRelative(ch.last_update_ts)}</span>
|
||||
{:else}
|
||||
<span class="scard-updated muted">waiting…</span>
|
||||
{/if}
|
||||
{#if ch.burn_in}
|
||||
{@const pct = Math.min(100, Math.round(((ch.baseline?.n_samples ?? 0) / 30) * 100))}
|
||||
<div class="burn-bar-wrap" title="Sensor conditioning progress">
|
||||
<div class="burn-bar" style="width:{pct}%"></div>
|
||||
</div>
|
||||
<div class="scard-metrics">
|
||||
<span class="sval" class:out={!inRange(ch.environment.temp_c, RANGES.temp[ch.type])}>
|
||||
{ch.environment.temp_c.toFixed(1)}°C
|
||||
</span>•
|
||||
<span class="sval" class:out={!inRange(ch.environment.rh_pct, RANGES.humid[ch.type])}>
|
||||
{ch.environment.rh_pct.toFixed(0)}%
|
||||
</span>•
|
||||
{#if co2val !== null}
|
||||
<span class="sval" class:out={!inRange(co2val, RANGES.co2[ch.type])}>
|
||||
{co2val.toFixed(0)}ppm
|
||||
</span>•
|
||||
{/if}
|
||||
<span class="sval-vpd" class:vpd-ok={vpdOk}>VPD {vpd.toFixed(2)}</span>
|
||||
</div>
|
||||
{#if ch.burn_in}
|
||||
{@const pct = Math.min(100, Math.round(((ch.baseline?.n_samples ?? 0) / 30) * 100))}
|
||||
<div class="burn-progress" title="Sensor conditioning: {pct}%">
|
||||
<div class="burn-fill" style="width:{pct}%"></div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
@@ -460,7 +452,7 @@
|
||||
<SweepRadar
|
||||
sweep={(ch.latestSweep ?? []) as GasSweepPoint[]}
|
||||
baseline={(ch.baseline ?? null) as SweepBaseline | null}
|
||||
size={180}
|
||||
size={radarSize}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -802,27 +794,35 @@
|
||||
.status-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 12px;
|
||||
gap: 10px;
|
||||
margin-left: 130px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.status-row.single { grid-template-columns: 1fr; }
|
||||
|
||||
.scard {
|
||||
background: var(--paper-warm);
|
||||
border: 1px solid var(--line-soft);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 14px 16px 12px;
|
||||
border-radius: 12px;
|
||||
padding: 12px 14px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
transition: border-color 0.2s;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
.scard-burn { opacity: 0.85; }
|
||||
.scard-burn { opacity: 0.9; }
|
||||
|
||||
/* Header row: name + status */
|
||||
.scard-main {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
.scard-head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* Live pulse dot */
|
||||
@@ -833,7 +833,6 @@
|
||||
background: var(--dot-color, var(--ink-muted));
|
||||
opacity: 0.35;
|
||||
flex-shrink: 0;
|
||||
align-self: center;
|
||||
}
|
||||
.live-dot.live {
|
||||
opacity: 1;
|
||||
@@ -850,50 +849,8 @@
|
||||
letter-spacing: -0.005em;
|
||||
font-weight: var(--fw-display);
|
||||
}
|
||||
.scard-desc {
|
||||
font-family: var(--font-serif);
|
||||
font-style: italic;
|
||||
font-size: 12px;
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
|
||||
/* Big stats row */
|
||||
.scard-stats {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.sstat { display: flex; align-items: baseline; gap: 2px; }
|
||||
.sstat-val {
|
||||
font-size: 24px;
|
||||
line-height: 1;
|
||||
letter-spacing: -0.015em;
|
||||
color: var(--ink);
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-weight: var(--fw-display);
|
||||
}
|
||||
.sstat-out .sstat-val { color: var(--attention); }
|
||||
.sstat-unit {
|
||||
font-family: var(--font-sans);
|
||||
font-size: 11px;
|
||||
color: var(--ink-muted);
|
||||
margin-left: 1px;
|
||||
}
|
||||
.sstat-sep {
|
||||
color: var(--ink-muted);
|
||||
font-size: 16px;
|
||||
align-self: center;
|
||||
padding: 0 2px;
|
||||
}
|
||||
|
||||
/* Chips row */
|
||||
.scard-chips {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
/* Status chip */
|
||||
.schip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -906,6 +863,7 @@
|
||||
background: var(--paper-2);
|
||||
color: var(--ink-muted);
|
||||
border: 1px solid transparent;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.schip-good {
|
||||
background: var(--forest-tint);
|
||||
@@ -921,39 +879,55 @@
|
||||
background: var(--paper-2);
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
.schip-dim { opacity: 0.7; }
|
||||
.schip-dot {
|
||||
width: 5px; height: 5px;
|
||||
border-radius: 50%;
|
||||
background: currentColor;
|
||||
}
|
||||
|
||||
/* Footer: last-update + burn-in bar */
|
||||
.scard-footer {
|
||||
/* Metrics row */
|
||||
.scard-metrics {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
align-items: baseline;
|
||||
gap: 12px;
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-size: 15px;
|
||||
color: var(--dot-color);
|
||||
border-bottom: 1px dashed var(--line);
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.scard-updated {
|
||||
font-family: var(--font-serif);
|
||||
font-style: italic;
|
||||
font-size: 11px;
|
||||
.sval {
|
||||
color: var(--ink-muted);
|
||||
}
|
||||
.scard-updated.muted { opacity: 0.6; }
|
||||
.burn-bar-wrap {
|
||||
flex: 1;
|
||||
height: 2px;
|
||||
background: var(--line-soft);
|
||||
border-radius: 999px;
|
||||
overflow: hidden;
|
||||
max-width: 80px;
|
||||
.sval.out { color: var(--attention); }
|
||||
.sval-vpd {
|
||||
font-size: 12px;
|
||||
color: var(--ink-muted);
|
||||
margin-left: auto;
|
||||
padding: 2px 8px;
|
||||
background: var(--paper-2);
|
||||
border-radius: 6px;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.burn-bar {
|
||||
.sval-vpd.vpd-ok {
|
||||
color: var(--forest);
|
||||
background: var(--forest-tint);
|
||||
border-color: color-mix(in srgb, var(--forest) 10%, transparent);
|
||||
}
|
||||
|
||||
/* Burn-in progress overlay */
|
||||
.burn-progress {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 3px;
|
||||
background: var(--line-soft);
|
||||
}
|
||||
.burn-fill {
|
||||
height: 100%;
|
||||
background: var(--forest);
|
||||
opacity: 0.5;
|
||||
border-radius: 999px;
|
||||
opacity: 0.6;
|
||||
transition: width 0.6s ease-out;
|
||||
}
|
||||
|
||||
@@ -1096,6 +1070,11 @@
|
||||
text-align: center;
|
||||
max-width: 280px;
|
||||
}
|
||||
@media (max-width: 900px) {
|
||||
.calibrating {
|
||||
max-width: 180px;
|
||||
}
|
||||
}
|
||||
.cal-title { font-size: 14px; color: var(--ink); letter-spacing: -0.005em; }
|
||||
.cal-body { font-size: 12.5px; line-height: 1.5; color: var(--ink-muted); margin: 0; }
|
||||
.cal-pulse { display: flex; gap: 5px; height: 8px; }
|
||||
@@ -1113,7 +1092,7 @@
|
||||
40% { opacity: 0.9; transform: scale(1.1); }
|
||||
}
|
||||
.cal-progress {
|
||||
width: 100%; max-width: 180px;
|
||||
width: 100%; max-width: 280px;
|
||||
height: 3px;
|
||||
background: var(--line-soft);
|
||||
border-radius: 999px;
|
||||
@@ -1328,7 +1307,7 @@
|
||||
}
|
||||
.metrics-wrap.single .rows.single { flex: 1; min-width: 0; }
|
||||
.metrics-wrap.single .row-radar.single {
|
||||
width: 200px;
|
||||
width: 30%;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -1361,8 +1340,9 @@
|
||||
.head-controls { gap: 6px; }
|
||||
.adv-btn { padding: 7px 11px 7px 9px; font-size: 10.5px; }
|
||||
|
||||
.status-row { grid-template-columns: 1fr; }
|
||||
.sstat-val { font-size: 20px; }
|
||||
.status-row { grid-template-columns: 1fr; margin-left: 0; }
|
||||
.scard-metrics { font-size: 14px; gap: 10px; }
|
||||
.sval-vpd { font-size: 11px; }
|
||||
|
||||
.chamber-heads, .row {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
@@ -1389,7 +1369,6 @@
|
||||
|
||||
@media (max-width: 560px) {
|
||||
.tab { padding: 7px 14px; }
|
||||
.sstat-val { font-size: 18px; }
|
||||
.cal-grid { grid-template-columns: 1fr; }
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user