Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: cuesheet v2 #435

Merged
merged 72 commits into from
Jul 22, 2023
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
9db47e6
refactor: partial typescript migration
cpvalente Jun 8, 2023
3034ad6
refactor: typescript migration
cpvalente Jun 8, 2023
28b47b4
Merge remote-tracking branch 'origin/master' into refactor/cuesheet-v2
cpvalente Jun 8, 2023
3fbb2bf
chore: remove prop-types package
cpvalente Jun 8, 2023
bc852cb
style: small tweaks to header
cpvalente Jun 10, 2023
0248d60
refactor: file structure
cpvalente Jun 10, 2023
8b677e6
refactor: accept nullish value
cpvalente Jun 10, 2023
e3568ed
refactor: migrate ontime table to tt-8
cpvalente Jun 10, 2023
c9b00db
refactor: add editable fields
cpvalente Jun 11, 2023
c84e72f
refactor: add index row
cpvalente Jun 11, 2023
a27b518
refactor: hide columns
cpvalente Jun 11, 2023
c0f8f92
refactor: column reorder
cpvalente Jun 12, 2023
f57452c
refactor: column resize
cpvalente Jun 12, 2023
714e115
refactor: column resize
cpvalente Jun 12, 2023
fc51236
chore: upgrade packages
cpvalente Jun 12, 2023
8e016f1
style: small tweaks to components
cpvalente Jun 18, 2023
17bcbc7
chore: delete unused
cpvalente Jun 18, 2023
794fbc8
style: small tweaks to components
cpvalente Jun 18, 2023
ea2c7ea
style: small tweaks to components
cpvalente Jun 18, 2023
74f671e
feat: ontime cuesheet
cpvalente Jun 18, 2023
3f2464d
style: small tweaks to components
cpvalente Jun 18, 2023
5885c9a
feat: ontime cuesheet
cpvalente Jun 18, 2023
d455b9f
refactor: virtualise table rows
cpvalente Jun 20, 2023
12eef4d
chore: remove unused code
cpvalente Jun 20, 2023
b530c41
style: tweaks on cuesheet view
cpvalente Jun 20, 2023
250ac6d
refactor: remove virtualisation
cpvalente Jun 20, 2023
9cdbca7
style: tweaks to non event rows
cpvalente Jun 20, 2023
8c6d686
refactor: extract and test applyDelay
cpvalente Jun 27, 2023
24a1f50
fix: delay not applied to timeEnd
cpvalente Jun 28, 2023
b1c954b
create caching store for backend calculations
cpvalente Jun 28, 2023
7fdb45b
refactor: rundown controller uses service as data source
cpvalente Jun 29, 2023
4333bee
refactor: convert to typescript
cpvalente Jun 29, 2023
48855eb
feat: caching store
cpvalente Jul 3, 2023
937b13e
refactor: add delay values to rundown
cpvalente Jul 3, 2023
116c60c
refactor: add delay values to rundown
cpvalente Jul 3, 2023
d3f96a9
refactor: remove unused
cpvalente Jul 3, 2023
b5f1adb
wip: cuesheet
cpvalente Jul 5, 2023
18630a7
refactor: cuesheet settings
cpvalente Jul 6, 2023
a00be43
feat: toggle past visibility
cpvalente Jul 6, 2023
b6f7717
chore: update tests
cpvalente Jul 6, 2023
0f858f1
refactor: typescript return types
cpvalente Jul 6, 2023
e2b3e2f
chore: update tests
cpvalente Jul 6, 2023
68b3fe5
refactor: use correct method
cpvalente Jul 6, 2023
fe8b43d
style: clarify error message
cpvalente Jul 10, 2023
95742bd
refactor: cuesheet typing and effects
cpvalente Jul 12, 2023
a47142e
style: consistent naming on cuesheet elements
cpvalente Jul 12, 2023
cb9c428
style: avoid name collisions in elements
cpvalente Jul 12, 2023
f3f2b97
style: small tweaks to option list
cpvalente Jul 12, 2023
30ca149
chore: test cachingStore
cpvalente Jul 12, 2023
3ce424f
style: small tweaks to option list
cpvalente Jul 12, 2023
550d9e3
style: naming convention on store attributes
cpvalente Jul 12, 2023
0a0ec86
Merge remote-tracking branch 'origin/master' into refactor/cuesheet-v2
cpvalente Jul 12, 2023
c141711
refactor: revise logic and add tests
cpvalente Jul 14, 2023
ff47e5f
refactor: revise logic
cpvalente Jul 14, 2023
02fe5b4
feat: add delay management settings
cpvalente Jul 14, 2023
40cde82
revert test utility
cpvalente Jul 14, 2023
927d64c
chore: configure inspect mode
cpvalente Jul 17, 2023
55a2381
refactor: use delay from server
cpvalente Jul 17, 2023
94d6c76
refactor: abstract array operation to utilities
cpvalente Jul 17, 2023
4fc8489
refactor: add caching layer to rundown operations
cpvalente Jul 17, 2023
43a31a0
fix: events are 1 indexed
cpvalente Jul 17, 2023
3db3a22
refactor: type log origin
cpvalente Jul 17, 2023
839f358
style: keep delay-block in view
cpvalente Jul 17, 2023
ed4809c
refactor: add extra fields to CSV
cpvalente Jul 17, 2023
db15488
style: show skipped events
cpvalente Jul 17, 2023
d178996
style: show skipped events
cpvalente Jul 17, 2023
2458e06
chore: add route to navigation menu
cpvalente Jul 21, 2023
33151a2
style: allow jumping to bottom
cpvalente Jul 21, 2023
6c2d95d
Merge remote-tracking branch 'origin/master' into refactor/cuesheet-v2
cpvalente Jul 21, 2023
cc5afb6
chore: add tests
cpvalente Jul 21, 2023
a653c73
chore: update snapshots
cpvalente Jul 21, 2023
998e29d
chore: update tests
cpvalente Jul 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions apps/client/.stylelintrc

