mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-04 15:08:01 +00:00
feat: parse timeToEnd from excel
This commit is contained in:
@@ -11,6 +11,7 @@ export const namedImportMap = {
|
||||
Duration: 'duration',
|
||||
Cue: 'cue',
|
||||
Title: 'title',
|
||||
'Time to end': 'time to end',
|
||||
'Is Public': 'public',
|
||||
Skip: 'skip',
|
||||
Note: 'notes',
|
||||
@@ -47,6 +48,7 @@ export function convertToImportMap(namedImportMap: NamedImportMap): ImportMap {
|
||||
duration: namedImportMap.Duration,
|
||||
cue: namedImportMap.Cue,
|
||||
title: namedImportMap.Title,
|
||||
isTimeToEnd: namedImportMap['Time to end'],
|
||||
isPublic: namedImportMap['Is Public'],
|
||||
skip: namedImportMap.Skip,
|
||||
note: namedImportMap.Note,
|
||||
|
||||
@@ -40,6 +40,7 @@ export default function PreviewRundown(props: PreviewRundownProps) {
|
||||
<th>Duration</th>
|
||||
<th>Warning Time</th>
|
||||
<th>Danger Time</th>
|
||||
<th>Is Time to End</th>
|
||||
<th>Is Public</th>
|
||||
<th>Skip</th>
|
||||
<th>Colour</th>
|
||||
@@ -71,6 +72,7 @@ export default function PreviewRundown(props: PreviewRundownProps) {
|
||||
}
|
||||
eventIndex += 1;
|
||||
const colour = event.colour ? getAccessibleColour(event.colour) : {};
|
||||
const isTimeToEnd = booleanToText(event.isTimeToEnd);
|
||||
const isPublic = booleanToText(event.isPublic);
|
||||
const skip = booleanToText(event.skip);
|
||||
|
||||
@@ -93,6 +95,7 @@ export default function PreviewRundown(props: PreviewRundownProps) {
|
||||
<td>{millisToString(event.duration)}</td>
|
||||
<td>{millisToString(event.timeWarning)}</td>
|
||||
<td>{millisToString(event.timeDanger)}</td>
|
||||
<td className={style.center}>{isTimeToEnd && <Tag>{isTimeToEnd}</Tag>}</td>
|
||||
<td className={style.center}>{isPublic && <Tag>{isPublic}</Tag>}</td>
|
||||
<td>{skip && <Tag>{skip}</Tag>}</td>
|
||||
<td style={{ ...colour }}>{event.colour}</td>
|
||||
|
||||
@@ -775,6 +775,7 @@ describe('getCustomFieldData()', () => {
|
||||
duration: 'duration',
|
||||
cue: 'cue',
|
||||
title: 'title',
|
||||
isTimeToEnd: 'time to end',
|
||||
isPublic: 'public',
|
||||
skip: 'skip',
|
||||
note: 'notes',
|
||||
@@ -825,6 +826,7 @@ describe('getCustomFieldData()', () => {
|
||||
duration: 'duration',
|
||||
cue: 'cue',
|
||||
title: 'title',
|
||||
isTimeToEnd: 'time to end',
|
||||
isPublic: 'public',
|
||||
skip: 'skip',
|
||||
note: 'notes',
|
||||
@@ -884,6 +886,7 @@ describe('parseExcel()', () => {
|
||||
'Title',
|
||||
'End Action',
|
||||
'Timer type',
|
||||
'Time to end',
|
||||
'Public',
|
||||
'Skip',
|
||||
'Notes',
|
||||
@@ -906,7 +909,8 @@ describe('parseExcel()', () => {
|
||||
'Guest Welcome',
|
||||
'',
|
||||
'',
|
||||
'x',
|
||||
'x', // <-- time to end
|
||||
'x', // <-- public
|
||||
'',
|
||||
'Ballyhoo',
|
||||
'a0',
|
||||
@@ -928,7 +932,8 @@ describe('parseExcel()', () => {
|
||||
'A song from the hearth',
|
||||
'load-next',
|
||||
'clock',
|
||||
'',
|
||||
'x', // <-- time to end
|
||||
'', // <-- public
|
||||
'x',
|
||||
'Rainbow chase',
|
||||
'b0',
|
||||
@@ -972,6 +977,7 @@ describe('parseExcel()', () => {
|
||||
timerType: 'count-down',
|
||||
endAction: 'none',
|
||||
isPublic: true,
|
||||
isTimeToEnd: true,
|
||||
skip: false,
|
||||
note: 'Ballyhoo',
|
||||
custom: {
|
||||
@@ -995,6 +1001,7 @@ describe('parseExcel()', () => {
|
||||
timeEnd: 30600000,
|
||||
title: 'A song from the hearth',
|
||||
timerType: 'clock',
|
||||
isTimeToEnd: true,
|
||||
endAction: 'load-next',
|
||||
isPublic: false,
|
||||
skip: true,
|
||||
@@ -1455,12 +1462,17 @@ describe('parseExcel()', () => {
|
||||
timeDanger: 'danger time',
|
||||
custom: {},
|
||||
};
|
||||
|
||||
const result = parseExcel(testdata, {}, importMap);
|
||||
expect(result.rundown.length).toBe(2);
|
||||
expect((result.rundown.at(0) as OntimeEvent).type).toBe(SupportedEvent.Event);
|
||||
expect((result.rundown.at(0) as OntimeEvent).timerType).toBe(TimerType.CountDown);
|
||||
expect((result.rundown.at(1) as OntimeEvent).type).toBe(SupportedEvent.Event);
|
||||
expect((result.rundown.at(1) as OntimeEvent).timerType).toBe(TimerType.CountDown);
|
||||
expect(result.rundown[0]).toMatchObject({
|
||||
type: SupportedEvent.Event,
|
||||
timerType: TimerType.CountDown,
|
||||
});
|
||||
expect(result.rundown[1]).toMatchObject({
|
||||
type: SupportedEvent.Event,
|
||||
timerType: TimerType.CountDown,
|
||||
});
|
||||
});
|
||||
|
||||
it('imports as events if timer type is empty or has whitespace', () => {
|
||||
|
||||
@@ -110,6 +110,7 @@ export const parseExcel = (
|
||||
// options: booleans
|
||||
let isPublicIndex: number | null = null;
|
||||
let skipIndex: number | null = null;
|
||||
let isTimeToEndIndex: number | null = null;
|
||||
|
||||
let linkStartIndex: number | null = null;
|
||||
|
||||
@@ -159,6 +160,10 @@ export const parseExcel = (
|
||||
titleIndex = col;
|
||||
rundownMetadata['title'] = { row, col };
|
||||
},
|
||||
[importMap.isTimeToEnd]: (row: number, col: number) => {
|
||||
isTimeToEndIndex = col;
|
||||
rundownMetadata['isTimeToEnd'] = { row, col };
|
||||
},
|
||||
[importMap.isPublic]: (row: number, col: number) => {
|
||||
isPublicIndex = col;
|
||||
rundownMetadata['isPublic'] = { row, col };
|
||||
@@ -226,6 +231,8 @@ export const parseExcel = (
|
||||
event.duration = parseExcelDate(column);
|
||||
} else if (j === cueIndex) {
|
||||
event.cue = makeString(column, '');
|
||||
} else if (j === isTimeToEndIndex) {
|
||||
event.isTimeToEnd = parseBooleanString(column);
|
||||
} else if (j === isPublicIndex) {
|
||||
event.isPublic = parseBooleanString(column);
|
||||
} else if (j === skipIndex) {
|
||||
@@ -271,7 +278,6 @@ export const parseExcel = (
|
||||
|
||||
// if any data was found in row, push to array
|
||||
const keysFound = Object.keys(event).length + Object.keys(eventCustomFields).length;
|
||||
console.log('keys found ---->', event)
|
||||
if (keysFound > 0) {
|
||||
// if it is a Block type drop all other filed
|
||||
if (isOntimeBlock(event)) {
|
||||
|
||||
@@ -11,6 +11,7 @@ describe('isImportMap()', () => {
|
||||
duration: 'duration',
|
||||
cue: 'cue',
|
||||
title: 'title',
|
||||
isTimeToEnd: 'time to end',
|
||||
isPublic: 'public',
|
||||
skip: 'skip',
|
||||
note: 'notes',
|
||||
@@ -34,6 +35,7 @@ describe('isImportMap()', () => {
|
||||
duration: 'duration',
|
||||
cue: 'cue',
|
||||
title: 'title',
|
||||
isTimeToEnd: 'time to end',
|
||||
isPublic: 'public',
|
||||
skip: 'skip',
|
||||
note: 'notes',
|
||||
|
||||
@@ -11,6 +11,7 @@ export const defaultImportMap = {
|
||||
duration: 'duration',
|
||||
cue: 'cue',
|
||||
title: 'title',
|
||||
isTimeToEnd: 'time to end',
|
||||
isPublic: 'public',
|
||||
skip: 'skip',
|
||||
note: 'notes',
|
||||
|
||||
Reference in New Issue
Block a user