feature/IO-3205-Paint-Scale-Integrations: Checkpoint

This commit is contained in:
Dave Richer
2025-04-28 11:29:35 -04:00
parent cf8a19575f
commit fb24eafcc8
4 changed files with 33 additions and 21 deletions

View File

@@ -373,17 +373,17 @@ app.whenReady().then(async () => {
} }
}); });
//Dynamically load ipcMain handlers once ready. //Dynamically load ipcMain handlers once ready.
try { try {
// Replace 'path/to/your/file' with the actual path to your file
const module = await import("./ipc/ipcMainConfig"); const module = await import("./ipc/ipcMainConfig");
log.debug("Successfully loaded ipcMainConfig");
// You can now use anything exported from the module // Initialize cron tasks after loading ipcMainConfig
// For example: await module.initializeCronTasks();
// module.someFunction() log.info("Cron tasks initialized successfully");
log.debug("Successfully loaded ipcMainConfig", module);
} catch (error) { } catch (error) {
log.error("Failed to load ipcMainConfig", { log.error("Failed to load ipcMainConfig or initialize cron tasks", {
...ErrorTypeCheck(error), ...ErrorTypeCheck(error),
}); });
} }

View File

@@ -101,6 +101,25 @@ interface GraphQLResponse {
}>; }>;
} }
const initializeCronTasks = async () => {
try {
// Fetch input and output configurations
const inputConfigs = await SettingsPaintScaleInputConfigsGet();
const outputConfigs = await SettingsPaintScaleOutputConfigsGet();
// Start input cron tasks
await handlePaintScaleInputCron(inputConfigs);
log.info("Initialized input cron tasks on app startup");
// Start output cron tasks
await handlePaintScaleOutputCron(outputConfigs);
log.info("Initialized output cron tasks on app startup");
} catch (error) {
log.error("Error initializing cron tasks on app startup:", error);
}
};
// Log all IPC messages and their payloads // Log all IPC messages and their payloads
const logIpcMessages = (): void => { const logIpcMessages = (): void => {
Object.keys(ipcTypes.toMain).forEach((key) => { Object.keys(ipcTypes.toMain).forEach((key) => {
@@ -171,6 +190,7 @@ const inputTypeHandlers: Record<
(store.get("app.bodyshop") as BodyShop)?.shopname || "", (store.get("app.bodyshop") as BodyShop)?.shopname || "",
); );
// TODO Clear up how to fetch API URL
const response = await axios.post( const response = await axios.post(
"https://your-api-base-url/mixdata/upload", "https://your-api-base-url/mixdata/upload",
formData, formData,
@@ -610,4 +630,6 @@ ipcMain.on(ipcTypes.toMain.updates.download, () => {
}); });
}); });
export { initializeCronTasks };
logIpcMessages(); logIpcMessages();

View File

@@ -10,12 +10,8 @@ import {
StartWatcher, StartWatcher,
StopWatcher, StopWatcher,
} from "../watcher/watcher"; } from "../watcher/watcher";
import { PaintScaleConfig } from "./paintScale";
interface PaintScaleConfig {
id: string;
path: string | null;
type: string;
}
// Initialize paint scale input configs in store if not set // Initialize paint scale input configs in store if not set
if (!Store.get("settings.paintScaleInputConfigs")) { if (!Store.get("settings.paintScaleInputConfigs")) {
@@ -136,7 +132,7 @@ const SettingEmsOutFilePathSet = async (): Promise<string> => {
}; };
const SettingsPaintScaleInputConfigsGet = async ( const SettingsPaintScaleInputConfigsGet = async (
_event: IpcMainInvokeEvent, _event?: IpcMainInvokeEvent,
): Promise<PaintScaleConfig[]> => { ): Promise<PaintScaleConfig[]> => {
try { try {
const configs = Store.get("settings.paintScaleInputConfigs") as PaintScaleConfig[]; const configs = Store.get("settings.paintScaleInputConfigs") as PaintScaleConfig[];
@@ -188,7 +184,7 @@ const SettingsPaintScaleInputPathSet = async (
}; };
const SettingsPaintScaleOutputConfigsGet = async ( const SettingsPaintScaleOutputConfigsGet = async (
_event: IpcMainInvokeEvent, _event?: IpcMainInvokeEvent,
): Promise<PaintScaleConfig[]> => { ): Promise<PaintScaleConfig[]> => {
try { try {
const configs = Store.get("settings.paintScaleOutputConfigs") as PaintScaleConfig[]; const configs = Store.get("settings.paintScaleOutputConfigs") as PaintScaleConfig[];

View File

@@ -1,17 +1,11 @@
// src/types/paintScale.ts // src/types/paintScale.ts
export enum PaintScaleType { export enum PaintScaleType {
PPG = 'PPG', PPG = 'PPG',
// Add other types as needed
} }
export interface PaintScaleConfig { export interface PaintScaleConfig {
id: string; id: string;
path: string | null; path?: string;
type: PaintScaleType; type: PaintScaleType;
pollingInterval: number; pollingInterval: number;
} }
export const paintScaleTypeOptions = [
{ value: PaintScaleType.PPG, label: 'PPG' },
// Add other options as needed
];