mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-07 15:29:10 +00:00
V2 fix offline (#294)
* fix: resolve path to UI build in dev * fix: configure offline fetching
This commit is contained in:
@@ -5,18 +5,14 @@ import { ALIASES } from '../api/apiConstants';
|
|||||||
import { getAliases } from '../api/ontimeApi';
|
import { getAliases } from '../api/ontimeApi';
|
||||||
|
|
||||||
export default function useAliases() {
|
export default function useAliases() {
|
||||||
const {
|
const { data, status, isError, refetch } = useQuery({
|
||||||
data,
|
|
||||||
status,
|
|
||||||
isError,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: ALIASES,
|
queryKey: ALIASES,
|
||||||
queryFn: getAliases,
|
queryFn: getAliases,
|
||||||
placeholderData: [],
|
placeholderData: [],
|
||||||
retry: 5,
|
retry: 5,
|
||||||
retryDelay: attempt => attempt * 2500,
|
retryDelay: (attempt) => attempt * 2500,
|
||||||
refetchInterval: queryRefetchIntervalSlow,
|
refetchInterval: queryRefetchIntervalSlow,
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
return { data, status, isError, refetch };
|
return { data, status, isError, refetch };
|
||||||
|
|||||||
@@ -6,18 +6,14 @@ import { fetchEvent } from '../api/eventApi';
|
|||||||
import { eventDataPlaceholder } from '../models/EventData.type';
|
import { eventDataPlaceholder } from '../models/EventData.type';
|
||||||
|
|
||||||
export default function useEvent() {
|
export default function useEvent() {
|
||||||
const {
|
const { data, status, isError, refetch } = useQuery({
|
||||||
data,
|
|
||||||
status,
|
|
||||||
isError,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: EVENT_TABLE,
|
queryKey: EVENT_TABLE,
|
||||||
queryFn: fetchEvent,
|
queryFn: fetchEvent,
|
||||||
placeholderData: eventDataPlaceholder,
|
placeholderData: eventDataPlaceholder,
|
||||||
retry: 5,
|
retry: 5,
|
||||||
retryDelay: attempt => attempt * 2500,
|
retryDelay: (attempt) => attempt * 2500,
|
||||||
refetchInterval: queryRefetchIntervalSlow,
|
refetchInterval: queryRefetchIntervalSlow,
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
return { data, status, isError, refetch };
|
return { data, status, isError, refetch };
|
||||||
|
|||||||
@@ -6,18 +6,14 @@ import { getInfo } from '../api/ontimeApi';
|
|||||||
import { ontimePlaceholderInfo } from '../models/Info.types';
|
import { ontimePlaceholderInfo } from '../models/Info.types';
|
||||||
|
|
||||||
export default function useInfo() {
|
export default function useInfo() {
|
||||||
const {
|
const { data, status, isError, refetch } = useQuery({
|
||||||
data,
|
|
||||||
status,
|
|
||||||
isError,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: APP_INFO,
|
queryKey: APP_INFO,
|
||||||
queryFn: getInfo,
|
queryFn: getInfo,
|
||||||
placeholderData: ontimePlaceholderInfo,
|
placeholderData: ontimePlaceholderInfo,
|
||||||
retry: 5,
|
retry: 5,
|
||||||
retryDelay: attempt => attempt * 2500,
|
retryDelay: (attempt) => attempt * 2500,
|
||||||
refetchInterval: queryRefetchIntervalSlow,
|
refetchInterval: queryRefetchIntervalSlow,
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
return { data, status, isError, refetch };
|
return { data, status, isError, refetch };
|
||||||
|
|||||||
@@ -6,18 +6,14 @@ import { getOSC } from '../api/ontimeApi';
|
|||||||
import { oscPlaceholderSettings } from '../models/OscSettings.type';
|
import { oscPlaceholderSettings } from '../models/OscSettings.type';
|
||||||
|
|
||||||
export default function useOscSettings() {
|
export default function useOscSettings() {
|
||||||
const {
|
const { data, status, isError, refetch } = useQuery({
|
||||||
data,
|
|
||||||
status,
|
|
||||||
isError,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: OSC_SETTINGS,
|
queryKey: OSC_SETTINGS,
|
||||||
queryFn: getOSC,
|
queryFn: getOSC,
|
||||||
placeholderData: oscPlaceholderSettings,
|
placeholderData: oscPlaceholderSettings,
|
||||||
retry: 5,
|
retry: 5,
|
||||||
retryDelay: attempt => attempt * 2500,
|
retryDelay: (attempt) => attempt * 2500,
|
||||||
refetchInterval: queryRefetchIntervalSlow,
|
refetchInterval: queryRefetchIntervalSlow,
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
return { data, status, isError, refetch };
|
return { data, status, isError, refetch };
|
||||||
|
|||||||
@@ -5,18 +5,14 @@ import { RUNDOWN_TABLE } from '../api/apiConstants';
|
|||||||
import { fetchRundown } from '../api/eventsApi';
|
import { fetchRundown } from '../api/eventsApi';
|
||||||
|
|
||||||
export default function useRundown() {
|
export default function useRundown() {
|
||||||
const {
|
const { data, status, isError, refetch } = useQuery({
|
||||||
data,
|
|
||||||
status,
|
|
||||||
isError,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: RUNDOWN_TABLE,
|
queryKey: RUNDOWN_TABLE,
|
||||||
queryFn: fetchRundown,
|
queryFn: fetchRundown,
|
||||||
placeholderData: [],
|
placeholderData: [],
|
||||||
retry: 5,
|
retry: 5,
|
||||||
retryDelay: attempt => attempt * 2500,
|
retryDelay: (attempt) => attempt * 2500,
|
||||||
refetchInterval: queryRefetchInterval,
|
refetchInterval: queryRefetchInterval,
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
return { data, status, isError, refetch };
|
return { data, status, isError, refetch };
|
||||||
|
|||||||
@@ -6,18 +6,14 @@ import { getSettings } from '../api/ontimeApi';
|
|||||||
import { ontimePlaceholderSettings } from '../models/OntimeSettings.type';
|
import { ontimePlaceholderSettings } from '../models/OntimeSettings.type';
|
||||||
|
|
||||||
export default function useSettings() {
|
export default function useSettings() {
|
||||||
const {
|
const { data, status, isError, refetch } = useQuery({
|
||||||
data,
|
|
||||||
status,
|
|
||||||
isError,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: APP_SETTINGS,
|
queryKey: APP_SETTINGS,
|
||||||
queryFn: getSettings,
|
queryFn: getSettings,
|
||||||
placeholderData: ontimePlaceholderSettings,
|
placeholderData: ontimePlaceholderSettings,
|
||||||
retry: 5,
|
retry: 5,
|
||||||
retryDelay: attempt => attempt * 2500,
|
retryDelay: (attempt) => attempt * 2500,
|
||||||
refetchInterval: queryRefetchIntervalSlow,
|
refetchInterval: queryRefetchIntervalSlow,
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
return { data, status, isError, refetch };
|
return { data, status, isError, refetch };
|
||||||
|
|||||||
@@ -6,18 +6,14 @@ import { getUserFields } from '../api/ontimeApi';
|
|||||||
import { userFieldsPlaceholder } from '../models/UserFields.type';
|
import { userFieldsPlaceholder } from '../models/UserFields.type';
|
||||||
|
|
||||||
export default function useUserFields() {
|
export default function useUserFields() {
|
||||||
const {
|
const { data, status, isError, refetch } = useQuery({
|
||||||
data,
|
|
||||||
status,
|
|
||||||
isError,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: USERFIELDS,
|
queryKey: USERFIELDS,
|
||||||
queryFn: getUserFields,
|
queryFn: getUserFields,
|
||||||
placeholderData: userFieldsPlaceholder,
|
placeholderData: userFieldsPlaceholder,
|
||||||
retry: 5,
|
retry: 5,
|
||||||
retryDelay: attempt => attempt * 2500,
|
retryDelay: (attempt) => attempt * 2500,
|
||||||
refetchInterval: queryRefetchInterval,
|
refetchInterval: queryRefetchInterval,
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
return { data, status, isError, refetch };
|
return { data, status, isError, refetch };
|
||||||
|
|||||||
@@ -6,18 +6,14 @@ import { getView } from '../api/ontimeApi';
|
|||||||
import { viewsSettingsPlaceholder } from '../models/ViewSettings.type';
|
import { viewsSettingsPlaceholder } from '../models/ViewSettings.type';
|
||||||
|
|
||||||
export default function useViewSettings() {
|
export default function useViewSettings() {
|
||||||
const {
|
const { data, status, isError, refetch } = useQuery({
|
||||||
data,
|
|
||||||
status,
|
|
||||||
isError,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: VIEW_SETTINGS,
|
queryKey: VIEW_SETTINGS,
|
||||||
queryFn: getView,
|
queryFn: getView,
|
||||||
placeholderData: viewsSettingsPlaceholder,
|
placeholderData: viewsSettingsPlaceholder,
|
||||||
retry: 5,
|
retry: 5,
|
||||||
retryDelay: attempt => attempt * 2500,
|
retryDelay: (attempt) => attempt * 2500,
|
||||||
refetchInterval: queryRefetchIntervalSlow,
|
refetchInterval: queryRefetchIntervalSlow,
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
return { data, status, isError, refetch };
|
return { data, status, isError, refetch };
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ export const useEventAction = () => {
|
|||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
queryClient.invalidateQueries(RUNDOWN_TABLE);
|
queryClient.invalidateQueries(RUNDOWN_TABLE);
|
||||||
},
|
},
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
type AddOptions = {
|
type AddOptions = {
|
||||||
@@ -43,7 +44,7 @@ export const useEventAction = () => {
|
|||||||
startTimeIsLastEnd?: boolean;
|
startTimeIsLastEnd?: boolean;
|
||||||
lastEventId?: string;
|
lastEventId?: string;
|
||||||
after?: string;
|
after?: string;
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an event to rundown
|
* Adds an event to rundown
|
||||||
@@ -52,7 +53,6 @@ export const useEventAction = () => {
|
|||||||
async (event: Partial<OntimeRundownEntry>, options?: AddOptions) => {
|
async (event: Partial<OntimeRundownEntry>, options?: AddOptions) => {
|
||||||
const newEvent: Partial<OntimeRundownEntry> = { ...event };
|
const newEvent: Partial<OntimeRundownEntry> = { ...event };
|
||||||
|
|
||||||
|
|
||||||
// ************* CHECK OPTIONS
|
// ************* CHECK OPTIONS
|
||||||
// there is an option to pass an index of an array to use as start time
|
// there is an option to pass an index of an array to use as start time
|
||||||
// only events have options
|
// only events have options
|
||||||
@@ -91,7 +91,7 @@ export const useEventAction = () => {
|
|||||||
// @ts-expect-error we know that the event here is one of the defined types
|
// @ts-expect-error we know that the event here is one of the defined types
|
||||||
await _addEventMutation.mutateAsync(newEvent);
|
await _addEventMutation.mutateAsync(newEvent);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if(!axios.isAxiosError(error)){
|
if (!axios.isAxiosError(error)) {
|
||||||
emitError(`Error fetching data: ${(error as AxiosError).message}`);
|
emitError(`Error fetching data: ${(error as AxiosError).message}`);
|
||||||
} else {
|
} else {
|
||||||
emitError(`Error fetching data: ${error}`);
|
emitError(`Error fetching data: ${error}`);
|
||||||
@@ -130,6 +130,7 @@ export const useEventAction = () => {
|
|||||||
onSettled: async () => {
|
onSettled: async () => {
|
||||||
await queryClient.invalidateQueries([RUNDOWN_TABLE_KEY]);
|
await queryClient.invalidateQueries([RUNDOWN_TABLE_KEY]);
|
||||||
},
|
},
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,12 +141,11 @@ export const useEventAction = () => {
|
|||||||
try {
|
try {
|
||||||
await _updateEventMutation.mutateAsync(event);
|
await _updateEventMutation.mutateAsync(event);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if(!axios.isAxiosError(error)){
|
if (!axios.isAxiosError(error)) {
|
||||||
emitError(`Error updating event: ${(error as AxiosError).message}`);
|
emitError(`Error updating event: ${(error as AxiosError).message}`);
|
||||||
} else {
|
} else {
|
||||||
emitError(`Error updating event: ${error}`);
|
emitError(`Error updating event: ${error}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[_updateEventMutation, emitError],
|
[_updateEventMutation, emitError],
|
||||||
@@ -182,6 +182,7 @@ export const useEventAction = () => {
|
|||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
queryClient.invalidateQueries(RUNDOWN_TABLE);
|
queryClient.invalidateQueries(RUNDOWN_TABLE);
|
||||||
},
|
},
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,8 +192,8 @@ export const useEventAction = () => {
|
|||||||
async (eventId: string) => {
|
async (eventId: string) => {
|
||||||
try {
|
try {
|
||||||
await _deleteEventMutation.mutateAsync(eventId);
|
await _deleteEventMutation.mutateAsync(eventId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if(!axios.isAxiosError(error)){
|
if (!axios.isAxiosError(error)) {
|
||||||
emitError(`Error deleting event: ${(error as AxiosError).message}`);
|
emitError(`Error deleting event: ${(error as AxiosError).message}`);
|
||||||
} else {
|
} else {
|
||||||
emitError(`Error deleting event: ${error}`);
|
emitError(`Error deleting event: ${error}`);
|
||||||
@@ -231,6 +232,7 @@ export const useEventAction = () => {
|
|||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
queryClient.invalidateQueries(RUNDOWN_TABLE);
|
queryClient.invalidateQueries(RUNDOWN_TABLE);
|
||||||
},
|
},
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -240,7 +242,7 @@ export const useEventAction = () => {
|
|||||||
try {
|
try {
|
||||||
await _deleteAllEventsMutation.mutateAsync();
|
await _deleteAllEventsMutation.mutateAsync();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if(!axios.isAxiosError(error)){
|
if (!axios.isAxiosError(error)) {
|
||||||
emitError(`Error deleting events: ${(error as AxiosError).message}`);
|
emitError(`Error deleting events: ${(error as AxiosError).message}`);
|
||||||
} else {
|
} else {
|
||||||
emitError(`Error deleting events: ${error}`);
|
emitError(`Error deleting events: ${error}`);
|
||||||
@@ -257,6 +259,7 @@ export const useEventAction = () => {
|
|||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
queryClient.invalidateQueries(RUNDOWN_TABLE);
|
queryClient.invalidateQueries(RUNDOWN_TABLE);
|
||||||
},
|
},
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -267,7 +270,7 @@ export const useEventAction = () => {
|
|||||||
try {
|
try {
|
||||||
await _applyDelayMutation.mutateAsync(delayEventId);
|
await _applyDelayMutation.mutateAsync(delayEventId);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if(!axios.isAxiosError(error)){
|
if (!axios.isAxiosError(error)) {
|
||||||
emitError(`Error applying delay: ${(error as AxiosError).message}`);
|
emitError(`Error applying delay: ${(error as AxiosError).message}`);
|
||||||
} else {
|
} else {
|
||||||
emitError(`Error applying delay: ${error}`);
|
emitError(`Error applying delay: ${error}`);
|
||||||
@@ -310,6 +313,7 @@ export const useEventAction = () => {
|
|||||||
onSettled: () => {
|
onSettled: () => {
|
||||||
queryClient.invalidateQueries(RUNDOWN_TABLE);
|
queryClient.invalidateQueries(RUNDOWN_TABLE);
|
||||||
},
|
},
|
||||||
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,7 +329,7 @@ export const useEventAction = () => {
|
|||||||
};
|
};
|
||||||
await _reorderEventMutation.mutateAsync(reorderObject);
|
await _reorderEventMutation.mutateAsync(reorderObject);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if(!axios.isAxiosError(error)){
|
if (!axios.isAxiosError(error)) {
|
||||||
emitError(`Error re-ordering event: ${(error as AxiosError).message}`);
|
emitError(`Error re-ordering event: ${(error as AxiosError).message}`);
|
||||||
} else {
|
} else {
|
||||||
emitError(`Error re-ordering event: ${error}`);
|
emitError(`Error re-ordering event: ${error}`);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { join, resolve } from 'path';
|
|||||||
|
|
||||||
import { initiateOSC, shutdownOSCServer } from './controllers/OscController.js';
|
import { initiateOSC, shutdownOSCServer } from './controllers/OscController.js';
|
||||||
import { initSentry } from './modules/sentry.js';
|
import { initSentry } from './modules/sentry.js';
|
||||||
import { currentDirectory, environment, isProduction, resolvedPath, uiPath } from './setup.js';
|
import { currentDirectory, environment, isProduction, resolvedPath } from './setup.js';
|
||||||
import { ONTIME_VERSION } from './ONTIME_VERSION.js';
|
import { ONTIME_VERSION } from './ONTIME_VERSION.js';
|
||||||
import { OSCSettings } from 'ontime-types';
|
import { OSCSettings } from 'ontime-types';
|
||||||
|
|
||||||
@@ -62,10 +62,13 @@ app.use('/playback', playbackRouter);
|
|||||||
app.use('/external', express.static(join(currentDirectory, 'external')));
|
app.use('/external', express.static(join(currentDirectory, 'external')));
|
||||||
|
|
||||||
// serve static - react, in test mode we fetch the React app from module
|
// serve static - react, in test mode we fetch the React app from module
|
||||||
app.use(express.static(join(currentDirectory, resolvedPath(), uiPath)));
|
const newpath = join(currentDirectory, resolvedPath());
|
||||||
|
console.log('serving content at ', newpath);
|
||||||
|
|
||||||
|
app.use(express.static(join(currentDirectory, resolvedPath())));
|
||||||
|
|
||||||
app.get('*', (req, res) => {
|
app.get('*', (req, res) => {
|
||||||
res.sendFile(resolve(currentDirectory, resolvedPath(), uiPath, 'index.html'));
|
res.sendFile(resolve(currentDirectory, resolvedPath(), 'index.html'));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Implement catch all
|
// Implement catch all
|
||||||
|
|||||||
@@ -40,10 +40,9 @@ export const isProduction = env === 'production' && !isTest;
|
|||||||
|
|
||||||
// =================================================
|
// =================================================
|
||||||
// resolve path to external
|
// resolve path to external
|
||||||
const productionPath = '../../Resources/extraResources/';
|
const productionPath = '../../Resources/extraResources/client';
|
||||||
const devPath = '../../';
|
const devPath = '../../client/build/';
|
||||||
|
|
||||||
export const uiPath = 'client/';
|
|
||||||
export const resolvedPath = (): string => (isProduction ? productionPath : devPath);
|
export const resolvedPath = (): string => (isProduction ? productionPath : devPath);
|
||||||
|
|
||||||
// resolve file URL in both CJS and ESM (build and dev)
|
// resolve file URL in both CJS and ESM (build and dev)
|
||||||
|
|||||||
Reference in New Issue
Block a user