mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-25 00:49:10 +00:00
hotfix: resolve data directory (#288)
This commit is contained in:
@@ -138,18 +138,18 @@ export const downloadRundown = async () => {
|
|||||||
*/
|
*/
|
||||||
type UploadDataOptions = {
|
type UploadDataOptions = {
|
||||||
onlyRundown?: boolean;
|
onlyRundown?: boolean;
|
||||||
}
|
};
|
||||||
export const uploadData = async (file: string, setProgress: (value: number) => void, options?: UploadDataOptions) => {
|
export const uploadData = async (file: string, setProgress: (value: number) => void, options?: UploadDataOptions) => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('userFile', file);
|
formData.append('userFile', file);
|
||||||
const onlyRundown = options?.onlyRundown;
|
const onlyRundown = options?.onlyRundown || 'false';
|
||||||
await axios
|
await axios
|
||||||
.post(`${ontimeURL}/db?onlyRundown=${onlyRundown}`, formData, {
|
.post(`${ontimeURL}/db?onlyRundown=${onlyRundown}`, formData, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
},
|
},
|
||||||
onUploadProgress: (progressEvent) => {
|
onUploadProgress: (progressEvent) => {
|
||||||
const complete = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
const complete = progressEvent?.total ? Math.round((progressEvent.loaded * 100) / progressEvent.total) : 0;
|
||||||
setProgress(complete);
|
setProgress(complete);
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -27,9 +27,8 @@ export const poll = async (req, res) => {
|
|||||||
export const dbDownload = async (req, res) => {
|
export const dbDownload = async (req, res) => {
|
||||||
const { title } = DataProvider.getEventData();
|
const { title } = DataProvider.getEventData();
|
||||||
const fileTitle = title || 'ontime data';
|
const fileTitle = title || 'ontime data';
|
||||||
const dbInDisk = resolveDbPath();
|
|
||||||
|
|
||||||
res.download(dbInDisk, `${fileTitle}.json`, (err) => {
|
res.download(resolveDbPath, `${fileTitle}.json`, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
res.status(500).send({
|
res.status(500).send({
|
||||||
message: `Could not download the file: ${err}`,
|
message: `Could not download the file: ${err}`,
|
||||||
|
|||||||
@@ -292,8 +292,7 @@ export const validateEvent = (eventArgs) => {
|
|||||||
|
|
||||||
const e = eventArgs;
|
const e = eventArgs;
|
||||||
const d = eventDef;
|
const d = eventDef;
|
||||||
const start =
|
const start = e.timeStart != null && typeof e.timeStart === 'number' ? e.timeStart : d.timeStart;
|
||||||
e.timeStart != null && typeof e.timeStart === 'number' ? e.timeStart : d.timeStart;
|
|
||||||
const end = e.timeEnd != null && typeof e.timeEnd === 'number' ? e.timeEnd : d.timeEnd;
|
const end = e.timeEnd != null && typeof e.timeEnd === 'number' ? e.timeEnd : d.timeEnd;
|
||||||
|
|
||||||
event = {
|
event = {
|
||||||
@@ -344,9 +343,7 @@ export const fileHandler = async (file) => {
|
|||||||
try {
|
try {
|
||||||
const excelData = xlsx
|
const excelData = xlsx
|
||||||
.parse(file, { cellDates: true })
|
.parse(file, { cellDates: true })
|
||||||
.find(
|
.find(({ name }) => name.toLowerCase() === 'ontime' || name.toLowerCase() === 'event schedule');
|
||||||
({ name }) => name.toLowerCase() === 'ontime' || name.toLowerCase() === 'event schedule'
|
|
||||||
);
|
|
||||||
|
|
||||||
// we only look at worksheets called ontime or event schedule
|
// we only look at worksheets called ontime or event schedule
|
||||||
if (excelData?.data) {
|
if (excelData?.data) {
|
||||||
@@ -379,7 +376,7 @@ export const fileHandler = async (file) => {
|
|||||||
return { error: true, message: 'Error parsing JSON file' };
|
return { error: true, message: 'Error parsing JSON file' };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uploadedJson.settings.version === 1) {
|
if (uploadedJson.settings.version === 2) {
|
||||||
try {
|
try {
|
||||||
res.data = await parseJson(uploadedJson);
|
res.data = await parseJson(uploadedJson);
|
||||||
res.message = 'success';
|
res.message = 'success';
|
||||||
|
|||||||
Reference in New Issue
Block a user