Merge branch '1.0.6'
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "bodyshop-desktop",
|
"name": "bodyshop-desktop",
|
||||||
"version": "1.0.5-alpha.2",
|
"version": "1.0.6-alpha.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "bodyshop-desktop",
|
"name": "bodyshop-desktop",
|
||||||
"version": "1.0.5-alpha.2",
|
"version": "1.0.6-alpha.1",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apollo/client": "^3.13.6",
|
"@apollo/client": "^3.13.6",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bodyshop-desktop",
|
"name": "bodyshop-desktop",
|
||||||
"version": "1.0.5",
|
"version": "1.0.6",
|
||||||
"description": "Shop Management System Partner",
|
"description": "Shop Management System Partner",
|
||||||
"main": "./out/main/index.js",
|
"main": "./out/main/index.js",
|
||||||
"author": "Convenient Brands, LLC",
|
"author": "Convenient Brands, LLC",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const handlePartsPriceChangeRequest = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
//Route handler here only.
|
//Route handler here only.
|
||||||
|
|
||||||
const { job } = req.body as { job: PpcJob };
|
const job = req.body as PpcJob;
|
||||||
try {
|
try {
|
||||||
await generatePartsPriceChange(job);
|
await generatePartsPriceChange(job);
|
||||||
res.status(200).json({ success: true });
|
res.status(200).json({ success: true });
|
||||||
|
|||||||
@@ -12,10 +12,7 @@ async function checkForAppUpdatesContinuously(): Promise<void> {
|
|||||||
}
|
}
|
||||||
async function checkForAppUpdates(): Promise<void> {
|
async function checkForAppUpdates(): Promise<void> {
|
||||||
await setReleaseChannel();
|
await setReleaseChannel();
|
||||||
autoUpdater.checkForUpdatesAndNotify({
|
autoUpdater.checkForUpdates();
|
||||||
title: "Shop Partner Update",
|
|
||||||
body: "A new version of Shop Partner is available. Click to update.",
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { checkForAppUpdates, checkForAppUpdatesContinuously };
|
export { checkForAppUpdates, checkForAppUpdatesContinuously };
|
||||||
|
|||||||
@@ -1,25 +1,33 @@
|
|||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from "react";
|
||||||
import ipcTypes from '../../../../../util/ipcTypes.json';
|
import ipcTypes from "../../../../../util/ipcTypes.json";
|
||||||
import { PaintScaleConfig, PaintScaleType } from '../../../../../util/types/paintScale';
|
import {
|
||||||
|
PaintScaleConfig,
|
||||||
|
PaintScaleType,
|
||||||
|
} from "../../../../../util/types/paintScale";
|
||||||
import { message } from "antd";
|
import { message } from "antd";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
type ConfigType = 'input' | 'output';
|
type ConfigType = "input" | "output";
|
||||||
|
|
||||||
export const usePaintScaleConfig = (configType: ConfigType) => {
|
export const usePaintScaleConfig = (configType: ConfigType) => {
|
||||||
const [paintScaleConfigs, setPaintScaleConfigs] = useState<PaintScaleConfig[]>([]);
|
const [paintScaleConfigs, setPaintScaleConfigs] = useState<
|
||||||
|
PaintScaleConfig[]
|
||||||
|
>([]);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
// Get the appropriate IPC methods based on config type
|
// Get the appropriate IPC methods based on config type
|
||||||
const getConfigsMethod = configType === 'input'
|
const getConfigsMethod =
|
||||||
|
configType === "input"
|
||||||
? ipcTypes.toMain.settings.paintScale.getInputConfigs
|
? ipcTypes.toMain.settings.paintScale.getInputConfigs
|
||||||
: ipcTypes.toMain.settings.paintScale.getOutputConfigs;
|
: ipcTypes.toMain.settings.paintScale.getOutputConfigs;
|
||||||
|
|
||||||
const setConfigsMethod = configType === 'input'
|
const setConfigsMethod =
|
||||||
|
configType === "input"
|
||||||
? ipcTypes.toMain.settings.paintScale.setInputConfigs
|
? ipcTypes.toMain.settings.paintScale.setInputConfigs
|
||||||
: ipcTypes.toMain.settings.paintScale.setOutputConfigs;
|
: ipcTypes.toMain.settings.paintScale.setOutputConfigs;
|
||||||
|
|
||||||
const setPathMethod = configType === 'input'
|
const setPathMethod =
|
||||||
|
configType === "input"
|
||||||
? ipcTypes.toMain.settings.paintScale.setInputPath
|
? ipcTypes.toMain.settings.paintScale.setInputPath
|
||||||
: ipcTypes.toMain.settings.paintScale.setOutputPath;
|
: ipcTypes.toMain.settings.paintScale.setOutputPath;
|
||||||
|
|
||||||
@@ -29,15 +37,19 @@ export const usePaintScaleConfig = (configType: ConfigType) => {
|
|||||||
.invoke(getConfigsMethod)
|
.invoke(getConfigsMethod)
|
||||||
.then((configs: PaintScaleConfig[]) => {
|
.then((configs: PaintScaleConfig[]) => {
|
||||||
// Ensure all configs have a pollingInterval and type (for backward compatibility)
|
// Ensure all configs have a pollingInterval and type (for backward compatibility)
|
||||||
const updatedConfigs = configs.map(config => ({
|
const defaultPolling = configType === "input" ? 1440 : 60;
|
||||||
|
const updatedConfigs = configs.map((config) => ({
|
||||||
...config,
|
...config,
|
||||||
pollingInterval: config.pollingInterval || 1440, // Default to 1440 seconds
|
pollingInterval: config.pollingInterval || defaultPolling, // Default to 1440 for input, 60 for output
|
||||||
type: config.type || PaintScaleType.PPG, // Default type if missing
|
type: config.type || PaintScaleType.PPG, // Default type if missing
|
||||||
}));
|
}));
|
||||||
setPaintScaleConfigs(updatedConfigs || []);
|
setPaintScaleConfigs(updatedConfigs || []);
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(`Failed to load paint scale ${configType} configs:`, error);
|
console.error(
|
||||||
|
`Failed to load paint scale ${configType} configs:`,
|
||||||
|
error,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}, [getConfigsMethod]);
|
}, [getConfigsMethod]);
|
||||||
|
|
||||||
@@ -47,25 +59,40 @@ export const usePaintScaleConfig = (configType: ConfigType) => {
|
|||||||
.invoke(setConfigsMethod, configs)
|
.invoke(setConfigsMethod, configs)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// Notify main process to update cron job
|
// Notify main process to update cron job
|
||||||
if (configType === 'input') {
|
if (configType === "input") {
|
||||||
window.electron.ipcRenderer.send(ipcTypes.toMain.settings.paintScale.updateInputCron, configs);
|
window.electron.ipcRenderer.send(
|
||||||
} else if (configType === 'output') {
|
ipcTypes.toMain.settings.paintScale.updateInputCron,
|
||||||
window.electron.ipcRenderer.send(ipcTypes.toMain.settings.paintScale.updateOutputCron, configs);
|
configs,
|
||||||
|
);
|
||||||
|
} else if (configType === "output") {
|
||||||
|
window.electron.ipcRenderer.send(
|
||||||
|
ipcTypes.toMain.settings.paintScale.updateOutputCron,
|
||||||
|
configs,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error(`Failed to save paint scale ${configType} configs:`, error);
|
console.error(
|
||||||
|
`Failed to save paint scale ${configType} configs:`,
|
||||||
|
error,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// New helper to check if a path is unique across input and output configs
|
// New helper to check if a path is unique across input and output configs
|
||||||
const checkPathUnique = async (newPath: string): Promise<boolean> => {
|
const checkPathUnique = async (newPath: string): Promise<boolean> => {
|
||||||
try {
|
try {
|
||||||
const inputConfigs: PaintScaleConfig[] = await window.electron.ipcRenderer.invoke(ipcTypes.toMain.settings.paintScale.getInputConfigs);
|
const inputConfigs: PaintScaleConfig[] =
|
||||||
const outputConfigs: PaintScaleConfig[] = await window.electron.ipcRenderer.invoke(ipcTypes.toMain.settings.paintScale.getOutputConfigs);
|
await window.electron.ipcRenderer.invoke(
|
||||||
|
ipcTypes.toMain.settings.paintScale.getInputConfigs,
|
||||||
|
);
|
||||||
|
const outputConfigs: PaintScaleConfig[] =
|
||||||
|
await window.electron.ipcRenderer.invoke(
|
||||||
|
ipcTypes.toMain.settings.paintScale.getOutputConfigs,
|
||||||
|
);
|
||||||
const allConfigs = [...inputConfigs, ...outputConfigs];
|
const allConfigs = [...inputConfigs, ...outputConfigs];
|
||||||
// Allow updating the current config even if its current value equals newPath.
|
// Allow updating the current config even if its current value equals newPath.
|
||||||
return !allConfigs.some(config => config.path === newPath);
|
return !allConfigs.some((config) => config.path === newPath);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to check unique path:", error);
|
console.error("Failed to check unique path:", error);
|
||||||
return false;
|
return false;
|
||||||
@@ -74,10 +101,11 @@ export const usePaintScaleConfig = (configType: ConfigType) => {
|
|||||||
|
|
||||||
// Handle adding a new paint scale config
|
// Handle adding a new paint scale config
|
||||||
const handleAddConfig = (type: PaintScaleType) => {
|
const handleAddConfig = (type: PaintScaleType) => {
|
||||||
|
const defaultPolling = configType === "input" ? 1440 : 60;
|
||||||
const newConfig: PaintScaleConfig = {
|
const newConfig: PaintScaleConfig = {
|
||||||
id: Date.now().toString(),
|
id: Date.now().toString(),
|
||||||
type,
|
type,
|
||||||
pollingInterval: 1440, // Default to 1440 seconds
|
pollingInterval: defaultPolling, // Default to 1440 for input, 60 for output
|
||||||
};
|
};
|
||||||
const updatedConfigs = [...paintScaleConfigs, newConfig];
|
const updatedConfigs = [...paintScaleConfigs, newConfig];
|
||||||
setPaintScaleConfigs(updatedConfigs);
|
setPaintScaleConfigs(updatedConfigs);
|
||||||
@@ -86,7 +114,9 @@ export const usePaintScaleConfig = (configType: ConfigType) => {
|
|||||||
|
|
||||||
// Handle removing a config
|
// Handle removing a config
|
||||||
const handleRemoveConfig = (id: string) => {
|
const handleRemoveConfig = (id: string) => {
|
||||||
const updatedConfigs = paintScaleConfigs.filter((config) => config.id !== id);
|
const updatedConfigs = paintScaleConfigs.filter(
|
||||||
|
(config) => config.id !== id,
|
||||||
|
);
|
||||||
setPaintScaleConfigs(updatedConfigs);
|
setPaintScaleConfigs(updatedConfigs);
|
||||||
saveConfigs(updatedConfigs);
|
saveConfigs(updatedConfigs);
|
||||||
};
|
};
|
||||||
@@ -94,7 +124,10 @@ export const usePaintScaleConfig = (configType: ConfigType) => {
|
|||||||
// Handle path selection (modified to check directory uniqueness)
|
// Handle path selection (modified to check directory uniqueness)
|
||||||
const handlePathChange = async (id: string) => {
|
const handlePathChange = async (id: string) => {
|
||||||
try {
|
try {
|
||||||
const path: string | null = await window.electron.ipcRenderer.invoke(setPathMethod, id);
|
const path: string | null = await window.electron.ipcRenderer.invoke(
|
||||||
|
setPathMethod,
|
||||||
|
id,
|
||||||
|
);
|
||||||
if (path) {
|
if (path) {
|
||||||
const isUnique = await checkPathUnique(path);
|
const isUnique = await checkPathUnique(path);
|
||||||
if (!isUnique) {
|
if (!isUnique) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const SettingsPaintScaleInputPaths = (): JSX.Element => {
|
|||||||
handleRemoveConfig,
|
handleRemoveConfig,
|
||||||
handlePathChange,
|
handlePathChange,
|
||||||
handlePollingIntervalChange,
|
handlePollingIntervalChange,
|
||||||
} = usePaintScaleConfig("input");
|
} = usePaintScaleConfig("output");
|
||||||
|
|
||||||
const [isModalVisible, setIsModalVisible] = useState(false);
|
const [isModalVisible, setIsModalVisible] = useState(false);
|
||||||
const [selectedType, setSelectedType] = useState<PaintScaleType | null>(null);
|
const [selectedType, setSelectedType] = useState<PaintScaleType | null>(null);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ const SettingsPaintScaleOutputPaths = (): JSX.Element => {
|
|||||||
handleRemoveConfig,
|
handleRemoveConfig,
|
||||||
handlePathChange,
|
handlePathChange,
|
||||||
handlePollingIntervalChange,
|
handlePollingIntervalChange,
|
||||||
} = usePaintScaleConfig("output");
|
} = usePaintScaleConfig("input");
|
||||||
|
|
||||||
const [isModalVisible, setIsModalVisible] = useState(false);
|
const [isModalVisible, setIsModalVisible] = useState(false);
|
||||||
const [selectedType, setSelectedType] = useState<PaintScaleType | null>(null);
|
const [selectedType, setSelectedType] = useState<PaintScaleType | null>(null);
|
||||||
|
|||||||
Reference in New Issue
Block a user