Skip to content

Commit

Permalink
feat: Add Operator List
Browse files Browse the repository at this point in the history
  • Loading branch information
arihanv committed Jul 3, 2023
1 parent 7a61585 commit 50f7bd1
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 13 deletions.
14 changes: 12 additions & 2 deletions apps/client/src/features/operator/Operator.module.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// remember we are targeting phones and tablets

.operator {
width: 100vw;
height: 100vh;
Expand All @@ -7,10 +8,19 @@
display: flex;
flex-direction: column;
gap: 2px;
color:white;
}

.allBlocks{
flex: 1;
overflow: scroll;
}

@mixin event-block() {
padding: 0.5rem;
padding: 0.2rem;
display: flex;
gap: 0.75rem;
align-items: center;
}

.scheduledEvent {
Expand All @@ -20,5 +30,5 @@

.block {
@include event-block();
background-color: wheat;
background-color: gray;
}
13 changes: 8 additions & 5 deletions apps/client/src/features/operator/Operator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { SupportedEvent } from 'ontime-types';
import useRundown from '../../common/hooks-query/useRundown';

import style from './Operator.module.scss';

import OpEvent from './op-event/OpEvent';
import OpBlock from './op-block/OpBlock';
import TimeBlock from './time-block/TimeBlock';

export default function Operator() {
// this is the data that you need, the status flag should give you possibility to create a loading state
Expand All @@ -17,6 +18,7 @@ export default function Operator() {

return (
<div className={style.operator}>
<div className={style.allBlocks}>
{data.map((entry) => {
// there are three types of events, you a filter them by using the type property
// for this view, we do not show the delay event
Expand All @@ -25,23 +27,24 @@ export default function Operator() {
if (entry.type === SupportedEvent.Event) {
return (
<div key={entry.id} className={style.scheduledEvent}>
<OpBlock entry={JSON.stringify(entry, null, 2)} />
<OpEvent data={entry} />
</div>
);
}


// this is a block entry (like a section title)
if (entry.type === SupportedEvent.Block) {
return (
<div key={entry.id} className={style.block}>
{/* {JSON.stringify(entry, null, 2)} */}
<OpBlock entry={JSON.stringify(entry, null, 2)} />
<OpBlock data={entry} />
</div>
);
}

return null;
})}
</div>
<TimeBlock/>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.title{
font-size: 1rem;
}
14 changes: 8 additions & 6 deletions apps/client/src/features/operator/op-block/OpBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import style from './OpBlock.module.scss';

type Props = {
entry: string;
}
data: any;
};

export default function OpBlock({entry}: Props) {
export default function OpBlock({ data }: Props) {
return (
<div>OpBlock</div>
)
}
<>
<div className={style.title}>{data.title}</div>
</>
);
}
27 changes: 27 additions & 0 deletions apps/client/src/features/operator/op-event/OpEvent.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.alias{
background-color: red;
width: fit-content;
height: fit-content;
padding: 0.2rem;
align-items: center;
}

.title{
font-size: 1rem;
}

.time{
display: flex;
flex-direction: column;
font-size: 0.65rem;
text-align: right;
}

.time > div {
margin-bottom: -4px; /* Adjust the value as needed */
}


.title{
flex: 1;
}
26 changes: 26 additions & 0 deletions apps/client/src/features/operator/op-event/OpEvent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { EventData } from 'ontime-types';
import style from './OpEvent.module.scss';
import { formatTime } from '../../../common/utils/time';

type Props = {
data: any;
};

export default function OpEvent({ data }: Props) {
const start = formatTime(data.timeStart, { format: 'hh:mm' });
const end = formatTime(data.timeEnd, { format: 'hh:mm' });
return (
<>
<div className={style.alias}>{data.note}</div>
<div className={style.title}>
{data.title} - {data.subtitle}
</div>
<div className={style.time}>
<div>
{start} - {end}
</div>
--:--:--
</div>
</>
);
}
12 changes: 12 additions & 0 deletions apps/client/src/features/operator/time-block/TimeBlock.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.block{
padding: 0.65rem;
border: 1px solid hotpink;
display: flex;
justify-content: space-between;
}

.clock{
display: flex;
gap: 1.5rem;
margin-right:1rem;
}
20 changes: 20 additions & 0 deletions apps/client/src/features/operator/time-block/TimeBlock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import styles from './TimeBlock.module.scss';
import { Play } from 'lucide-react';
import { useTimer } from '../../../common/hooks/useSocket';
import { formatTime } from '../../../common/utils/time';

type Props = {};

export default function TimeBlock({}: Props) {
const timer = useTimer();
const timeNow = formatTime(timer.clock, {
showSeconds: true,
format: 'hh:mm:ss a',
});
return (
<div className={styles.block}>
<Play size={17} />
<div className={styles.clock}>{timeNow} <div>00:10:00</div></div>
</div>
);
}

0 comments on commit 50f7bd1

Please sign in to comment.