mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 22:49:18 +00:00
Colorised spreadsheet (#1643)
* feat: colorise spreadSheet with rundown color * feat: add colorisation in spreadsheet for block * feat: border color * fix: cleanup accessible color * fix: review before merge (https://github.com/cpvalente/ontime/pull/1608) * fix: usgae of map instead foreach (https://github.com/cpvalente/ontime/pull/1608) * Update apps/server/src/services/sheet-service/SheetService.ts Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com> * fix: comment condition * fix: Remove Color plugin (but don't can get color like 'red' or 'black') * fix: isLight for more clean code * fix: remove map on isLight function * fix: remove debug logger * refactor colour * lint --------- Co-authored-by: Gwenitora <gwenitora.gardu74@gmail.com> Co-authored-by: Gwenitora <61121870+Gwenitora@users.noreply.github.com> Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
984dcb0181
commit
4872cd0a48
@@ -211,16 +211,18 @@ async function verifySheet(
|
||||
spreadsheetId: sheetId,
|
||||
includeGridData: false,
|
||||
});
|
||||
const worksheets = spreadsheets.data.sheets?.forEach((sheet) => {
|
||||
|
||||
const worksheets: string[] = [];
|
||||
spreadsheets.data.sheets?.forEach((sheet) => {
|
||||
if (sheet.properties?.title) {
|
||||
return sheet.properties.title;
|
||||
worksheets.push(sheet.properties.title);
|
||||
}
|
||||
});
|
||||
|
||||
if (!worksheets) {
|
||||
if (worksheets.length === 0) {
|
||||
throw new Error('No worksheets found');
|
||||
}
|
||||
return worksheets;
|
||||
return { worksheetOptions: worksheets };
|
||||
} catch (error) {
|
||||
// attempt to catch errors caused by importing xlsx
|
||||
catchCommonImportXlsxError(error);
|
||||
@@ -293,7 +295,17 @@ async function verifyWorksheet(sheetId: string, worksheet: string): Promise<{ wo
|
||||
if (!selectedWorksheet) {
|
||||
throw new Error('Could not find worksheet');
|
||||
}
|
||||
if (!selectedWorksheet.properties || !selectedWorksheet.properties.sheetId) {
|
||||
/*
|
||||
The first spreadsheet provided by google sheet has an id = 0,
|
||||
so !0 returns true, the only other number that returns true in this setup is NaN,
|
||||
so if x !== 0 && x !== NaN, then !x returns false, we indeed want !NaN to return true,
|
||||
but we would like !0 to return false, reason why is also checked that the id is not 0,
|
||||
because if it is 0, then I should not enter the condition.
|
||||
*/
|
||||
if (
|
||||
!selectedWorksheet.properties ||
|
||||
(!selectedWorksheet.properties.sheetId && selectedWorksheet.properties.sheetId !== 0)
|
||||
) {
|
||||
throw new Error('Got invalid data from worksheet');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user