This file was deleted.

12 changes: 3 additions & 9 deletions apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.0.0",
"private": true,
"dependencies": {
"@chakra-ui/react": "^2.5.5",
"@chakra-ui/react": "^2.7.0",
"@dnd-kit/core": "^6.0.8",
"@dnd-kit/sortable": "^7.0.2",
"@dnd-kit/utilities": "^3.2.1",
Expand All @@ -14,7 +14,8 @@
"@sentry/tracing": "^7.46.0",
"@tanstack/react-query": "^4.28.0",
"@tanstack/react-query-devtools": "^4.29.0",
"autosize": "^5.0.2",
"@tanstack/react-table": "^8.9.2",
"autosize": "^6.0.1",
"axios": "^1.2.0",
"color": "^4.2.3",
"csv-stringify": "^6.2.3",
Expand All @@ -27,7 +28,6 @@
"react-hook-form": "^7.43.5",
"react-qr-code": "^2.0.11",
"react-router-dom": "^6.3.0",
"react-table": "^7.7.0",
"typeface-open-sans": "^1.1.13",
"web-vitals": "^3.1.1",
"zustand": "^4.3.6"
Expand All @@ -40,7 +40,6 @@
"build:local": "cross-env NODE_ENV=local vite build",
"build:docker": "vite build",
"lint": "eslint .",
"stylelint": "npx stylelint \"**/*.scss\"\n",
"test": "vitest",
"test:pipeline": "vitest run",
"cleanup": "rm -rf .turbo && rm -rf node_modules && rm -rf build"
Expand All @@ -65,7 +64,6 @@
"@testing-library/user-event": "^14.1.1",
"@types/color": "^3.0.3",
"@types/luxon": "^3.2.0",
"@types/prop-types": "^15.7.5",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.10",
"@types/testing-library__jest-dom": "^5.14.5",
Expand All @@ -84,11 +82,7 @@
"ontime-types": "workspace:*",
"ontime-utils": "workspace:*",
"prettier": "^2.8.3",
"prop-types": "^15.8.1",
"sass": "^1.57.1",
"stylelint": "^14.16.1",
"stylelint-config-prettier": "^9.0.4",
"stylelint-config-standard-scss": "^6.1.0",
"typescript": "^4.9.4",
"vite": "^4.3.1",
"vite-plugin-compression2": "^0.9.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import { Textarea, TextareaProps } from '@chakra-ui/react';
// @ts-expect-error no types from library
import autosize from 'autosize/dist/autosize';

interface AutoTextAreaProps extends TextareaProps {
isDark?: boolean;
}

export const AutoTextArea = (props: AutoTextAreaProps) => {
const { isDark, ...rest } = props;
export const AutoTextArea = (props: TextareaProps) => {
const ref = useRef<HTMLTextAreaElement>(null);

useEffect(() => {
Expand All @@ -26,8 +21,8 @@ export const AutoTextArea = (props: AutoTextAreaProps) => {
resize='none'
ref={ref}
transition='height none'
variant={isDark ? 'ontime-filled' : 'ontime-filled-on-light'}
{...rest}
variant='ontime-transparent'
{...props}
/>
);
};
79 changes: 0 additions & 79 deletions apps/client/src/common/context/TableSettingsContext.jsx

This file was deleted.

19 changes: 18 additions & 1 deletion apps/client/src/common/utils/__tests__/dateConfig.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
import { forgivingStringToMillis, millisToDelayString, millisToMinutes, millisToSeconds } from '../dateConfig';
import {
forgivingStringToMillis,
millisToDelayString,
millisToMinutes,
millisToSeconds,
secondsInMillis,
} from '../dateConfig';

describe('test secondsInMillis function', () => {
it('return 0 if value is null', () => {
expect(secondsInMillis(null)).toBe(0);
});
it('returns the seconds value of a millis date', () => {
const date = 1686255053619; // Thu Jun 08 2023 20:10:53
const seconds = secondsInMillis(date);
expect(seconds).toBe(53);
});
});

describe('test millisToSeconds function', () => {
it('test with null values', () => {
Expand Down
7 changes: 7 additions & 0 deletions apps/client/src/common/utils/dateConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ import { mth, mtm, mts } from './timeConstants';
export const timeFormat = 'HH:mm';
export const timeFormatSeconds = 'HH:mm:ss';

export function secondsInMillis(millis: number | null) {
if (!millis) {
return 0;
}
return Math.floor((millis % mtm) / mts);
}

/**
* @description Converts milliseconds to seconds
* @param {number | null} millis - time in seconds
Expand Down
13 changes: 11 additions & 2 deletions apps/client/src/common/utils/eventsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const getEventsWithDelay = (rundown: OntimeRundownEntry[]): OntimeEvent[]
* @param {number} limit - max number of events to return
* @returns {Object[]} Event list with maximum <limit> objects
*/
export const trimRundown = (rundown: OntimeRundownEntry[], selectedId: string, limit: number) => {
export const trimRundown = (rundown: OntimeEvent[], selectedId: string, limit: number): OntimeEvent[] => {
if (rundown == null) return [];

const BEFORE = 2;
Expand Down Expand Up @@ -78,7 +78,7 @@ export const formatEventList = (
selectedId: string,
nextId: string,
options: FormatEventListOptionsProp,
) => {
): ScheduleEvent[] => {
if (rundown == null) return [];
const { showEnd = false } = options;

Expand All @@ -103,6 +103,15 @@ export const formatEventList = (
return formattedEvents;
};

export type ScheduleEvent = {
id: string;
time: string;
title: string;
isNow: boolean;
isNext: boolean;
colour: string;
};

/**
* @description Creates a safe duplicate of an event
* @param {object} event
Expand Down
7 changes: 7 additions & 0 deletions apps/client/src/features/menu/RundownMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ const RundownMenu = () => {
setCursor(null);
}, [deleteAllEvents, setCursor, setEditId]);

const makeMany = () => {
for (let i = 0; i < 100; i++) {
addEvent({ type: SupportedEvent.Event });
}
};

return (
<div className={style.headerButtons}>
<Button onClick={makeMany}>make many</Button>
<Menu isLazy lazyBehavior='unmount' variant='ontime-on-dark'>
<MenuButton as={Button} leftIcon={<IoAdd />} size='sm' variant='ontime-subtle'>
Event...
Expand Down
131 changes: 131 additions & 0 deletions apps/client/src/features/table/Cuesheet.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
@use '../../theme/ontimeColours' as *;
@use '../../theme/v2Styles' as *;

$table-font-size: calc(1rem - 2px);
$table-header-font-size: calc(1rem - 3px);

.cuesheetContainer {
grid-area: table;
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
overflow: auto;
}

.cuesheet {
font-size: $table-font-size;
font-weight: 400;

tr {
display: flex;
}

th, td {
margin: 1px;
font-weight: inherit;
font-size: inherit;
text-align: left;
position: relative;

white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}

.tableHeader,
.eventRow {
.indexColumn {
min-width: 2rem;
text-align: right;
font-weight: 400;
}
}

.tableHeader {
position: sticky;
top: 0;
z-index: 10;
background-color: $gray-1300;

font-size: $table-header-font-size;
color: $gray-700;
font-weight: 400;
}

.eventRow {
vertical-align: top;

td {
background-color: $gray-1250;
border-radius: 2px;
padding: 0.25rem;
}
}

.blockRow {
width: 100%;
background-color: $gray-1350;
font-size: 1rem;
height: 2.5rem;

td {
align-self: flex-end;
padding: 0.25rem 1rem;
}
}

.delayRow {
width: 100%;
color: $ontime-delay-text;

td {
width: 100vw;
text-align: center;
padding: 0.5rem 0;
}
}

.check {
font-size: 1.5rem;
margin: 0 auto;
}

.delaySymbol {
svg {
font-size: 1.5rem;
color: $ontime-delay;
margin: 0 auto;
}
}

.resizer {
cursor: col-resize;
opacity: 0;
display: inline-block;
width: 3px;
height: 100%;
position: absolute;
right: 0;
top: 0;
transform: translateX(50%);
background-color: $action-blue;

user-select: none;
touch-action: none;

transition-duration: $transition-time-action;
transition-property: width, background-color;

&:hover {
opacity: $opacity-disabled;
width: 6px;
}

&.isResizing {
opacity: 1;
width: 6px;
background-color: $action-blue;
}
}
Loading