mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 09:15:22 +03:00
feat: added color mapping by label
This commit is contained in:
parent
36fd261394
commit
21f9e9831b
@ -9,7 +9,7 @@ export interface TimelineEvent {
|
|||||||
startTime: Date;
|
startTime: Date;
|
||||||
endTime: Date;
|
endTime: Date;
|
||||||
id: string;
|
id: string;
|
||||||
label: string;
|
label: 'car' | 'person' | 'dog';
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TimelineEventBlock extends TimelineEvent {
|
export interface TimelineEventBlock extends TimelineEvent {
|
||||||
|
|||||||
@ -9,11 +9,22 @@ interface TimelineBlockViewProps {
|
|||||||
export const TimelineBlockView = ({ block, onClick }: TimelineBlockViewProps) => {
|
export const TimelineBlockView = ({ block, onClick }: TimelineBlockViewProps) => {
|
||||||
const onClickHandler = () => onClick(block);
|
const onClickHandler = () => onClick(block);
|
||||||
|
|
||||||
|
const getColor = (eventBlock: TimelineEventBlock) => {
|
||||||
|
if (eventBlock.label === 'car') {
|
||||||
|
return 'red';
|
||||||
|
} else if (eventBlock.label === 'person') {
|
||||||
|
return 'blue';
|
||||||
|
} else if (eventBlock.label === 'dog') {
|
||||||
|
return 'green';
|
||||||
|
}
|
||||||
|
return 'gray';
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={block.id}
|
key={block.id}
|
||||||
onClick={onClickHandler}
|
onClick={onClickHandler}
|
||||||
className='absolute z-10 rounded-full bg-blue-300 h-2'
|
className={`absolute z-10 rounded-full bg-${getColor(block)}-400 h-2`}
|
||||||
style={{
|
style={{
|
||||||
top: `${block.yOffset}px`,
|
top: `${block.yOffset}px`,
|
||||||
left: `${block.positionX}px`,
|
left: `${block.positionX}px`,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user