mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-08 08:53:51 +00:00
fix: deepsource recommendations
This commit is contained in:
@@ -66,9 +66,7 @@ export default function SheetsModal(props: SheetsModalProps) {
|
||||
|
||||
const handleFile = async (event: ChangeEvent<HTMLInputElement>) => {
|
||||
const selectedFile = event?.target?.files?.[0];
|
||||
if (!selectedFile) {
|
||||
return;
|
||||
} else {
|
||||
if (selectedFile) {
|
||||
await uploadSheetClientFile(selectedFile).catch((err) => {
|
||||
console.error(err); //TODO: how to show this to the user
|
||||
});
|
||||
@@ -124,7 +122,7 @@ export default function SheetsModal(props: SheetsModalProps) {
|
||||
};
|
||||
|
||||
const handlePushData = () => {
|
||||
postPushSheet().then((_) => {});
|
||||
postPushSheet();
|
||||
};
|
||||
|
||||
const handleFinalise = async () => {
|
||||
|
||||
@@ -523,7 +523,7 @@ export async function sheetAuthUrl(req, res) {
|
||||
* @method GET
|
||||
*/
|
||||
export const getGoogleSheetSettings = async (req, res) => {
|
||||
const sheet = DataProvider.getGoogleSheet();
|
||||
const sheet = await DataProvider.getGoogleSheet();
|
||||
res.status(200).send(sheet);
|
||||
};
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ export function cellRequenstFromEvent(
|
||||
worksheetId: number,
|
||||
metadata,
|
||||
): sheets_v4.Schema$Request {
|
||||
const r: sheets_v4.Schema$CellData[] = [];
|
||||
const returnRows: sheets_v4.Schema$CellData[] = [];
|
||||
const tmp = Object.entries(metadata)
|
||||
.filter(([_, value]) => value !== undefined)
|
||||
.sort(([_a, a], [_b, b]) => a['col'] - b['col']) as [string, { col: number; row: number }][];
|
||||
@@ -64,25 +64,25 @@ export function cellRequenstFromEvent(
|
||||
tmp.forEach(([key, _]) => {
|
||||
if (isOntimeEvent(event)) {
|
||||
if (key === 'blank') {
|
||||
r.push({});
|
||||
returnRows.push({});
|
||||
} else if (key === 'colour') {
|
||||
r.push({
|
||||
returnRows.push({
|
||||
userEnteredValue: { stringValue: event.colour },
|
||||
});
|
||||
} else if (typeof event[key] === 'number') {
|
||||
r.push({
|
||||
returnRows.push({
|
||||
userEnteredValue: { stringValue: millisToString(event[key], true) },
|
||||
});
|
||||
} else if (typeof event[key] === 'string') {
|
||||
r.push({
|
||||
returnRows.push({
|
||||
userEnteredValue: { stringValue: event[key] },
|
||||
});
|
||||
} else if (typeof event[key] === 'boolean') {
|
||||
r.push({
|
||||
returnRows.push({
|
||||
userEnteredValue: { stringValue: event[key] ? 'x' : '' },
|
||||
});
|
||||
} else {
|
||||
r.push({});
|
||||
returnRows.push({});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -96,7 +96,7 @@ export function cellRequenstFromEvent(
|
||||
fields: 'userEnteredValue',
|
||||
rows: [
|
||||
{
|
||||
values: r,
|
||||
values: returnRows,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -115,7 +115,7 @@ export function cellRequenstFromProjectData(
|
||||
worksheetId: number,
|
||||
metadata,
|
||||
): sheets_v4.Schema$Request {
|
||||
const r: sheets_v4.Schema$RowData[] = [];
|
||||
const returnRows: sheets_v4.Schema$RowData[] = [];
|
||||
const tmp = Object.entries(metadata)
|
||||
.filter(([_, value]) => value !== undefined)
|
||||
.sort(([_a, a], [_b, b]) => a['col'] - b['col']) as [string, { col: number; row: number }][];
|
||||
@@ -139,9 +139,9 @@ export function cellRequenstFromProjectData(
|
||||
}
|
||||
tmp.forEach(([key, _]) => {
|
||||
if (key == 'blank') {
|
||||
r.push({});
|
||||
returnRows.push({});
|
||||
} else {
|
||||
r.push({
|
||||
returnRows.push({
|
||||
values: [
|
||||
{
|
||||
userEnteredValue: { stringValue: projectData[key] },
|
||||
@@ -159,7 +159,7 @@ export function cellRequenstFromProjectData(
|
||||
columnIndex: minCol,
|
||||
},
|
||||
fields: 'userEnteredValue',
|
||||
rows: r,
|
||||
rows: returnRows,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -122,123 +122,123 @@ export const parseExcel = (excelData: unknown[][], options?: Partial<ExcelImport
|
||||
const handlers = {
|
||||
[importMap.projectName]: (row: number, col: number) => {
|
||||
projectTitleNext = true;
|
||||
projectMetadata['title'] = { row: row, col: col };
|
||||
projectMetadata['title'] = { row, col };
|
||||
},
|
||||
[importMap.projectDescription]: (row: number, col: number) => {
|
||||
projectDescriptionNext = true;
|
||||
projectMetadata['description'] = { row: row, col: col };
|
||||
projectMetadata['description'] = { row, col };
|
||||
},
|
||||
[importMap.publicUrl]: (row: number, col: number) => {
|
||||
publicUrlNext = true;
|
||||
projectMetadata['publicUrl'] = { row: row, col: col };
|
||||
projectMetadata['publicUrl'] = { row, col };
|
||||
},
|
||||
[importMap.publicInfo]: (row: number, col: number) => {
|
||||
publicInfoNext = true;
|
||||
projectMetadata['publicInfo'] = { row: row, col: col };
|
||||
projectMetadata['publicInfo'] = { row, col };
|
||||
},
|
||||
[importMap.backstageUrl]: (row: number, col: number) => {
|
||||
backstageUrlNext = true;
|
||||
projectMetadata['backstageUrl'] = { row: row, col: col };
|
||||
projectMetadata['backstageUrl'] = { row, col };
|
||||
},
|
||||
[importMap.backstageInfo]: (row: number, col: number) => {
|
||||
backstageInfoNext = true;
|
||||
projectMetadata['backstageInfo'] = { row: row, col: col };
|
||||
projectMetadata['backstageInfo'] = { row, col };
|
||||
},
|
||||
|
||||
[importMap.timeStart]: (row: number, col: number) => {
|
||||
timeStartIndex = col;
|
||||
rundownMetadata['timeStart'] = { row: row, col: col };
|
||||
rundownMetadata['timeStart'] = { row, col };
|
||||
},
|
||||
[importMap.timeEnd]: (row: number, col: number) => {
|
||||
timeEndIndex = col;
|
||||
rundownMetadata['timeEnd'] = { row: row, col: col };
|
||||
rundownMetadata['timeEnd'] = { row, col };
|
||||
},
|
||||
[importMap.duration]: (row: number, col: number) => {
|
||||
durationIndex = col;
|
||||
rundownMetadata['duration'] = { row: row, col: col };
|
||||
rundownMetadata['duration'] = { row, col };
|
||||
},
|
||||
|
||||
[importMap.cue]: (row: number, col: number) => {
|
||||
cueIndex = col;
|
||||
rundownMetadata['cue'] = { row: row, col: col };
|
||||
rundownMetadata['cue'] = { row, col };
|
||||
},
|
||||
[importMap.title]: (row: number, col: number) => {
|
||||
titleIndex = col;
|
||||
rundownMetadata['title'] = { row: row, col: col };
|
||||
rundownMetadata['title'] = { row, col };
|
||||
},
|
||||
[importMap.presenter]: (row: number, col: number) => {
|
||||
presenterIndex = col;
|
||||
rundownMetadata['presenter'] = { row: row, col: col };
|
||||
rundownMetadata['presenter'] = { row, col };
|
||||
},
|
||||
[importMap.subtitle]: (row: number, col: number) => {
|
||||
subtitleIndex = col;
|
||||
rundownMetadata['subtitle'] = { row: row, col: col };
|
||||
rundownMetadata['subtitle'] = { row, col };
|
||||
},
|
||||
[importMap.isPublic]: (row: number, col: number) => {
|
||||
isPublicIndex = col;
|
||||
rundownMetadata['isPublic'] = { row: row, col: col };
|
||||
rundownMetadata['isPublic'] = { row, col };
|
||||
},
|
||||
[importMap.skip]: (row: number, col: number) => {
|
||||
skipIndex = col;
|
||||
rundownMetadata['skip'] = { row: row, col: col };
|
||||
rundownMetadata['skip'] = { row, col };
|
||||
},
|
||||
[importMap.note]: (row: number, col: number) => {
|
||||
notesIndex = col;
|
||||
rundownMetadata['note'] = { row: row, col: col };
|
||||
rundownMetadata['note'] = { row, col };
|
||||
},
|
||||
[importMap.colour]: (row: number, col: number) => {
|
||||
colourIndex = col;
|
||||
rundownMetadata['colour'] = { row: row, col: col };
|
||||
rundownMetadata['colour'] = { row, col };
|
||||
},
|
||||
|
||||
[importMap.endAction]: (row: number, col: number) => {
|
||||
endActionIndex = col;
|
||||
rundownMetadata['endAction'] = { row: row, col: col };
|
||||
rundownMetadata['endAction'] = { row, col };
|
||||
},
|
||||
[importMap.timerType]: (row: number, col: number) => {
|
||||
timerTypeIndex = col;
|
||||
rundownMetadata['timerType'] = { row: row, col: col };
|
||||
rundownMetadata['timerType'] = { row, col };
|
||||
},
|
||||
|
||||
[importMap.user0]: (row: number, col: number) => {
|
||||
user0Index = col;
|
||||
rundownMetadata['user0'] = { row: row, col: col };
|
||||
rundownMetadata['user0'] = { row, col };
|
||||
},
|
||||
[importMap.user1]: (row: number, col: number) => {
|
||||
user1Index = col;
|
||||
rundownMetadata['user1'] = { row: row, col: col };
|
||||
rundownMetadata['user1'] = { row, col };
|
||||
},
|
||||
[importMap.user2]: (row: number, col: number) => {
|
||||
user2Index = col;
|
||||
rundownMetadata['user2'] = { row: row, col: col };
|
||||
rundownMetadata['user2'] = { row, col };
|
||||
},
|
||||
[importMap.user3]: (row: number, col: number) => {
|
||||
user3Index = col;
|
||||
rundownMetadata['user3'] = { row: row, col: col };
|
||||
rundownMetadata['user3'] = { row, col };
|
||||
},
|
||||
[importMap.user4]: (row: number, col: number) => {
|
||||
user4Index = col;
|
||||
rundownMetadata['user4'] = { row: row, col: col };
|
||||
rundownMetadata['user4'] = { row, col };
|
||||
},
|
||||
[importMap.user5]: (row: number, col: number) => {
|
||||
user5Index = col;
|
||||
rundownMetadata['user5'] = { row: row, col: col };
|
||||
rundownMetadata['user5'] = { row, col };
|
||||
},
|
||||
[importMap.user6]: (row: number, col: number) => {
|
||||
user6Index = col;
|
||||
rundownMetadata['user6'] = { row: row, col: col };
|
||||
rundownMetadata['user6'] = { row, col };
|
||||
},
|
||||
[importMap.user7]: (row: number, col: number) => {
|
||||
user7Index = col;
|
||||
rundownMetadata['user7'] = { row: row, col: col };
|
||||
rundownMetadata['user7'] = { row, col };
|
||||
},
|
||||
[importMap.user8]: (row: number, col: number) => {
|
||||
user8Index = col;
|
||||
rundownMetadata['user8'] = { row: row, col: col };
|
||||
rundownMetadata['user8'] = { row, col };
|
||||
},
|
||||
[importMap.user9]: (row: number, col: number) => {
|
||||
user9Index = col;
|
||||
rundownMetadata['user9'] = { row: row, col: col };
|
||||
rundownMetadata['user9'] = { row, col };
|
||||
},
|
||||
} as const;
|
||||
|
||||
@@ -336,8 +336,8 @@ export const parseExcel = (excelData: unknown[][], options?: Partial<ExcelImport
|
||||
version: '2.0.0',
|
||||
},
|
||||
userFields: customUserFields,
|
||||
projectMetadata: projectMetadata,
|
||||
rundownMetadata: rundownMetadata,
|
||||
projectMetadata,
|
||||
rundownMetadata,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
import { OAuth2Client } from 'google-auth-library';
|
||||
import { readFile, writeFile } from 'fs/promises';
|
||||
import { sheets, sheets_v4 } from '@googleapis/sheets';
|
||||
import { readFile, writeFile } from 'fs/promises';
|
||||
import { OAuth2Client } from 'google-auth-library';
|
||||
import http from 'http';
|
||||
import { DatabaseModel, GoogleSheetState, LogOrigin } from 'ontime-types';
|
||||
import { join } from 'path';
|
||||
import { URL } from 'url';
|
||||
import { logger } from '../classes/Logger.js';
|
||||
import { DataProvider } from '../classes/data-provider/DataProvider.js';
|
||||
import { getAppDataPath } from '../setup.js';
|
||||
import { DatabaseModel, LogOrigin } from 'ontime-types';
|
||||
import { ensureDirectory } from './fileManagement.js';
|
||||
import { cellRequenstFromEvent, cellRequenstFromProjectData, getA1Notation } from './googleSheetUtils.js';
|
||||
import { parseExcel } from './parser.js';
|
||||
import { parseProject, parseRundown, parseUserFields } from './parserFunctions.js';
|
||||
import { ensureDirectory } from './fileManagement.js';
|
||||
import { DataProvider } from '../classes/data-provider/DataProvider.js';
|
||||
import { GoogleSheetState } from 'ontime-types';
|
||||
import { cellRequenstFromEvent, cellRequenstFromProjectData, getA1Notation } from './googleSheetUtils.js';
|
||||
import { join } from 'path';
|
||||
|
||||
type ResponseOK = {
|
||||
data: Partial<DatabaseModel>;
|
||||
@@ -24,9 +23,9 @@ class sheet {
|
||||
private readonly sheetsFolder;
|
||||
private readonly client_secret;
|
||||
private static authUrl: null | string = null;
|
||||
private worksheetId: number = 0;
|
||||
private sheetId: string = '';
|
||||
private range: string = '';
|
||||
private worksheetId = 0;
|
||||
private sheetId = '';
|
||||
private range = '';
|
||||
|
||||
constructor() {
|
||||
const appDataPath = getAppDataPath();
|
||||
@@ -87,10 +86,13 @@ class sheet {
|
||||
});
|
||||
|
||||
if (spreadsheets.status === 200) {
|
||||
const w = spreadsheets.data.sheets.find((p) => p.properties.title == worksheet);
|
||||
if (w !== undefined) {
|
||||
const endCell = getA1Notation(w.properties.gridProperties.rowCount, w.properties.gridProperties.columnCount);
|
||||
return { worksheetId: w.properties.sheetId, range: `${worksheet}!A1:${endCell}` };
|
||||
const ourWorksheetData = spreadsheets.data.sheets.find((n) => n.properties.title == worksheet);
|
||||
if (ourWorksheetData !== undefined) {
|
||||
const endCell = getA1Notation(
|
||||
ourWorksheetData.properties.gridProperties.rowCount,
|
||||
ourWorksheetData.properties.gridProperties.columnCount,
|
||||
);
|
||||
return { worksheetId: ourWorksheetData.properties.sheetId, range: `${worksheet}!A1:${endCell}` };
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@@ -317,7 +319,7 @@ class sheet {
|
||||
}
|
||||
const code = searchParams.get('code');
|
||||
const { tokens } = await client.getToken({
|
||||
code: code,
|
||||
code,
|
||||
redirect_uri: redirectUri.toString(),
|
||||
});
|
||||
client.credentials = tokens;
|
||||
@@ -338,7 +340,7 @@ class sheet {
|
||||
listenPort = Number(redirectUri.port);
|
||||
}
|
||||
//TODO: the server might not start correctly
|
||||
server.listen(listenPort, () => {});
|
||||
server.listen(listenPort);
|
||||
const address = server.address();
|
||||
if (typeof address !== 'string') {
|
||||
redirectUri.port = String(address.port);
|
||||
@@ -353,7 +355,7 @@ class sheet {
|
||||
this.authServerTimeout = setTimeout(
|
||||
() => {
|
||||
sheet.authUrl = null;
|
||||
server.unref;
|
||||
server.unref();
|
||||
},
|
||||
2 * 60 * 1000,
|
||||
);
|
||||
|
||||
@@ -5,8 +5,7 @@ import { OSCSettings } from './core/OscSettings.type.js';
|
||||
import { Settings } from './core/Settings.type.js';
|
||||
import { UserFields } from './core/UserFields.type.js';
|
||||
import { ViewSettings } from './core/Views.type.js';
|
||||
import { GoogleSheet } from '../index.js';
|
||||
import { HttpSettings } from '../index.js';
|
||||
import { GoogleSheet, HttpSettings } from '../index.js';
|
||||
|
||||
export type DatabaseModel = {
|
||||
rundown: OntimeRundown;
|
||||
|
||||
Reference in New Issue
Block a user