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