Compare commits
26 Commits
feature/IO
...
1.0.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd9fa67087 | ||
|
|
e9dd8ff760 | ||
|
|
1c839ee3f8 | ||
|
|
9fdd88526c | ||
|
|
d5b40ef6f4 | ||
|
|
59162e3028 | ||
|
|
f41728550c | ||
|
|
3b918d3fcb | ||
|
|
cf18acc661 | ||
|
|
be079a2e48 | ||
|
|
9b90b780ef | ||
|
|
a19026e048 | ||
|
|
47608a8cde | ||
|
|
a9fdf327b6 | ||
|
|
bd63af69e2 | ||
|
|
6fa97a081f | ||
|
|
be0eafec7e | ||
|
|
6e4c8b5558 | ||
|
|
fb106ec87f | ||
|
|
2a5c2b43e1 | ||
|
|
eab52bf8c1 | ||
|
|
cd5ddc4fa1 | ||
|
|
3f2501cd90 | ||
|
|
019e1b161b | ||
|
|
cdad47b82f | ||
|
|
2953aa420e |
@@ -2,8 +2,8 @@ VITE_FIREBASE_CONFIG={"apiKey":"AIzaSyDPLT8GiDHDR1R4nI66Qi0BY1aYviDPioc","authDo
|
||||
VITE_GRAPHQL_ENDPOINT=https://db.dev.imex.online/v1/graphql
|
||||
VITE_FIREBASE_CONFIG_TEST={ "apiKey":"AIzaSyBw7_GTy7GtQyfkIRPVrWHEGKfcqeyXw0c", "authDomain":"imex-test.firebaseapp.com", "projectId":"imex-test", "storageBucket":"imex-test.appspot.com", "messagingSenderId":"991923618608", "appId":"1:991923618608:web:633437569cdad78299bef5", "measurementId":"G-TW0XLZEH18"}
|
||||
VITE_GRAPHQL_ENDPOINT_TEST=https://db.test.bodyshop.app/v1/graphql
|
||||
VITE_COMPANY=IMEX
|
||||
VITE_COMPANY=ROME
|
||||
VITE_FE_URL=https://imex.online
|
||||
VITE_FE_URL_TEST=https://test.imex.online
|
||||
VITE_API_URL="http://localhost:4000"
|
||||
VITE_API_TEST_URL="http://api.test.imex.online"
|
||||
VITE_API_TEST_URL="https://api.test.imex.online"
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -14,5 +14,6 @@ out
|
||||
|
||||
# Build Files
|
||||
macbuild.sh
|
||||
deploy.ps1
|
||||
# Sentry Config File
|
||||
.env.sentry-build-plugin
|
||||
|
||||
3
.vscode/launch.json
vendored
3
.vscode/launch.json
vendored
@@ -13,7 +13,8 @@
|
||||
"runtimeArgs": ["--sourcemap"],
|
||||
"env": {
|
||||
"REMOTE_DEBUGGING_PORT": "9222"
|
||||
}
|
||||
},
|
||||
"experimentalNetworking": "off"
|
||||
},
|
||||
{
|
||||
"name": "Debug Renderer Process",
|
||||
|
||||
17
build/com.convenient-brands.bodyshop-desktop.keepalive.plist
Normal file
17
build/com.convenient-brands.bodyshop-desktop.keepalive.plist
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>com.convenientbrands.bodyshop-desktop.keepalive</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>Shop Partner Keep Alive</string>
|
||||
<string>imexmedia://keep-alive</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>StartInterval</key>
|
||||
<integer>${KEEP_ALIVE_INTERVAL_SECONDS}</integer>
|
||||
</dict>
|
||||
</plist>
|
||||
53
deploy/set-artifact-name.js
Normal file
53
deploy/set-artifact-name.js
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env node
|
||||
// Cross-platform script to set artifact naming based on version
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
// Read the package.json to get the version
|
||||
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||
const version = packageJson.version;
|
||||
|
||||
console.log(`Current version: ${version}`);
|
||||
|
||||
// Determine the artifact suffix based on the version
|
||||
let artifactSuffix = '';
|
||||
|
||||
if (version.includes('alpha')) {
|
||||
artifactSuffix = `alpha-${version}-`;
|
||||
console.log(`Detected alpha version, setting suffix to: ${artifactSuffix}`);
|
||||
} else if (version.includes('beta')) {
|
||||
artifactSuffix = `beta-${version}-`;
|
||||
console.log(`Detected beta version, setting suffix to: ${artifactSuffix}`);
|
||||
} else {
|
||||
artifactSuffix = '';
|
||||
console.log('Detected release version, no suffix will be added');
|
||||
}
|
||||
|
||||
// Set the environment variable for the current process
|
||||
process.env.ARTIFACT_SUFFIX = artifactSuffix;
|
||||
|
||||
console.log(`ARTIFACT_SUFFIX set to: '${artifactSuffix}'`);
|
||||
|
||||
// If arguments are passed, execute the remaining command with the environment variable set
|
||||
if (process.argv.length > 2) {
|
||||
const command = process.argv[2];
|
||||
const args = process.argv.slice(3);
|
||||
|
||||
console.log(`Executing: ${command} ${args.join(' ')}`);
|
||||
|
||||
const child = spawn(command, args, {
|
||||
stdio: 'inherit',
|
||||
env: { ...process.env, ARTIFACT_SUFFIX: artifactSuffix },
|
||||
shell: true
|
||||
});
|
||||
|
||||
child.on('close', (code) => {
|
||||
process.exit(code);
|
||||
});
|
||||
} else {
|
||||
// Just setting the environment variable
|
||||
console.log('Environment variable set. Use this script with additional arguments to run commands with the variable set.');
|
||||
}
|
||||
38
deploy/set-artifact-name.ps1
Normal file
38
deploy/set-artifact-name.ps1
Normal file
@@ -0,0 +1,38 @@
|
||||
# PowerShell script to set artifact naming based on version
|
||||
param(
|
||||
[string]$ConfigType = "imex"
|
||||
)
|
||||
|
||||
# Read the package.json to get the version
|
||||
$packageJsonPath = Join-Path $PSScriptRoot "..\package.json"
|
||||
$packageJson = Get-Content $packageJsonPath | ConvertFrom-Json
|
||||
$version = $packageJson.version
|
||||
|
||||
Write-Host "Current version: $version"
|
||||
|
||||
# Determine the artifact suffix based on the version
|
||||
$artifactSuffix = ""
|
||||
|
||||
if ($version -match "alpha") {
|
||||
$artifactSuffix = "alpha-${version}-"
|
||||
Write-Host "Detected alpha version, setting suffix to: $artifactSuffix"
|
||||
}
|
||||
elseif ($version -match "beta") {
|
||||
$artifactSuffix = "beta-${version}-"
|
||||
Write-Host "Detected beta version, setting suffix to: $artifactSuffix"
|
||||
}
|
||||
else {
|
||||
$artifactSuffix = ""
|
||||
Write-Host "Detected release version, no suffix will be added"
|
||||
}
|
||||
|
||||
# Set the environment variable
|
||||
$env:ARTIFACT_SUFFIX = $artifactSuffix
|
||||
|
||||
# Export for the current session
|
||||
[Environment]::SetEnvironmentVariable("ARTIFACT_SUFFIX", $artifactSuffix, "Process")
|
||||
|
||||
Write-Host "ARTIFACT_SUFFIX set to: '$env:ARTIFACT_SUFFIX'"
|
||||
|
||||
# Return the suffix for use in other scripts
|
||||
return $artifactSuffix
|
||||
33
deploy/set-artifact-name.sh
Normal file
33
deploy/set-artifact-name.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
# Bash script to set artifact naming based on version
|
||||
|
||||
# Get the directory where this script is located
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Read the package.json to get the version
|
||||
PACKAGE_JSON_PATH="$SCRIPT_DIR/../package.json"
|
||||
VERSION=$(node -p "require('$PACKAGE_JSON_PATH').version")
|
||||
|
||||
echo "Current version: $VERSION"
|
||||
|
||||
# Determine the artifact suffix based on the version
|
||||
ARTIFACT_SUFFIX=""
|
||||
|
||||
if [[ $VERSION == *"alpha"* ]]; then
|
||||
ARTIFACT_SUFFIX="alpha-${VERSION}-"
|
||||
echo "Detected alpha version, setting suffix to: $ARTIFACT_SUFFIX"
|
||||
elif [[ $VERSION == *"beta"* ]]; then
|
||||
ARTIFACT_SUFFIX="beta-${VERSION}-"
|
||||
echo "Detected beta version, setting suffix to: $ARTIFACT_SUFFIX"
|
||||
else
|
||||
ARTIFACT_SUFFIX=""
|
||||
echo "Detected release version, no suffix will be added"
|
||||
fi
|
||||
|
||||
# Export the environment variable
|
||||
export ARTIFACT_SUFFIX="$ARTIFACT_SUFFIX"
|
||||
|
||||
echo "ARTIFACT_SUFFIX set to: '$ARTIFACT_SUFFIX'"
|
||||
|
||||
# Also write to a temporary file for sourcing in other scripts
|
||||
echo "export ARTIFACT_SUFFIX='$ARTIFACT_SUFFIX'" > "$SCRIPT_DIR/.artifact-suffix.env"
|
||||
64
deploy/test-artifact-naming-cross-platform.js
Normal file
64
deploy/test-artifact-naming-cross-platform.js
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env node
|
||||
// Cross-platform test script to demonstrate artifact naming for different versions
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
console.log('=== Artifact Naming Test (Cross-Platform) ===');
|
||||
console.log('');
|
||||
|
||||
// Get current version
|
||||
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||
const currentVersion = packageJson.version;
|
||||
|
||||
console.log(`Current version: ${currentVersion}`);
|
||||
|
||||
// Function to get artifact suffix
|
||||
function getArtifactSuffix(version) {
|
||||
if (version.includes('alpha')) {
|
||||
return `alpha-${version}-`;
|
||||
} else if (version.includes('beta')) {
|
||||
return `beta-${version}-`;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
// Test scenarios
|
||||
const testVersions = [
|
||||
'1.0.5', // Release version
|
||||
'1.0.5-alpha.2', // Alpha version
|
||||
'1.0.5-beta.1', // Beta version
|
||||
'2.0.0-alpha.1', // Another alpha
|
||||
'1.5.0-beta.3' // Another beta
|
||||
];
|
||||
|
||||
console.log('Test scenarios:');
|
||||
console.log('==================');
|
||||
|
||||
testVersions.forEach(version => {
|
||||
const suffix = getArtifactSuffix(version);
|
||||
|
||||
// Different artifact names for different platforms
|
||||
const windowsArtifact = `imex-partner-${suffix}x64.exe`;
|
||||
const macArtifact = `imex-partner-${suffix}x64.dmg`;
|
||||
const linuxArtifact = `imex-partner-${suffix}x64.AppImage`;
|
||||
|
||||
console.log(`Version: ${version}`);
|
||||
console.log(` Suffix: '${suffix}'`);
|
||||
console.log(` Windows: ${windowsArtifact}`);
|
||||
console.log(` Mac: ${macArtifact}`);
|
||||
console.log(` Linux: ${linuxArtifact}`);
|
||||
console.log('');
|
||||
});
|
||||
|
||||
console.log('Current configuration will produce:');
|
||||
const currentSuffix = getArtifactSuffix(currentVersion);
|
||||
console.log(` Windows: imex-partner-${currentSuffix}x64.exe`);
|
||||
console.log(` Mac: imex-partner-${currentSuffix}x64.dmg`);
|
||||
console.log(` Linux: imex-partner-${currentSuffix}x64.AppImage`);
|
||||
|
||||
console.log('');
|
||||
console.log(`Platform detected: ${process.platform}`);
|
||||
console.log(`Architecture: ${process.arch}`);
|
||||
48
deploy/test-artifact-naming.ps1
Normal file
48
deploy/test-artifact-naming.ps1
Normal file
@@ -0,0 +1,48 @@
|
||||
# Test script to demonstrate artifact naming for different versions
|
||||
Write-Host "=== Artifact Naming Test ==="
|
||||
Write-Host ""
|
||||
|
||||
# Test current version
|
||||
$packageJsonPath = ".\package.json"
|
||||
$packageJson = Get-Content $packageJsonPath | ConvertFrom-Json
|
||||
$currentVersion = $packageJson.version
|
||||
|
||||
Write-Host "Current version: $currentVersion"
|
||||
|
||||
# Function to get artifact suffix
|
||||
function Get-ArtifactSuffix($version) {
|
||||
if ($version -match "alpha") {
|
||||
return "alpha-${version}-"
|
||||
} elseif ($version -match "beta") {
|
||||
return "beta-${version}-"
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
# Test scenarios
|
||||
$testVersions = @(
|
||||
"1.0.5", # Release version
|
||||
"1.0.5-alpha.2", # Alpha version
|
||||
"1.0.5-beta.1", # Beta version
|
||||
"2.0.0-alpha.1", # Another alpha
|
||||
"1.5.0-beta.3" # Another beta
|
||||
)
|
||||
|
||||
Write-Host "Test scenarios:"
|
||||
Write-Host "=================="
|
||||
|
||||
foreach ($version in $testVersions) {
|
||||
$suffix = Get-ArtifactSuffix $version
|
||||
$artifactName = "imex-partner-${suffix}x64.exe"
|
||||
|
||||
Write-Host "Version: $version"
|
||||
Write-Host " Suffix: '$suffix'"
|
||||
Write-Host " Result: $artifactName"
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
Write-Host "Current configuration will produce:"
|
||||
$currentSuffix = Get-ArtifactSuffix $currentVersion
|
||||
$currentArtifact = "imex-partner-${currentSuffix}x64.exe"
|
||||
Write-Host " $currentArtifact"
|
||||
50
deploy/test-artifact-naming.sh
Normal file
50
deploy/test-artifact-naming.sh
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
# Test script to demonstrate artifact naming for different versions on Mac
|
||||
|
||||
echo "=== Artifact Naming Test (Mac) ==="
|
||||
echo ""
|
||||
|
||||
# Get current version
|
||||
PACKAGE_JSON_PATH="./package.json"
|
||||
CURRENT_VERSION=$(node -p "require('$PACKAGE_JSON_PATH').version")
|
||||
|
||||
echo "Current version: $CURRENT_VERSION"
|
||||
|
||||
# Function to get artifact suffix
|
||||
get_artifact_suffix() {
|
||||
local version=$1
|
||||
if [[ $version == *"alpha"* ]]; then
|
||||
echo "alpha-${version}-"
|
||||
elif [[ $version == *"beta"* ]]; then
|
||||
echo "beta-${version}-"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
# Test scenarios
|
||||
TEST_VERSIONS=(
|
||||
"1.0.5" # Release version
|
||||
"1.0.5-alpha.2" # Alpha version
|
||||
"1.0.5-beta.1" # Beta version
|
||||
"2.0.0-alpha.1" # Another alpha
|
||||
"1.5.0-beta.3" # Another beta
|
||||
)
|
||||
|
||||
echo "Test scenarios:"
|
||||
echo "=================="
|
||||
|
||||
for version in "${TEST_VERSIONS[@]}"; do
|
||||
suffix=$(get_artifact_suffix "$version")
|
||||
artifact_name="imex-partner-${suffix}x64.dmg"
|
||||
|
||||
echo "Version: $version"
|
||||
echo " Suffix: '$suffix'"
|
||||
echo " Result: $artifact_name"
|
||||
echo ""
|
||||
done
|
||||
|
||||
echo "Current configuration will produce:"
|
||||
current_suffix=$(get_artifact_suffix "$CURRENT_VERSION")
|
||||
current_artifact="imex-partner-${current_suffix}x64.dmg"
|
||||
echo " $current_artifact"
|
||||
@@ -23,7 +23,7 @@ win:
|
||||
certificateProfileName: ImEXRPS
|
||||
codeSigningAccountName: ImEX
|
||||
nsis:
|
||||
artifactName: ${name}-${version}-setup.${ext}
|
||||
artifactName: imex-partner-${env.ARTIFACT_SUFFIX}${arch}.${ext}
|
||||
shortcutName: ${productName}
|
||||
uninstallDisplayName: ${productName}
|
||||
createDesktopShortcut: always
|
||||
@@ -49,7 +49,7 @@ mac:
|
||||
arch:
|
||||
- x64
|
||||
dmg:
|
||||
artifactName: ${name}-${version}-${arch}.${ext}
|
||||
artifactName: imex-partner-${env.ARTIFACT_SUFFIX}${arch}.${ext}
|
||||
linux:
|
||||
target:
|
||||
- AppImage
|
||||
@@ -59,7 +59,7 @@ linux:
|
||||
category: Utility
|
||||
desktop: scripts/imex-shop-partner.desktop
|
||||
appImage:
|
||||
artifactName: ${name}-${version}.${ext}
|
||||
artifactName: imex-partner-${env.ARTIFACT_SUFFIX}${arch}.${ext}
|
||||
npmRebuild: false
|
||||
publish:
|
||||
provider: s3
|
||||
|
||||
@@ -17,13 +17,13 @@ asarUnpack:
|
||||
- resources/**
|
||||
win:
|
||||
executableName: ShopPartner
|
||||
icon: resources/icon.png
|
||||
icon: resources/ro-icon.png
|
||||
azureSignOptions:
|
||||
endpoint: https://eus.codesigning.azure.net
|
||||
certificateProfileName: ImEXRPS
|
||||
codeSigningAccountName: ImEX
|
||||
nsis:
|
||||
artifactName: ${name}-${version}-setup.${ext}
|
||||
artifactName: rome-partner-${env.ARTIFACT_SUFFIX}${arch}.${ext}
|
||||
shortcutName: ${productName}
|
||||
uninstallDisplayName: ${productName}
|
||||
createDesktopShortcut: always
|
||||
@@ -31,6 +31,7 @@ nsis:
|
||||
mac:
|
||||
entitlementsInherit: build/entitlements.mac.plist
|
||||
category: public.app-category.business
|
||||
icon: resources/ro-icon.png
|
||||
extendInfo:
|
||||
- NSCameraUsageDescription: Application requests access to the device's camera.
|
||||
- NSMicrophoneUsageDescription: Application requests access to the device's microphone.
|
||||
@@ -49,7 +50,7 @@ mac:
|
||||
arch:
|
||||
- x64
|
||||
dmg:
|
||||
artifactName: ${name}-${version}-${arch}.${ext}
|
||||
artifactName: rome-partner-${env.ARTIFACT_SUFFIX}${arch}.${ext}
|
||||
linux:
|
||||
target:
|
||||
- AppImage
|
||||
@@ -59,7 +60,7 @@ linux:
|
||||
category: Utility
|
||||
desktop: scripts/rome-shop-partner.desktop
|
||||
appImage:
|
||||
artifactName: ${name}-${version}.${ext}
|
||||
artifactName: rome-partner-${env.ARTIFACT_SUFFIX}${arch}.${ext}
|
||||
npmRebuild: false
|
||||
publish:
|
||||
provider: s3
|
||||
|
||||
818
package-lock.json
generated
818
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "bodyshop-desktop",
|
||||
"version": "0.0.1-alpha.8",
|
||||
"version": "1.0.5",
|
||||
"description": "Shop Management System Partner",
|
||||
"main": "./out/main/index.js",
|
||||
"author": "Convenient Brands, LLC",
|
||||
@@ -13,17 +13,17 @@
|
||||
"typecheck": "npm run typecheck:node && npm run typecheck:web",
|
||||
"start": "electron-vite preview",
|
||||
"dev": "electron-vite dev",
|
||||
"build:imex": "electron-vite build --mode imex && electron-builder --config electron-builder.imex.yml",
|
||||
"build:rome": "electron-vite build --mode rome && electron-builder --config electron-builder.rome.yml",
|
||||
"build:imex:publish": "electron-vite build --mode imex && electron-builder --config electron-builder.imex.yml --publish always",
|
||||
"build:rome:publish": "electron-vite build --mode rome && electron-builder --config electron-builder.rome.yml --publish always",
|
||||
"build:imex:linux": "electron-vite build --mode imex && electron-builder --config electron-builder.imex.yml --linux",
|
||||
"build:rome:linux": "electron-vite build --mode rome && electron-builder --config electron-builder.rome.yml --linux",
|
||||
"build:imex": "node deploy/set-artifact-name.js electron-vite build --mode imex && node deploy/set-artifact-name.js electron-builder --config electron-builder.imex.yml",
|
||||
"build:rome": "node deploy/set-artifact-name.js electron-vite build --mode rome && node deploy/set-artifact-name.js electron-builder --config electron-builder.rome.yml",
|
||||
"build:imex:publish": "node deploy/set-artifact-name.js electron-vite build --mode imex && node deploy/set-artifact-name.js electron-builder --config electron-builder.imex.yml --publish always",
|
||||
"build:rome:publish": "node deploy/set-artifact-name.js electron-vite build --mode rome && node deploy/set-artifact-name.js electron-builder --config electron-builder.rome.yml --publish always",
|
||||
"build:imex:linux": "node deploy/set-artifact-name.js electron-vite build --mode imex && node deploy/set-artifact-name.js electron-builder --config electron-builder.imex.yml --linux",
|
||||
"build:rome:linux": "node deploy/set-artifact-name.js electron-vite build --mode rome && node deploy/set-artifact-name.js electron-builder --config electron-builder.rome.yml --linux",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"build:unpack": "electron-vite build --mode imex && electron-builder --dir",
|
||||
"build:win": "electron-vite build --mode imex && electron-builder --win",
|
||||
"build:mac": "electron-vite build --mode imex && electron-builder --mac",
|
||||
"build:linux": "electron-vite build --mode imex && electron-builder --linux"
|
||||
"build:unpack": "node deploy/set-artifact-name.js electron-vite build --mode imex && node deploy/set-artifact-name.js electron-builder --dir",
|
||||
"build:win": "node deploy/set-artifact-name.js electron-vite build --mode imex && node deploy/set-artifact-name.js electron-builder --win",
|
||||
"build:mac": "node deploy/set-artifact-name.js electron-vite build --mode imex && node deploy/set-artifact-name.js electron-builder --mac",
|
||||
"build:linux": "node deploy/set-artifact-name.js electron-vite build --mode imex && node deploy/set-artifact-name.js electron-builder --linux"
|
||||
},
|
||||
"dependencies": {
|
||||
"@apollo/client": "^3.13.6",
|
||||
@@ -55,8 +55,10 @@
|
||||
"@types/xml2js": "^0.4.14",
|
||||
"@vitejs/plugin-react": "^4.3.4",
|
||||
"antd": "^5.24.6",
|
||||
"archiver": "^7.0.1",
|
||||
"chokidar": "^4.0.3",
|
||||
"cors": "^2.8.5",
|
||||
"cross-env": "^10.0.0",
|
||||
"dbffile": "^1.12.0",
|
||||
"electron": "^35.1.5",
|
||||
"electron-builder": "^25.1.8",
|
||||
@@ -72,6 +74,7 @@
|
||||
"graphql-request": "^7.1.2",
|
||||
"i18next": "^24.2.3",
|
||||
"lodash": "^4.17.21",
|
||||
"node-cron": "^3.0.3",
|
||||
"playwright": "^1.51.1",
|
||||
"prettier": "^3.5.3",
|
||||
"react": "^19.1.0",
|
||||
@@ -84,7 +87,6 @@
|
||||
"typescript": "^5.8.3",
|
||||
"vite": "6.2.6",
|
||||
"xml2js": "^0.6.2",
|
||||
"xmlbuilder2": "^3.1.1",
|
||||
"node-cron": "^3.0.3"
|
||||
"xmlbuilder2": "^3.1.1"
|
||||
}
|
||||
}
|
||||
|
||||
BIN
resources/ro-icon.png
Normal file
BIN
resources/ro-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 55 KiB |
@@ -182,7 +182,9 @@ const DecodeAD1 = async (
|
||||
if (!rawAd1Data.ownr_ph1 || _.isEmpty(rawAd1Data.ownr_ph1)) {
|
||||
rawAd1Data.ownr_ph1 = rawAd1Data.ownr_ph2;
|
||||
}
|
||||
|
||||
if (rawAd1Data.clm_no === "") {
|
||||
rawAd1Data.clm_no = undefined;
|
||||
}
|
||||
let ownerRecord: OwnerRecordInterface;
|
||||
//Check if the owner information is there. If not, use the insured information as a fallback.
|
||||
if (
|
||||
|
||||
@@ -43,6 +43,7 @@ import { DecodedTtl } from "./decode-ttl.interface";
|
||||
import DecodeVeh from "./decode-veh";
|
||||
import { DecodedVeh } from "./decode-veh.interface";
|
||||
import setAppProgressbar from "../util/setAppProgressBar";
|
||||
import UploadEmsToS3 from "./emsbackup";
|
||||
|
||||
async function ImportJob(filepath: string): Promise<void> {
|
||||
const parsedFilePath = path.parse(filepath);
|
||||
@@ -156,6 +157,7 @@ async function ImportJob(filepath: string): Promise<void> {
|
||||
console.log("Available Job record to upload;", newAvailableJob);
|
||||
|
||||
setAppProgressbar(0.95);
|
||||
if (jobObject.clm_no) {
|
||||
const existingJobRecord: QueryJobByClmNoResult = await client.request(
|
||||
QUERY_JOB_BY_CLM_NO_TYPED,
|
||||
{ clm_no: jobObject.clm_no },
|
||||
@@ -165,6 +167,7 @@ async function ImportJob(filepath: string): Promise<void> {
|
||||
newAvailableJob.issupplement = true;
|
||||
newAvailableJob.jobid = existingJobRecord.jobs[0].id;
|
||||
}
|
||||
}
|
||||
|
||||
const insertRecordResult: InsertAvailableJobResult = await client.request(
|
||||
INSERT_AVAILABLE_JOB_TYPED,
|
||||
@@ -191,6 +194,14 @@ async function ImportJob(filepath: string): Promise<void> {
|
||||
uploadNotification.show();
|
||||
|
||||
log.debug("Job inserted", insertRecordResult);
|
||||
|
||||
UploadEmsToS3({
|
||||
extensionlessFilePath,
|
||||
bodyshopid: newAvailableJob.bodyshopid,
|
||||
ciecaid: jobObject.ciecaid ?? "",
|
||||
clm_no: jobObject.clm_no ?? "",
|
||||
ownr_ln: jobObject.ownr_ln ?? "",
|
||||
});
|
||||
} catch (error) {
|
||||
log.error("Error encountered while decoding job. ", errorTypeCheck(error));
|
||||
const uploadNotificationFailure = new Notification({
|
||||
|
||||
104
src/main/decoder/emsbackup.ts
Normal file
104
src/main/decoder/emsbackup.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
import axios from "axios";
|
||||
import archiver from "archiver";
|
||||
import errorTypeCheck from "../../util/errorTypeCheck";
|
||||
import { UUID } from "crypto";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import stream from "stream";
|
||||
import { getTokenFromRenderer } from "../graphql/graphql-client";
|
||||
import store from "../store/store";
|
||||
|
||||
async function UploadEmsToS3({
|
||||
extensionlessFilePath,
|
||||
bodyshopid,
|
||||
clm_no,
|
||||
ciecaid,
|
||||
ownr_ln,
|
||||
}: {
|
||||
extensionlessFilePath: string;
|
||||
bodyshopid: UUID;
|
||||
clm_no: string;
|
||||
ciecaid: string;
|
||||
ownr_ln: string;
|
||||
}): Promise<boolean> {
|
||||
// This function is a placeholder for the actual upload logic
|
||||
try {
|
||||
const directory = path.dirname(extensionlessFilePath);
|
||||
const baseFilename = path.basename(extensionlessFilePath);
|
||||
|
||||
// Find all files in the directory that start with the base filename
|
||||
const filesToZip = fs
|
||||
.readdirSync(directory)
|
||||
.filter((file) => file.startsWith(baseFilename))
|
||||
.map((file) => path.join(directory, file));
|
||||
|
||||
if (filesToZip.length === 0) {
|
||||
console.error("No files found to zip.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create a zip archive in memory
|
||||
const archive = archiver("zip", { zlib: { level: 9 } });
|
||||
const zipBuffer = await new Promise<Buffer>((resolve, reject) => {
|
||||
const buffers: Buffer[] = [];
|
||||
const writableStream = new stream.Writable({
|
||||
write(chunk, _encoding, callback) {
|
||||
buffers.push(chunk);
|
||||
callback();
|
||||
},
|
||||
});
|
||||
|
||||
writableStream.on("finish", () => resolve(Buffer.concat(buffers)));
|
||||
writableStream.on("error", reject);
|
||||
|
||||
archive.pipe(writableStream);
|
||||
|
||||
// Append files to the archive
|
||||
filesToZip.forEach((file) => {
|
||||
archive.file(file, { name: path.basename(file) });
|
||||
});
|
||||
|
||||
archive.finalize();
|
||||
});
|
||||
|
||||
// Get the presigned URL from the server
|
||||
const presignedUrlResponse = await axios.post(
|
||||
`${
|
||||
store.get("app.isTest")
|
||||
? import.meta.env.VITE_API_TEST_URL
|
||||
: import.meta.env.VITE_API_URL
|
||||
}/emsupload`,
|
||||
{
|
||||
bodyshopid,
|
||||
ciecaid,
|
||||
clm_no,
|
||||
ownr_ln,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${await getTokenFromRenderer()}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
const presignedUrl = presignedUrlResponse.data?.presignedUrl;
|
||||
if (!presignedUrl) {
|
||||
console.error("Failed to retrieve presigned URL.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Upload the zip file to S3 using the presigned URL
|
||||
await axios.put(presignedUrl, zipBuffer, {
|
||||
headers: {
|
||||
"Content-Type": "application/zip",
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error uploading EMS to S3:", errorTypeCheck(error));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true; // Return true if the upload is successful
|
||||
}
|
||||
|
||||
export default UploadEmsToS3;
|
||||
@@ -19,6 +19,8 @@ const EmsPartsOrderGenerateLinFile = async (
|
||||
DB_REF: partsOrderLine.jobline?.db_ref,
|
||||
UNQ_SEQ: partsOrderLine.jobline?.unq_seq,
|
||||
WHO_PAYS: partsOrderLine.jobline?.who_pays,
|
||||
PART_DESCJ: partsOrderLine.jobline?.part_descj,
|
||||
|
||||
LINE_DESC: partsOrderLine.jobline?.line_desc,
|
||||
PART_TYPE:
|
||||
partsOrderLine.priceChange === true
|
||||
|
||||
@@ -24,7 +24,7 @@ const EmsPartsOrderGenerateTtlFile = async (
|
||||
ttlFieldLineDescriptors,
|
||||
);
|
||||
|
||||
await dbf.appendRecords(records);
|
||||
await dbf.appendRecords([records]);
|
||||
console.log(`${records.length} TTL file records added.`);
|
||||
return true;
|
||||
} catch (error) {
|
||||
|
||||
@@ -79,6 +79,7 @@ export interface Jobline {
|
||||
bett_type: string | null;
|
||||
cert_part: boolean;
|
||||
est_seq: string | null;
|
||||
part_descj: boolean;
|
||||
}
|
||||
|
||||
// Parts Order Line export interface
|
||||
|
||||
@@ -2,6 +2,7 @@ import { UUID } from "crypto";
|
||||
import { parse, TypedQueryDocumentNode } from "graphql";
|
||||
import { gql } from "graphql-request";
|
||||
import { AvailableJobSchema } from "../decoder/decoder";
|
||||
|
||||
// Define types for the query result and variables
|
||||
export interface ActiveBodyshopQueryResult {
|
||||
bodyshops: Array<{
|
||||
@@ -11,9 +12,8 @@ export interface ActiveBodyshopQueryResult {
|
||||
convenient_company: string;
|
||||
}>;
|
||||
}
|
||||
// No variables needed for this query
|
||||
|
||||
// Transform the string query into a TypedQueryDocumentNode
|
||||
// No variables needed for this query
|
||||
export const QUERY_ACTIVE_BODYSHOP_TYPED: TypedQueryDocumentNode<
|
||||
ActiveBodyshopQueryResult,
|
||||
Record<never, never>
|
||||
@@ -34,9 +34,11 @@ export interface MasterdataQueryResult {
|
||||
key: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface MasterdataQueryVariables {
|
||||
key: string;
|
||||
}
|
||||
|
||||
export const QUERY_MASTERDATA_TYPED: TypedQueryDocumentNode<
|
||||
MasterdataQueryResult,
|
||||
MasterdataQueryVariables
|
||||
@@ -54,9 +56,11 @@ export interface VehicleQueryResult {
|
||||
id: UUID;
|
||||
}>;
|
||||
}
|
||||
|
||||
interface VehicleQueryVariables {
|
||||
vin: string;
|
||||
}
|
||||
|
||||
export const QUERY_VEHICLE_BY_VIN_TYPED: TypedQueryDocumentNode<
|
||||
VehicleQueryResult,
|
||||
VehicleQueryVariables
|
||||
@@ -73,9 +77,11 @@ export interface QueryJobByClmNoResult {
|
||||
id: UUID;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface QueryJobByClmNoVariables {
|
||||
clm_no: string;
|
||||
}
|
||||
|
||||
export const QUERY_JOB_BY_CLM_NO_TYPED: TypedQueryDocumentNode<
|
||||
QueryJobByClmNoResult,
|
||||
QueryJobByClmNoVariables
|
||||
@@ -92,9 +98,11 @@ export interface InsertAvailableJobResult {
|
||||
id: UUID;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface InsertAvailableJobVariables {
|
||||
jobInput: Array<AvailableJobSchema>;
|
||||
}
|
||||
|
||||
export const INSERT_AVAILABLE_JOB_TYPED: TypedQueryDocumentNode<
|
||||
InsertAvailableJobResult,
|
||||
InsertAvailableJobVariables
|
||||
@@ -125,3 +133,140 @@ export const INSERT_AVAILABLE_JOB_TYPED: TypedQueryDocumentNode<
|
||||
InsertAvailableJobResult,
|
||||
InsertAvailableJobVariables
|
||||
>;
|
||||
|
||||
// Add PpgData Query
|
||||
export interface PpgDataQueryResult {
|
||||
bodyshops_by_pk: {
|
||||
id: string;
|
||||
shopname: string;
|
||||
imexshopid: string;
|
||||
} | null;
|
||||
jobs: Array<{
|
||||
id: string;
|
||||
ro_number: string;
|
||||
status: string;
|
||||
ownr_fn: string;
|
||||
ownr_ln: string;
|
||||
ownr_co_nm: string;
|
||||
v_vin: string;
|
||||
v_model_yr: string;
|
||||
v_make_desc: string;
|
||||
v_model_desc: string;
|
||||
v_color: string;
|
||||
plate_no: string;
|
||||
ins_co_nm: string;
|
||||
est_ct_fn: string;
|
||||
est_ct_ln: string;
|
||||
rate_mapa: number;
|
||||
rate_lab: number;
|
||||
job_totals: {
|
||||
rates?: {
|
||||
mapa?: {
|
||||
total?: {
|
||||
amount?: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
totals?: {
|
||||
subtotal?: {
|
||||
amount?: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
vehicle: {
|
||||
v_paint_codes: {
|
||||
paint_cd1?: string;
|
||||
};
|
||||
};
|
||||
labhrs: {
|
||||
aggregate: {
|
||||
sum: {
|
||||
mod_lb_hrs: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
larhrs: {
|
||||
aggregate: {
|
||||
sum: {
|
||||
mod_lb_hrs: number;
|
||||
};
|
||||
};
|
||||
};
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface PpgDataQueryVariables {
|
||||
today: string;
|
||||
todayplus5: string;
|
||||
shopid: string;
|
||||
}
|
||||
|
||||
export const PPG_DATA_QUERY_TYPED: TypedQueryDocumentNode<
|
||||
PpgDataQueryResult,
|
||||
PpgDataQueryVariables
|
||||
> = parse(gql`
|
||||
query PpgData(
|
||||
$today: timestamptz!
|
||||
$todayplus5: timestamptz!
|
||||
$shopid: uuid!
|
||||
) {
|
||||
bodyshops_by_pk(id: $shopid) {
|
||||
id
|
||||
shopname
|
||||
imexshopid
|
||||
}
|
||||
jobs(
|
||||
where: {
|
||||
_or: [
|
||||
{
|
||||
_and: [
|
||||
{ scheduled_in: { _lte: $todayplus5 } }
|
||||
{ scheduled_in: { _gte: $today } }
|
||||
]
|
||||
}
|
||||
{ inproduction: { _eq: true } }
|
||||
]
|
||||
}
|
||||
) {
|
||||
id
|
||||
ro_number
|
||||
status
|
||||
ownr_fn
|
||||
ownr_ln
|
||||
ownr_co_nm
|
||||
v_vin
|
||||
v_model_yr
|
||||
v_make_desc
|
||||
v_model_desc
|
||||
v_color
|
||||
plate_no
|
||||
ins_co_nm
|
||||
est_ct_fn
|
||||
est_ct_ln
|
||||
rate_mapa
|
||||
rate_lab
|
||||
job_totals
|
||||
vehicle {
|
||||
v_paint_codes
|
||||
}
|
||||
labhrs: joblines_aggregate(
|
||||
where: { mod_lbr_ty: { _neq: "LAR" }, removed: { _eq: false } }
|
||||
) {
|
||||
aggregate {
|
||||
sum {
|
||||
mod_lb_hrs
|
||||
}
|
||||
}
|
||||
}
|
||||
larhrs: joblines_aggregate(
|
||||
where: { mod_lbr_ty: { _eq: "LAR" }, removed: { _eq: false } }
|
||||
) {
|
||||
aggregate {
|
||||
sum {
|
||||
mod_lb_hrs
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`) as TypedQueryDocumentNode<PpgDataQueryResult, PpgDataQueryVariables>;
|
||||
|
||||
@@ -31,6 +31,12 @@ export default class LocalServer {
|
||||
"https://localhost:3000",
|
||||
"https://test.imex.online",
|
||||
"https://imex.online",
|
||||
"https://test.romeonline.io",
|
||||
"https://romeonline.io",
|
||||
"https://www.test.imex.online",
|
||||
"https://www.imex.online",
|
||||
"https://www.test.romeonline.io",
|
||||
"https://www.romeonline.io",
|
||||
];
|
||||
|
||||
this.app.use(
|
||||
|
||||
@@ -13,7 +13,9 @@ import {
|
||||
import log from "electron-log/main";
|
||||
import { autoUpdater } from "electron-updater";
|
||||
import path, { join } from "path";
|
||||
import appIcon from "../../resources/icon.png?asset";
|
||||
import imexAppIcon from "../../resources/icon.png?asset";
|
||||
import romeAppIcon from "../../resources/ro-icon.png?asset";
|
||||
|
||||
import {
|
||||
default as ErrorTypeCheck,
|
||||
default as errorTypeCheck,
|
||||
@@ -33,6 +35,10 @@ import {
|
||||
isKeepAliveTaskInstalled,
|
||||
setupKeepAliveTask,
|
||||
} from "./setup-keep-alive-task";
|
||||
import ensureWindowOnScreen from "./util/ensureWindowOnScreen";
|
||||
|
||||
const appIconToUse =
|
||||
import.meta.env.VITE_COMPANY === "IMEX" ? imexAppIcon : romeAppIcon;
|
||||
|
||||
Sentry.init({
|
||||
dsn: "https://ba41d22656999a8c1fd63bcb7df98650@o492140.ingest.us.sentry.io/4509074139447296",
|
||||
@@ -56,16 +62,23 @@ function createWindow(): void {
|
||||
y: number | undefined;
|
||||
};
|
||||
|
||||
// Validate window position is on screen
|
||||
const { validX, validY } = ensureWindowOnScreen(x, y, width, height);
|
||||
|
||||
const mainWindow = new BrowserWindow({
|
||||
width,
|
||||
height,
|
||||
x,
|
||||
y,
|
||||
x: validX,
|
||||
y: validY,
|
||||
show: false, // Start hidden, show later if not keep-alive
|
||||
minWidth: 600,
|
||||
minHeight: 400,
|
||||
//autoHideMenuBar: true,
|
||||
...(process.platform === "linux" ? { icon: appIcon } : {}),
|
||||
...(process.platform === "linux"
|
||||
? {
|
||||
icon: appIconToUse,
|
||||
}
|
||||
: {}),
|
||||
title: "Shop Partner",
|
||||
webPreferences: {
|
||||
preload: join(__dirname, "../preload/index.js"),
|
||||
@@ -464,31 +477,36 @@ app.whenReady().then(async () => {
|
||||
if (url.startsWith(`${protocol}://keep-alive`)) {
|
||||
log.info("Keep-alive protocol received, app is already running.");
|
||||
// Do nothing if already running
|
||||
return; // Skip openMainWindow to avoid focusing the window
|
||||
return;
|
||||
} else {
|
||||
openInExplorer(url);
|
||||
}
|
||||
} else {
|
||||
openMainWindow(); // Focus window if no URL
|
||||
}
|
||||
// No action taken if no URL is provided
|
||||
});
|
||||
|
||||
//Dynamically load ipcMain handlers once ready.
|
||||
try {
|
||||
const module = await import("./ipc/ipcMainConfig");
|
||||
const { initializeCronTasks } = await import("./ipc/ipcMainConfig");
|
||||
log.debug("Successfully loaded ipcMainConfig");
|
||||
|
||||
// Initialize cron tasks after loading ipcMainConfig
|
||||
await module.initializeCronTasks();
|
||||
try {
|
||||
await initializeCronTasks();
|
||||
log.info("Cron tasks initialized successfully");
|
||||
} catch (error) {
|
||||
log.error("Failed to load ipcMainConfig or initialize cron tasks", {
|
||||
log.warn("Non-fatal: Failed to initialize cron tasks", {
|
||||
...ErrorTypeCheck(error),
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
log.error("Fatal: Failed to load ipcMainConfig", {
|
||||
...ErrorTypeCheck(error),
|
||||
});
|
||||
throw error; // Adjust based on whether the app should continue
|
||||
}
|
||||
|
||||
//Create Tray
|
||||
const trayicon = nativeImage.createFromPath(appIcon);
|
||||
const trayicon = nativeImage.createFromPath(appIconToUse);
|
||||
const tray = new Tray(trayicon.resize({ width: 16 }));
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{
|
||||
@@ -513,7 +531,7 @@ app.whenReady().then(async () => {
|
||||
|
||||
//Check for app updates.
|
||||
autoUpdater.logger = log;
|
||||
|
||||
autoUpdater.allowDowngrade = true;
|
||||
// if (import.meta.env.DEV) {
|
||||
// // Useful for some dev/debugging tasks, but download can
|
||||
// // not be validated because dev app is not signed
|
||||
@@ -568,15 +586,10 @@ app.whenReady().then(async () => {
|
||||
|
||||
app.on("open-url", (event: Electron.Event, url: string) => {
|
||||
event.preventDefault();
|
||||
//Don't do anything for now. We just want to open the app.
|
||||
if (url.startsWith(`${protocol}://keep-alive`)) {
|
||||
log.info("Keep-alive protocol received.");
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
isKeepAliveLaunch = true;
|
||||
openMainWindow(); // Launch app if not running
|
||||
}
|
||||
// Do nothing if already running
|
||||
return; // Skip openMainWindow to avoid focusing the window
|
||||
// Do nothing, whether app is running or not
|
||||
return;
|
||||
} else {
|
||||
openInExplorer(url);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
} from "../watcher/watcher";
|
||||
import { PaintScaleConfig } from "../../util/types/paintScale";
|
||||
|
||||
|
||||
// Initialize paint scale input configs in store if not set
|
||||
if (!Store.get("settings.paintScaleInputConfigs")) {
|
||||
Store.set("settings.paintScaleInputConfigs", []);
|
||||
@@ -131,11 +130,13 @@ const SettingEmsOutFilePathSet = async (): Promise<string> => {
|
||||
return (Store.get("settings.emsOutFilePath") as string) || "";
|
||||
};
|
||||
|
||||
const SettingsPaintScaleInputConfigsGet = async (
|
||||
const SettingsPaintScaleInputConfigsGet = (
|
||||
_event?: IpcMainInvokeEvent,
|
||||
): Promise<PaintScaleConfig[]> => {
|
||||
): PaintScaleConfig[] => {
|
||||
try {
|
||||
const configs = Store.get("settings.paintScaleInputConfigs") as PaintScaleConfig[];
|
||||
const configs = Store.get(
|
||||
"settings.paintScaleInputConfigs",
|
||||
) as PaintScaleConfig[];
|
||||
log.debug("Retrieved paint scale input configs:", configs);
|
||||
return configs || [];
|
||||
} catch (error) {
|
||||
@@ -183,11 +184,13 @@ const SettingsPaintScaleInputPathSet = async (
|
||||
}
|
||||
};
|
||||
|
||||
const SettingsPaintScaleOutputConfigsGet = async (
|
||||
const SettingsPaintScaleOutputConfigsGet = (
|
||||
_event?: IpcMainInvokeEvent,
|
||||
): Promise<PaintScaleConfig[]> => {
|
||||
): PaintScaleConfig[] => {
|
||||
try {
|
||||
const configs = Store.get("settings.paintScaleOutputConfigs") as PaintScaleConfig[];
|
||||
const configs = Store.get(
|
||||
"settings.paintScaleOutputConfigs",
|
||||
) as PaintScaleConfig[];
|
||||
log.debug("Retrieved paint scale output configs:", configs);
|
||||
return configs || [];
|
||||
} catch (error) {
|
||||
|
||||
@@ -20,19 +20,26 @@ const ipcMainHandleAuthStateChanged = async (
|
||||
user: User | null,
|
||||
): Promise<void> => {
|
||||
Store.set("user", user);
|
||||
log.debug("Received authentication state change from Renderer.", user);
|
||||
await setReleaseChannel();
|
||||
checkForAppUpdatesContinuously();
|
||||
};
|
||||
|
||||
async function setReleaseChannel() {
|
||||
try {
|
||||
//Need to query the currently active shop, and store the metadata as well.
|
||||
//Also need to query the OP Codes for decoding reference.
|
||||
log.debug("Received authentication state change from Renderer.", user);
|
||||
handleShopMetaDataFetch();
|
||||
await handleShopMetaDataFetch();
|
||||
//Check for updates
|
||||
const convCo = Store.get("app.bodyshop");
|
||||
if (convCo === "alpha") {
|
||||
const bodyshop = Store.get("app.bodyshop");
|
||||
if (bodyshop?.convenient_company?.toLowerCase() === "alpha") {
|
||||
autoUpdater.channel = "alpha";
|
||||
log.debug("Setting update channel to ALPHA channel.");
|
||||
} else if (convCo === "beta") {
|
||||
} else if (bodyshop?.convenient_company?.toLowerCase() === "beta") {
|
||||
autoUpdater.channel = "beta";
|
||||
log.debug("Setting update channel to BETA channel.");
|
||||
} else {
|
||||
log.debug("Setting update channel to LATEST channel.");
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(
|
||||
@@ -44,8 +51,7 @@ const ipcMainHandleAuthStateChanged = async (
|
||||
"Error connecting to ImEX Online servers to get shop data. Please try again.",
|
||||
);
|
||||
}
|
||||
checkForAppUpdatesContinuously();
|
||||
};
|
||||
}
|
||||
|
||||
const handleShopMetaDataFetch = async (
|
||||
reloadWindow?: boolean,
|
||||
@@ -89,7 +95,8 @@ const ipMainHandleResetPassword = async (): Promise<void> => {
|
||||
};
|
||||
|
||||
export {
|
||||
handleShopMetaDataFetch,
|
||||
ipcMainHandleAuthStateChanged,
|
||||
ipMainHandleResetPassword,
|
||||
handleShopMetaDataFetch,
|
||||
setReleaseChannel,
|
||||
};
|
||||
|
||||
@@ -5,24 +5,43 @@ import axios from "axios";
|
||||
import { create } from "xmlbuilder2";
|
||||
import { parseStringPromise } from "xml2js";
|
||||
import store from "../../store/store";
|
||||
import client from "../../graphql/graphql-client";
|
||||
import client, { getTokenFromRenderer } from "../../graphql/graphql-client";
|
||||
import { PaintScaleConfig } from "../../../util/types/paintScale";
|
||||
import dayjs from "dayjs";
|
||||
import {
|
||||
PPG_DATA_QUERY_TYPED,
|
||||
PpgDataQueryResult,
|
||||
PpgDataQueryVariables,
|
||||
} from "../../graphql/queries";
|
||||
|
||||
// PPG Input Handler
|
||||
export async function ppgInputHandler(config: PaintScaleConfig): Promise<void> {
|
||||
try {
|
||||
log.info(
|
||||
`Polling input directory for PPG config ${config.id}: ${config.path}`,
|
||||
);
|
||||
|
||||
log.debug(
|
||||
`Archive dir: ${path.join(config.path!, "archive")}, Error dir: ${path.join(config.path!, "error")}`,
|
||||
);
|
||||
|
||||
// Ensure archive and error directories exist
|
||||
const archiveDir = path.join(config.path!, "archive");
|
||||
const errorDir = path.join(config.path!, "error");
|
||||
try {
|
||||
await fs.mkdir(archiveDir, { recursive: true });
|
||||
await fs.mkdir(errorDir, { recursive: true });
|
||||
log.debug(
|
||||
`Archive and error directories ensured: ${archiveDir}, ${errorDir}`,
|
||||
);
|
||||
} catch (dirError) {
|
||||
log.error(`Failed to create directories for ${config.path}:`, dirError);
|
||||
throw dirError;
|
||||
}
|
||||
|
||||
// Check for files
|
||||
const files = await fs.readdir(config.path!);
|
||||
log.debug(`Found ${files.length} files in ${config.path}:`, files);
|
||||
|
||||
for (const file of files) {
|
||||
// Only process XML files
|
||||
if (!file.toLowerCase().endsWith(".xml")) {
|
||||
@@ -30,10 +49,15 @@ export async function ppgInputHandler(config: PaintScaleConfig): Promise<void> {
|
||||
}
|
||||
|
||||
const filePath = path.join(config.path!, file);
|
||||
try {
|
||||
const stats = await fs.stat(filePath);
|
||||
if (!stats.isFile()) {
|
||||
continue;
|
||||
}
|
||||
} catch (statError) {
|
||||
log.warn(`Failed to stat file ${filePath}:`, statError);
|
||||
continue;
|
||||
}
|
||||
|
||||
log.debug(`Processing input file: ${filePath}`);
|
||||
|
||||
@@ -46,40 +70,61 @@ export async function ppgInputHandler(config: PaintScaleConfig): Promise<void> {
|
||||
}
|
||||
|
||||
// Validate XML structure
|
||||
let xmlContent : BlobPart;
|
||||
|
||||
let xmlContent: BlobPart;
|
||||
try {
|
||||
xmlContent = await fs.readFile(filePath, "utf8");
|
||||
await parseStringPromise(xmlContent);
|
||||
log.debug(`Successfully validated XML for ${filePath}`);
|
||||
} catch (error) {
|
||||
log.error(`Invalid XML in ${filePath}:`, error);
|
||||
const timestamp = Date.now().toString(); // similar to DateTime.Now.Ticks in C#
|
||||
const errorPath = path.join(errorDir, `${timestamp}.xml`);
|
||||
const timestamp = dayjs().format("YYYYMMDD_HHmmss");
|
||||
const originalFilename = path.basename(file, path.extname(file));
|
||||
const errorPath = path.join(
|
||||
errorDir,
|
||||
`${originalFilename}-${timestamp}.xml`,
|
||||
);
|
||||
try {
|
||||
await fs.rename(filePath, errorPath);
|
||||
log.debug(`Moved invalid file to error: ${errorPath}`);
|
||||
} catch (moveError) {
|
||||
log.error(
|
||||
`Failed to move invalid file to error directory ${errorPath}:`,
|
||||
moveError,
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get authentication token
|
||||
const token = (store.get("user") as any)?.stsTokenManager?.accessToken;
|
||||
let token: string | null;
|
||||
try {
|
||||
token = await getTokenFromRenderer();
|
||||
if (!token) {
|
||||
log.error(`No authentication token for file: ${filePath}`);
|
||||
continue;
|
||||
}
|
||||
log.debug(
|
||||
`Obtained authentication token for ${filePath}: ${token.slice(0, 10)}...`,
|
||||
);
|
||||
} catch (tokenError) {
|
||||
log.error(
|
||||
`Failed to obtain authentication token for ${filePath}:`,
|
||||
tokenError,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Upload file to API
|
||||
const formData = new FormData();
|
||||
formData.append("file", new Blob([xmlContent]), path.basename(filePath));
|
||||
formData.append(
|
||||
"shopId",
|
||||
(store.get("app.bodyshop") as any)?.shopname || "",
|
||||
);
|
||||
const shopId = (store.get("app.bodyshop") as any)?.shopname || "";
|
||||
formData.append("shopId", shopId);
|
||||
log.debug(`Shop ID: ${shopId}`);
|
||||
|
||||
const baseURL = store.get("app.isTest")
|
||||
? import.meta.env.VITE_API_TEST_URL
|
||||
: import.meta.env.VITE_API_URL;
|
||||
const finalUrl = `${baseURL}/mixdata/upload`;
|
||||
|
||||
log.debug(`Uploading file to ${finalUrl}`);
|
||||
|
||||
try {
|
||||
@@ -88,23 +133,52 @@ export async function ppgInputHandler(config: PaintScaleConfig): Promise<void> {
|
||||
Authorization: `Bearer ${token}`,
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
timeout: 10000, // 10-second timeout
|
||||
});
|
||||
|
||||
log.info(`Upload response for ${filePath}:`, {
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
data: response.data,
|
||||
});
|
||||
|
||||
if (response.status === 200) {
|
||||
log.info(`Successful upload of ${filePath}`);
|
||||
// Move file to archive
|
||||
const timestamp = Date.now().toString(); // generate new timestamp
|
||||
const archivePath = path.join(archiveDir, `${timestamp}.xml`);
|
||||
const timestamp = dayjs().format("YYYYMMDD_HHmmss");
|
||||
const originalFilename = path.basename(file, path.extname(file));
|
||||
const archivePath = path.join(
|
||||
archiveDir,
|
||||
`${originalFilename}-${timestamp}.xml`,
|
||||
);
|
||||
try {
|
||||
await fs.access(archiveDir, fs.constants.W_OK); // Verify archiveDir is writable
|
||||
await fs.rename(filePath, archivePath);
|
||||
log.debug(`Moved file to archive: ${archivePath}`);
|
||||
log.info(`Moved file to archive: ${archivePath}`);
|
||||
} catch (moveError) {
|
||||
log.error(
|
||||
`Failed to move file to archive directory ${archivePath}:`,
|
||||
moveError,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
log.error(
|
||||
`Failed to upload ${filePath}: ${response.status} ${response.statusText}`,
|
||||
response.data,
|
||||
{ responseData: response.data },
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(`Error uploading ${filePath}:`, error);
|
||||
} catch (error: any) {
|
||||
log.error(`Error uploading ${filePath}:`, {
|
||||
message: error.message,
|
||||
code: error.code,
|
||||
response: error.response
|
||||
? {
|
||||
status: error.response.status,
|
||||
statusText: error.response.statusText,
|
||||
data: error.response.data,
|
||||
}
|
||||
: null,
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -121,70 +195,16 @@ export async function ppgOutputHandler(
|
||||
|
||||
await fs.mkdir(config.path!, { recursive: true });
|
||||
|
||||
const query = `
|
||||
query PpgData($today: timestamptz!, $todayplus5: timestamptz!, $shopid: uuid!) {
|
||||
bodyshops_by_pk(id:$shopid) {
|
||||
id
|
||||
shopname
|
||||
imexshopid
|
||||
}
|
||||
jobs(where: {
|
||||
_or: [
|
||||
{
|
||||
_and: [
|
||||
{ scheduled_in: { _lte: $todayplus5 } },
|
||||
{ scheduled_in: { _gte: $today } }
|
||||
]
|
||||
},
|
||||
{ inproduction: { _eq: true } }
|
||||
]
|
||||
}) {
|
||||
id
|
||||
ro_number
|
||||
status
|
||||
ownr_fn
|
||||
ownr_ln
|
||||
ownr_co_nm
|
||||
v_vin
|
||||
v_model_yr
|
||||
v_make_desc
|
||||
v_model_desc
|
||||
v_color
|
||||
plate_no
|
||||
ins_co_nm
|
||||
est_ct_fn
|
||||
est_ct_ln
|
||||
rate_mapa
|
||||
rate_lab
|
||||
job_totals
|
||||
vehicle {
|
||||
v_paint_codes
|
||||
}
|
||||
labhrs: joblines_aggregate(where: { mod_lbr_ty: { _neq: "LAR" }, removed: { _eq: false } }) {
|
||||
aggregate {
|
||||
sum {
|
||||
mod_lb_hrs
|
||||
}
|
||||
}
|
||||
}
|
||||
larhrs: joblines_aggregate(where: { mod_lbr_ty: { _eq: "LAR" }, removed: { _eq: false } }) {
|
||||
aggregate {
|
||||
sum {
|
||||
mod_lb_hrs
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const variables = {
|
||||
today: new Date().toISOString(),
|
||||
todayplus5: new Date(Date.now() + 5 * 86400000).toISOString(),
|
||||
const variables: PpgDataQueryVariables = {
|
||||
today: dayjs().toISOString(),
|
||||
todayplus5: dayjs().add(5, "day").toISOString(),
|
||||
shopid: (store.get("app.bodyshop") as any)?.id,
|
||||
};
|
||||
|
||||
const response = (await client.request(query, variables)) as any;
|
||||
const response = await client.request<
|
||||
PpgDataQueryResult,
|
||||
PpgDataQueryVariables
|
||||
>(PPG_DATA_QUERY_TYPED, variables);
|
||||
const jobs = response.jobs ?? [];
|
||||
|
||||
const header = {
|
||||
@@ -197,18 +217,10 @@ export async function ppgOutputHandler(
|
||||
},
|
||||
Transaction: {
|
||||
TransactionID: "",
|
||||
TransactionDate: (() => {
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = ("0" + (now.getMonth() + 1)).slice(-2);
|
||||
const day = ("0" + now.getDate()).slice(-2);
|
||||
const hours = ("0" + now.getHours()).slice(-2);
|
||||
const minutes = ("0" + now.getMinutes()).slice(-2);
|
||||
return `${year}-${month}-${day}:${hours}:${minutes}`;
|
||||
})(),
|
||||
TransactionDate: dayjs().format("YYYY-MM-DD:HH:mm"),
|
||||
},
|
||||
Product: {
|
||||
Name: "ImEX Online",
|
||||
Name: import.meta.env.VITE_COMPANY === "IMEX",
|
||||
Version: "",
|
||||
},
|
||||
},
|
||||
@@ -220,7 +232,7 @@ export async function ppgOutputHandler(
|
||||
},
|
||||
RepairOrders: {
|
||||
ROCount: jobs.length.toString(),
|
||||
RO: jobs.map((job: any) => ({
|
||||
RO: jobs.map((job) => ({
|
||||
RONumber: job.ro_number || "",
|
||||
ROStatus: "Open",
|
||||
Customer: `${job.ownr_ln || ""}, ${job.ownr_fn || ""}`,
|
||||
@@ -258,4 +270,3 @@ export async function ppgOutputHandler(
|
||||
log.error(`Error generating PPG output for config ${config.id}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export async function setupKeepAliveAgent(): Promise<void> {
|
||||
<string>com.convenientbrands.bodyshop-desktop.keepalive</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>open</string>
|
||||
<string>Shop Partner Keep Alive</string>
|
||||
<string>imexmedia://keep-alive</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
@@ -31,7 +31,7 @@ export async function setupKeepAliveAgent(): Promise<void> {
|
||||
|
||||
const plistPath = join(
|
||||
homedir(),
|
||||
"Library/LaunchAgents/com.convenientbrands.bodyshop-desktop.keepalive.plist",
|
||||
"/Library/LaunchAgents/com.convenientbrands.bodyshop-desktop.keepalive.plist",
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -40,7 +40,9 @@ export async function setupKeepAliveAgent(): Promise<void> {
|
||||
log.info(`Launch agent created and loaded: ${stdout}`);
|
||||
if (stderr) log.warn(`Launch agent stderr: ${stderr}`);
|
||||
} catch (error) {
|
||||
log.error(`Error setting up launch agent: ${error instanceof Error ? error.message : String(error)}`);
|
||||
log.error(
|
||||
`Error setting up launch agent: ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
throw error; // Rethrow to allow caller to handle
|
||||
}
|
||||
}
|
||||
@@ -48,7 +50,7 @@ export async function setupKeepAliveAgent(): Promise<void> {
|
||||
export async function isKeepAliveAgentInstalled(): Promise<boolean> {
|
||||
const plistPath = join(
|
||||
homedir(),
|
||||
"Library/LaunchAgents/com.convenientbrands.bodyshop-desktop.keepalive.plist",
|
||||
"/Library/LaunchAgents/com.convenientbrands.bodyshop-desktop.keepalive.plist",
|
||||
);
|
||||
const maxRetries = 3;
|
||||
const retryDelay = 500; // 500ms delay between retries
|
||||
@@ -56,10 +58,14 @@ export async function isKeepAliveAgentInstalled(): Promise<boolean> {
|
||||
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
||||
try {
|
||||
await fs.access(plistPath, fs.constants.F_OK);
|
||||
const { stdout } = await execPromise(`launchctl list | grep com.convenientbrands.bodyshop-desktop.keepalive`);
|
||||
const { stdout } = await execPromise(
|
||||
`launchctl list | grep com.convenientbrands.bodyshop-desktop.keepalive`,
|
||||
);
|
||||
return !!stdout; // Return true if plist exists and agent is loaded
|
||||
} catch (error) {
|
||||
log.debug(`Launch agent not found (attempt ${attempt}/${maxRetries}): ${error instanceof Error ? error.message : String(error)}`);
|
||||
log.debug(
|
||||
`Launch agent not found (attempt ${attempt}/${maxRetries}): ${error instanceof Error ? error.message : String(error)}`,
|
||||
);
|
||||
if (attempt === maxRetries) {
|
||||
return false; // Return false after all retries fail
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ const execPromise = promisify(exec);
|
||||
|
||||
// Define the interval as a variable (in minutes)
|
||||
const KEEP_ALIVE_INTERVAL_MINUTES = 15;
|
||||
const taskName = "ShopPartnerKeepAlive";
|
||||
|
||||
export async function setupKeepAliveTask(): Promise<void> {
|
||||
const taskName = "ImEXShopPartnerKeepAlive";
|
||||
const protocolUrl = "imexmedia://keep-alive";
|
||||
// Use rundll32.exe to silently open the URL as a protocol
|
||||
const command = `rundll32.exe url.dll,OpenURL "${protocolUrl}"`;
|
||||
@@ -30,7 +30,6 @@ export async function setupKeepAliveTask(): Promise<void> {
|
||||
}
|
||||
|
||||
export async function isKeepAliveTaskInstalled(): Promise<boolean> {
|
||||
const taskName = "ImEXShopPartnerKeepAlive";
|
||||
const maxRetries = 3;
|
||||
const retryDelay = 500; // 500ms delay between retries
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { autoUpdater } from "electron-updater";
|
||||
import { setReleaseChannel } from "../ipc/ipcMainHandler.user";
|
||||
|
||||
function checkForAppUpdatesContinuously(): void {
|
||||
async function checkForAppUpdatesContinuously(): Promise<void> {
|
||||
checkForAppUpdates();
|
||||
setInterval(
|
||||
() => {
|
||||
@@ -9,11 +10,12 @@ function checkForAppUpdatesContinuously(): void {
|
||||
1000 * 60 * 30,
|
||||
);
|
||||
}
|
||||
function checkForAppUpdates(): void {
|
||||
async function checkForAppUpdates(): Promise<void> {
|
||||
await setReleaseChannel();
|
||||
autoUpdater.checkForUpdatesAndNotify({
|
||||
title: "Shop Partner Update",
|
||||
body: "A new version of Shop Partner is available. Click to update.",
|
||||
});
|
||||
}
|
||||
|
||||
export { checkForAppUpdatesContinuously, checkForAppUpdates };
|
||||
export { checkForAppUpdates, checkForAppUpdatesContinuously };
|
||||
|
||||
@@ -56,7 +56,7 @@ export const ttlFieldLineDescriptors: FieldDescriptor[] = [
|
||||
decimalPlaces: 2,
|
||||
},
|
||||
{
|
||||
name: "N_SUPP_ANT",
|
||||
name: "N_SUPP_AMT",
|
||||
type: "N",
|
||||
size: 10,
|
||||
decimalPlaces: 2,
|
||||
|
||||
109
src/main/util/ensureWindowOnScreen.ts
Normal file
109
src/main/util/ensureWindowOnScreen.ts
Normal file
@@ -0,0 +1,109 @@
|
||||
import { screen } from "electron";
|
||||
|
||||
function ensureWindowOnScreen(
|
||||
x: number | undefined,
|
||||
y: number | undefined,
|
||||
windowWidth: number,
|
||||
windowHeight: number,
|
||||
): { validX: number | undefined; validY: number | undefined } {
|
||||
// If no coordinates stored, let Electron position window automatically
|
||||
if (x === undefined || y === undefined) {
|
||||
return { validX: undefined, validY: undefined };
|
||||
}
|
||||
|
||||
const displays = screen.getAllDisplays();
|
||||
|
||||
// Minimum visible pixels required on each edge to be considered "visible enough"
|
||||
const MIN_VISIBLE = 50; // Ensure at least 50px from each edge is visible
|
||||
|
||||
// Try to find a display where the window would be almost fully visible
|
||||
for (const display of displays) {
|
||||
const { bounds } = display;
|
||||
|
||||
// Check if window is mostly within this display
|
||||
if (
|
||||
x + MIN_VISIBLE >= bounds.x &&
|
||||
x + windowWidth - MIN_VISIBLE <= bounds.x + bounds.width &&
|
||||
y + MIN_VISIBLE >= bounds.y &&
|
||||
y + windowHeight - MIN_VISIBLE <= bounds.y + bounds.height
|
||||
) {
|
||||
// Window is adequately visible on this display
|
||||
return { validX: x, validY: y };
|
||||
}
|
||||
}
|
||||
|
||||
// If window isn't adequately visible on any display, try to adjust it to fit the closest display
|
||||
const closestDisplay = findClosestDisplay(displays, x, y);
|
||||
const { bounds } = closestDisplay;
|
||||
|
||||
// Adjust position to ensure window is fully on screen
|
||||
let adjustedX = x;
|
||||
let adjustedY = y;
|
||||
|
||||
// Adjust horizontal position if needed
|
||||
if (x < bounds.x) {
|
||||
adjustedX = bounds.x;
|
||||
} else if (x + windowWidth > bounds.x + bounds.width) {
|
||||
adjustedX = bounds.x + bounds.width - windowWidth;
|
||||
}
|
||||
|
||||
// Adjust vertical position if needed
|
||||
if (y < bounds.y) {
|
||||
adjustedY = bounds.y;
|
||||
} else if (y + windowHeight > bounds.y + bounds.height) {
|
||||
adjustedY = bounds.y + bounds.height - windowHeight;
|
||||
}
|
||||
|
||||
// If adjustments keep window on screen, use adjusted position
|
||||
if (
|
||||
adjustedX >= bounds.x &&
|
||||
adjustedX + windowWidth <= bounds.x + bounds.width &&
|
||||
adjustedY >= bounds.y &&
|
||||
adjustedY + windowHeight <= bounds.y + bounds.height
|
||||
) {
|
||||
return { validX: adjustedX, validY: adjustedY };
|
||||
}
|
||||
|
||||
// If all else fails, center on primary display
|
||||
const primaryDisplay = screen.getPrimaryDisplay();
|
||||
const primaryBounds = primaryDisplay.bounds;
|
||||
|
||||
return {
|
||||
validX: Math.floor(
|
||||
primaryBounds.x + (primaryBounds.width - windowWidth) / 2,
|
||||
),
|
||||
validY: Math.floor(
|
||||
primaryBounds.y + (primaryBounds.height - windowHeight) / 2,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
// Helper function to find the closest display to a point
|
||||
function findClosestDisplay(
|
||||
displays: Electron.Display[],
|
||||
x: number,
|
||||
y: number,
|
||||
): Electron.Display {
|
||||
let closestDisplay = displays[0];
|
||||
let shortestDistance = Number.MAX_VALUE;
|
||||
|
||||
for (const display of displays) {
|
||||
const { bounds } = display;
|
||||
// Calculate distance to center of display
|
||||
const displayCenterX = bounds.x + bounds.width / 2;
|
||||
const displayCenterY = bounds.y + bounds.height / 2;
|
||||
|
||||
const distance = Math.sqrt(
|
||||
Math.pow(x - displayCenterX, 2) + Math.pow(y - displayCenterY, 2),
|
||||
);
|
||||
|
||||
if (distance < shortestDistance) {
|
||||
shortestDistance = distance;
|
||||
closestDisplay = display;
|
||||
}
|
||||
}
|
||||
|
||||
return closestDisplay;
|
||||
}
|
||||
|
||||
export default ensureWindowOnScreen;
|
||||
@@ -42,7 +42,10 @@ async function StartWatcher(): Promise<boolean> {
|
||||
watcher = chokidar.watch(filePaths, {
|
||||
ignored: (filepath, stats) => {
|
||||
const p = path.parse(filepath);
|
||||
return !stats?.isFile() && p.ext !== "" && p.ext.toUpperCase() !== ".ENV"; //Only watch for .ENV files.
|
||||
return (
|
||||
(!stats?.isFile() && p.ext !== "" && p.ext.toUpperCase() !== ".ENV") ||
|
||||
p.name?.toUpperCase() === ".DS_STORE"
|
||||
); //Only watch for .ENV files.
|
||||
},
|
||||
usePolling: pollingSettings.enabled || false,
|
||||
interval: pollingSettings.interval || 30000,
|
||||
|
||||
@@ -13,9 +13,10 @@ import {
|
||||
Space,
|
||||
Table,
|
||||
Tag,
|
||||
theme,
|
||||
Tooltip,
|
||||
} from "antd";
|
||||
import { FC, useState } from "react";
|
||||
import { JSX, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
PaintScaleConfig,
|
||||
@@ -24,8 +25,10 @@ import {
|
||||
} from "../../../../util/types/paintScale";
|
||||
import { usePaintScaleConfig } from "./PaintScale/usePaintScaleConfig";
|
||||
|
||||
const SettingsPaintScaleInputPaths: FC = () => {
|
||||
const SettingsPaintScaleInputPaths = (): JSX.Element => {
|
||||
const { t } = useTranslation();
|
||||
const { token } = theme.useToken(); // Access theme tokens
|
||||
|
||||
const {
|
||||
paintScaleConfigs,
|
||||
handleAddConfig,
|
||||
@@ -87,7 +90,7 @@ const SettingsPaintScaleInputPaths: FC = () => {
|
||||
placeholder={t("settings.labels.paintScalePath")}
|
||||
disabled
|
||||
style={{
|
||||
borderColor: isValid ? "#52c41a" : "#d9d9d9",
|
||||
borderColor: isValid ? token.colorSuccess : token.colorError, // Use semantic tokens
|
||||
}}
|
||||
suffix={
|
||||
<Tooltip
|
||||
@@ -98,9 +101,9 @@ const SettingsPaintScaleInputPaths: FC = () => {
|
||||
}
|
||||
>
|
||||
{isValid ? (
|
||||
<CheckCircleFilled style={{ color: "#52c41a" }} />
|
||||
<CheckCircleFilled style={{ color: token.colorSuccess }} />
|
||||
) : (
|
||||
<WarningFilled style={{ color: "#faad14" }} />
|
||||
<WarningFilled style={{ color: token.colorError }} />
|
||||
)}
|
||||
</Tooltip>
|
||||
}
|
||||
|
||||
@@ -4,8 +4,18 @@ import {
|
||||
FolderOpenFilled,
|
||||
WarningFilled,
|
||||
} from "@ant-design/icons";
|
||||
import { Button, Card, Input, Modal, Select, Space, Table, Tag } from "antd";
|
||||
import { FC, useState } from "react";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
Input,
|
||||
Modal,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
Tag,
|
||||
theme,
|
||||
} from "antd";
|
||||
import { JSX, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
PaintScaleConfig,
|
||||
@@ -14,7 +24,8 @@ import {
|
||||
} from "../../../../util/types/paintScale";
|
||||
import { usePaintScaleConfig } from "./PaintScale/usePaintScaleConfig";
|
||||
|
||||
const SettingsPaintScaleOutputPaths: FC = () => {
|
||||
const SettingsPaintScaleOutputPaths = (): JSX.Element => {
|
||||
const { token } = theme.useToken();
|
||||
const { t } = useTranslation();
|
||||
const {
|
||||
paintScaleConfigs,
|
||||
@@ -77,13 +88,13 @@ const SettingsPaintScaleOutputPaths: FC = () => {
|
||||
placeholder={t("settings.labels.paintScalePath")}
|
||||
disabled
|
||||
style={{
|
||||
borderColor: isValid ? "#52c41a" : "#d9d9d9",
|
||||
borderColor: isValid ? token.colorSuccess : token.colorError,
|
||||
}}
|
||||
suffix={
|
||||
isValid ? (
|
||||
<CheckCircleFilled style={{ color: "#52c41a" }} />
|
||||
<CheckCircleFilled style={{ color: token.colorSuccess }} />
|
||||
) : (
|
||||
<WarningFilled style={{ color: "#faad14" }} />
|
||||
<WarningFilled style={{ color: token.colorError }} />
|
||||
)
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -29,26 +29,26 @@
|
||||
"duplicatePath": "The selected directory is already used in another configuration."
|
||||
},
|
||||
"labels": {
|
||||
"actions": "Actions",
|
||||
"addPaintScalePath": "Add Paint Scale Path",
|
||||
"emsOutFilePath": "EMS Out File Path (Parts Order, etc.)",
|
||||
"invalidPath": "Path not set or invalid",
|
||||
"paintScalePath": "Paint Scale Path",
|
||||
"paintScaleSettingsInput": "BSMS To Paint Scale",
|
||||
"paintScaleSettingsOutput": "Paint Scale To BSMS",
|
||||
"paintScaleType": "Paint Scale Type",
|
||||
"pollingInterval": "Polling Interval (m)",
|
||||
"pollinginterval": "Polling Interval (ms)",
|
||||
"ppcfilepath": "Parts Price Change File Path",
|
||||
"remove": "Remove",
|
||||
"selectPaintScaleType": "Select Paint Scale Type",
|
||||
"started": "Started",
|
||||
"stopped": "Stopped",
|
||||
"validPath": "Valid path",
|
||||
"watchedpaths": "Watched Paths",
|
||||
"watchermodepolling": "Polling",
|
||||
"watchermoderealtime": "Real Time",
|
||||
"watcherstatus": "Watcher Status",
|
||||
"paintScaleSettingsInput": "BSMS To Paint Scale",
|
||||
"paintScaleSettingsOutput": "Paint Scale To BSMS",
|
||||
"paintScalePath": "Paint Scale Path",
|
||||
"paintScaleType": "Paint Scale Type",
|
||||
"addPaintScalePath": "Add Paint Scale Path",
|
||||
"remove": "Remove",
|
||||
"actions": "Actions",
|
||||
"pollingInterval": "Polling Interval (m)",
|
||||
"validPath": "Valid path",
|
||||
"invalidPath": "Path not set or invalid",
|
||||
"selectPaintScaleType": "Select Paint Scale Type"
|
||||
"watcherstatus": "Watcher Status"
|
||||
}
|
||||
},
|
||||
"title": {
|
||||
@@ -57,6 +57,7 @@
|
||||
},
|
||||
"updates": {
|
||||
"apply": "Apply Update",
|
||||
"applying": "Applying update",
|
||||
"available": "An update is available.",
|
||||
"download": "Download Update",
|
||||
"downloading": "An update is downloading."
|
||||
|
||||
@@ -234,9 +234,53 @@
|
||||
</concept_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
<name>errors</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>duplicatePath</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
</children>
|
||||
</folder_node>
|
||||
<folder_node>
|
||||
<name>labels</name>
|
||||
<children>
|
||||
<concept_node>
|
||||
<name>actions</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>addPaintScalePath</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>emsOutFilePath</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -250,6 +294,84 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>invalidPath</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>paintScalePath</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>paintScaleSettingsInput</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>paintScaleSettingsOutput</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>paintScaleType</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>pollingInterval</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>pollinginterval</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -276,6 +398,32 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>remove</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>selectPaintScaleType</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>started</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -302,6 +450,19 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>validPath</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>watchedpaths</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -405,6 +566,19 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>applying</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
<description></description>
|
||||
<comment></comment>
|
||||
<default_text></default_text>
|
||||
<translations>
|
||||
<translation>
|
||||
<language>en-US</language>
|
||||
<approved>false</approved>
|
||||
</translation>
|
||||
</translations>
|
||||
</concept_node>
|
||||
<concept_node>
|
||||
<name>available</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
|
||||
Reference in New Issue
Block a user