Implement Option 1: Synchronized Swimlanes with Time Anchor

This commit is contained in:
2026-07-28 14:21:15 +05:30
parent 0def7a5b68
commit c921e0ddef
+88 -42
View File
@@ -47,42 +47,30 @@ export default function EventTimeline() {
return <span className="badge">{state}</span>; return <span className="badge">{state}</span>;
}; };
const groupedEvents = useMemo(() => { const chronologicalBlocks = useMemo(() => {
return { const blocks = {};
CO: events.filter(e => e.camera_zone === 'CO'), events.forEach(ev => {
Mill: events.filter(e => e.camera_zone === 'Mill'), // Group by Minute (HH:MM)
Conveyor: events.filter(e => e.camera_zone === 'Conveyor') const timeKey = ev.start_time.substring(0, 5);
}; if (!blocks[timeKey]) {
blocks[timeKey] = { timeKey, CO: [], Mill: [], Conveyor: [] };
}
if (ev.camera_zone === 'CO') blocks[timeKey].CO.push(ev);
if (ev.camera_zone === 'Mill') blocks[timeKey].Mill.push(ev);
if (ev.camera_zone === 'Conveyor') blocks[timeKey].Conveyor.push(ev);
});
// Sort chronologically
return Object.values(blocks).sort((a, b) => a.timeKey.localeCompare(b.timeKey));
}, [events]); }, [events]);
const renderTimeline = (zone, zoneEvents, index) => ( const renderEventCard = (ev, i, arrLength) => (
<div style={{ <div key={ev.id} style={{
flex: 1, display: 'flex', flexDirection: 'column',
overflowY: 'auto', paddingBottom: i < arrLength - 1 ? '1rem' : '0',
maxHeight: '70vh', marginBottom: i < arrLength - 1 ? '1rem' : '0',
paddingLeft: index === 0 ? '0' : '1.5rem', borderBottom: i < arrLength - 1 ? '1px solid rgba(255,255,255,0.05)' : 'none'
paddingRight: index === 2 ? '0' : '1.5rem',
borderRight: index === 2 ? 'none' : '1px solid rgba(255,255,255,0.05)'
}}> }}>
<h2 style={{
position: 'sticky',
top: 0,
background: 'var(--panel-bg)',
backdropFilter: 'blur(16px)',
WebkitBackdropFilter: 'blur(16px)',
paddingBottom: '1rem',
paddingTop: '0.5rem',
borderBottom: '1px solid var(--panel-border)',
zIndex: 10
}}>
{zone} Timeline
</h2>
<div style={{ marginTop: '1rem' }}>
{zoneEvents.length === 0 ? (
<p style={{ opacity: 0.5, textAlign: 'center' }}>No events recorded.</p>
) : (
zoneEvents.map((ev, i) => (
<div key={ev.id} style={{ display: 'flex', flexDirection: 'column', padding: '1rem 0', borderBottom: i < zoneEvents.length -1 ? '1px dashed rgba(255,255,255,0.1)' : 'none' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '0.5rem' }}> <div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: '0.5rem' }}>
<span style={{ fontSize: '0.85rem', color: 'var(--text-secondary)' }}> <span style={{ fontSize: '0.85rem', color: 'var(--text-secondary)' }}>
{ev.start_time.substring(0, 5)} - {ev.end_time.substring(0, 5)} {ev.start_time.substring(0, 5)} - {ev.end_time.substring(0, 5)}
@@ -116,10 +104,6 @@ export default function EventTimeline() {
</div> </div>
</div> </div>
</div> </div>
))
)}
</div>
</div>
); );
if (loading) { if (loading) {
@@ -137,13 +121,75 @@ export default function EventTimeline() {
<ArrowLeft size={16} /> Back to Changeover Analytics <ArrowLeft size={16} /> Back to Changeover Analytics
</Link> </Link>
<h1>Event Timeline: {id}</h1> <h1>Event Timeline: {id}</h1>
<p>Location-wise sequential breakdown of events</p> <p>Synchronized Swimlane Timeline</p>
</div>
<div className="glass-panel" style={{ display: 'flex', flexDirection: 'column', padding: 0, overflow: 'hidden' }}>
{/* Sticky Header Grid */}
<div style={{
display: 'grid',
gridTemplateColumns: '80px 1fr 1fr 1fr',
gap: '1.5rem',
padding: '1.5rem 1.5rem 1rem 1.5rem',
background: 'var(--panel-bg)',
backdropFilter: 'blur(16px)',
WebkitBackdropFilter: 'blur(16px)',
borderBottom: '1px solid var(--panel-border)',
position: 'sticky',
top: 0,
zIndex: 10
}}>
<h2 style={{ margin: 0, fontSize: '1rem', color: 'var(--text-secondary)' }}>Time</h2>
<h2 style={{ margin: 0, fontSize: '1.1rem' }}>CO Timeline</h2>
<h2 style={{ margin: 0, fontSize: '1.1rem' }}>Mill Timeline</h2>
<h2 style={{ margin: 0, fontSize: '1.1rem' }}>Conveyor Timeline</h2>
</div>
{/* Scrollable Timeline Tracks Container */}
<div style={{ overflowY: 'auto', maxHeight: '65vh', padding: '0 1.5rem' }}>
{chronologicalBlocks.length === 0 ? (
<p style={{ padding: '2rem', textAlign: 'center', opacity: 0.5 }}>No events recorded.</p>
) : (
chronologicalBlocks.map((block, index) => (
<div key={block.timeKey} style={{
display: 'grid',
gridTemplateColumns: '80px 1fr 1fr 1fr',
gap: '1.5rem',
borderBottom: index < chronologicalBlocks.length - 1 ? '1px dashed rgba(255,255,255,0.1)' : 'none',
padding: '1.5rem 0'
}}>
{/* Time Anchor Left Column */}
<div style={{ position: 'relative' }}>
<div style={{
position: 'sticky',
top: '0',
fontWeight: '600',
color: 'var(--accent)',
fontSize: '1.1rem',
letterSpacing: '0.05em'
}}>
{block.timeKey}
</div>
</div>
{/* Event Columns */}
<div>
{block.CO.map((ev, i) => renderEventCard(ev, i, block.CO.length))}
</div>
<div>
{block.Mill.map((ev, i) => renderEventCard(ev, i, block.Mill.length))}
</div>
<div>
{block.Conveyor.map((ev, i) => renderEventCard(ev, i, block.Conveyor.length))}
</div>
</div>
))
)}
</div> </div>
<div className="glass-panel" style={{ display: 'flex', padding: '1.5rem', alignItems: 'stretch' }}>
{renderTimeline('CO', groupedEvents.CO, 0)}
{renderTimeline('Mill', groupedEvents.Mill, 1)}
{renderTimeline('Conveyor', groupedEvents.Conveyor, 2)}
</div> </div>
</div> </div>
); );