-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
833 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
apps/client/src/features/viewers/timeline/Timeline.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
@use '../../../theme/viewerDefs' as *; | ||
|
||
$timeline-entry-height: 20px; | ||
$lane-height: 120px; | ||
|
||
.timeline { | ||
flex: 1; | ||
font-weight: 600; | ||
color: $ui-white; | ||
} | ||
|
||
.timelineEvents { | ||
position: relative; | ||
top: 0.5rem; | ||
height: 100%; | ||
} | ||
|
||
.column { | ||
display: flex; | ||
flex-direction: column; | ||
position: absolute; | ||
border-inline: 1px solid $ui-black; | ||
// avoiding content being larger than the view | ||
height: calc(100% - 3rem); | ||
} | ||
|
||
.content { | ||
flex: 1; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1rem; | ||
padding-top: 0.25rem; | ||
padding-inline-start: 0.25rem; | ||
overflow: hidden; | ||
|
||
background-color: var(--lighter, $viewer-card-bg-color); | ||
border-bottom: 2px solid $ui-black; | ||
box-shadow: 0 0.25rem 0 0 var(--color, $ui-white); | ||
} | ||
|
||
.delay { | ||
margin-top: -1rem; | ||
} | ||
|
||
.timeOverview { | ||
padding-top: 0.25rem; | ||
padding-inline-start: 0.25em; | ||
text-transform: capitalize; | ||
white-space: normal; | ||
height: 6rem; | ||
|
||
&[data-status='done'] { | ||
opacity: $opacity-disabled; | ||
} | ||
|
||
&[data-status='live'] { | ||
.status { | ||
color: $active-red; | ||
} | ||
} | ||
|
||
&[data-status='future'] { | ||
.status { | ||
color: $green-500; | ||
} | ||
} | ||
} | ||
|
||
.cross { | ||
text-decoration: line-through; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import { memo } from 'react'; | ||
import { useViewportSize } from '@mantine/hooks'; | ||
import { isOntimeEvent, MaybeNumber } from 'ontime-types'; | ||
import { dayInMs, getFirstEventNormal, getLastEventNormal, MILLIS_PER_HOUR } from 'ontime-utils'; | ||
|
||
import useRundown from '../../../common/hooks-query/useRundown'; | ||
|
||
import TimelineMarkers from './timeline-markers/TimelineMarkers'; | ||
import ProgressBar from './timeline-progress-bar/TimelineProgressBar'; | ||
import { getElementPosition, getEndHour, getStartHour } from './timeline.utils'; | ||
import { ProgressStatus, TimelineEntry } from './TimelineEntry'; | ||
|
||
import style from './Timeline.module.scss'; | ||
|
||
function useTimeline() { | ||
const { data } = useRundown(); | ||
if (data.revision === -1) { | ||
return null; | ||
} | ||
|
||
const { firstEvent } = getFirstEventNormal(data.rundown, data.order); | ||
const { lastEvent } = getLastEventNormal(data.rundown, data.order); | ||
const firstStart = firstEvent?.timeStart ?? 0; | ||
const lastEnd = lastEvent?.timeEnd ?? 0; | ||
const normalisedLastEnd = lastEnd < firstStart ? lastEnd + dayInMs : lastEnd; | ||
|
||
// timeline is padded to nearest hours (floor and ceil) | ||
const startHour = getStartHour(firstStart) * MILLIS_PER_HOUR; | ||
const endHour = getEndHour(normalisedLastEnd) * MILLIS_PER_HOUR; | ||
const accumulatedDelay = lastEvent?.delay ?? 0; | ||
|
||
return { | ||
rundown: data.rundown, | ||
order: data.order, | ||
startHour, | ||
endHour, | ||
accumulatedDelay, | ||
}; | ||
} | ||
|
||
interface TimelineProps { | ||
selectedEventId: string | null; | ||
} | ||
|
||
export default memo(Timeline); | ||
|
||
function Timeline(props: TimelineProps) { | ||
const { selectedEventId } = props; | ||
const { width: screenWidth } = useViewportSize(); | ||
const timelineData = useTimeline(); | ||
|
||
if (timelineData === null) { | ||
return null; | ||
} | ||
|
||
const { rundown, order, startHour, endHour, accumulatedDelay } = timelineData; | ||
|
||
let hasTimelinePassedMidnight = false; | ||
let previousEventStartTime: MaybeNumber = null; | ||
let eventStatus: ProgressStatus = 'done'; | ||
|
||
return ( | ||
<div className={style.timeline}> | ||
<TimelineMarkers /> | ||
<ProgressBar startHour={startHour} endHour={endHour + accumulatedDelay} /> | ||
<div className={style.timelineEvents}> | ||
{order.map((eventId) => { | ||
// for now we dont render delays and blocks | ||
const event = rundown[eventId]; | ||
if (!isOntimeEvent(event)) { | ||
return null; | ||
} | ||
|
||
// keep track of progress of rundown | ||
if (eventStatus === 'live') { | ||
eventStatus = 'future'; | ||
} | ||
if (eventId === selectedEventId) { | ||
eventStatus = 'live'; | ||
} | ||
|
||
// we need to offset the start to account for midnight | ||
if (!hasTimelinePassedMidnight) { | ||
hasTimelinePassedMidnight = previousEventStartTime !== null && event.timeStart < previousEventStartTime; | ||
} | ||
const normalisedStart = hasTimelinePassedMidnight ? event.timeStart + dayInMs : event.timeStart; | ||
previousEventStartTime = normalisedStart; | ||
|
||
const { left: elementLeftPosition, width: elementWidth } = getElementPosition( | ||
startHour, | ||
endHour + accumulatedDelay, | ||
normalisedStart + (event.delay ?? 0), | ||
event.duration, | ||
screenWidth, | ||
); | ||
|
||
return ( | ||
<TimelineEntry | ||
key={eventId} | ||
colour={event.colour} | ||
delay={event.delay ?? 0} | ||
duration={event.duration} | ||
left={elementLeftPosition} | ||
status={eventStatus} | ||
start={event.timeStart} | ||
title={event.title} | ||
width={elementWidth} | ||
/> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.