Compare commits
3 Commits
22801f6b75
...
5e5dadba2c
| Author | SHA1 | Date | |
|---|---|---|---|
| 5e5dadba2c | |||
| 6438d1a51c | |||
| 3fa7758fbe |
33
main.js
33
main.js
@@ -8,8 +8,10 @@ const {
|
||||
resolveUnroutedDir,
|
||||
listUnroutedFiles,
|
||||
listDuplicateFiles,
|
||||
listSkippedFiles,
|
||||
clearUnroutedFiles,
|
||||
clearDuplicateFiles,
|
||||
clearSkippedFiles,
|
||||
} = require('./services/unrouted');
|
||||
|
||||
const CAD_EXTENSIONS = ['prt', 'asm', 'dwr'];
|
||||
@@ -66,8 +68,8 @@ let config = buildConfig(DEFAULT_DESTINATION);
|
||||
|
||||
function createWindow() {
|
||||
const win = new BrowserWindow({
|
||||
width: 900,
|
||||
height: 640,
|
||||
width: 1000,
|
||||
height: 800,
|
||||
icon: path.join(__dirname, 'build', 'icon.png'),
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js'),
|
||||
@@ -91,7 +93,32 @@ function createDocsWindow() {
|
||||
docs.setMenuBarVisibility(false);
|
||||
}
|
||||
|
||||
function showAboutDialog() {
|
||||
dialog.showMessageBox({
|
||||
type: 'info',
|
||||
title: 'Informazioni su CadRoute',
|
||||
message: 'CadRoute',
|
||||
detail: [
|
||||
`Versione: ${app.getVersion()}`,
|
||||
`Autore: Davide Grilli`,
|
||||
`Azienda: Cevolani Italia s.r.l.`,
|
||||
`Licenza: MIT`,
|
||||
``,
|
||||
`Smistatore automatico di file CAD (Creo).`,
|
||||
``,
|
||||
`Electron: ${process.versions.electron}`,
|
||||
`Node: ${process.versions.node}`,
|
||||
].join('\n'),
|
||||
buttons: ['OK'],
|
||||
noLink: true,
|
||||
});
|
||||
}
|
||||
|
||||
Menu.setApplicationMenu(Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'Informazioni',
|
||||
submenu: [{ label: 'Informazioni su CadRoute...', click: () => showAboutDialog() }],
|
||||
},
|
||||
{
|
||||
label: 'Help',
|
||||
submenu: [{ label: 'Documentazione', click: () => createDocsWindow() }],
|
||||
@@ -209,5 +236,7 @@ ipcMain.handle('open-unrouted-folder', async () => {
|
||||
|
||||
ipcMain.handle('list-unrouted-files', async () => listUnroutedFiles());
|
||||
ipcMain.handle('list-duplicates-files', async () => listDuplicateFiles());
|
||||
ipcMain.handle('list-skipped-files', async () => listSkippedFiles());
|
||||
ipcMain.handle('clear-unrouted-files', async () => clearUnroutedFiles());
|
||||
ipcMain.handle('clear-duplicates-files', async () => clearDuplicateFiles());
|
||||
ipcMain.handle('clear-skipped-files', async () => clearSkippedFiles());
|
||||
|
||||
@@ -11,6 +11,8 @@ contextBridge.exposeInMainWorld('api', {
|
||||
openUnroutedFolder: () => ipcRenderer.invoke('open-unrouted-folder'),
|
||||
listUnroutedFiles: () => ipcRenderer.invoke('list-unrouted-files'),
|
||||
listDuplicatesFiles: () => ipcRenderer.invoke('list-duplicates-files'),
|
||||
listSkippedFiles: () => ipcRenderer.invoke('list-skipped-files'),
|
||||
clearUnroutedFiles: () => ipcRenderer.invoke('clear-unrouted-files'),
|
||||
clearDuplicatesFiles: () => ipcRenderer.invoke('clear-duplicates-files'),
|
||||
clearSkippedFiles: () => ipcRenderer.invoke('clear-skipped-files'),
|
||||
});
|
||||
|
||||
@@ -24,32 +24,35 @@
|
||||
background: linear-gradient(130deg, #eaf0ff 0%, var(--bg) 45%, #f9fbff 100%);
|
||||
color: var(--text);
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.page {
|
||||
max-width: 820px;
|
||||
max-width: 980px;
|
||||
margin: 40px auto;
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
padding: 26px;
|
||||
padding: 32px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 6px;
|
||||
margin-bottom: 8px;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
margin-top: 18px;
|
||||
gap: 14px;
|
||||
margin-top: 22px;
|
||||
}
|
||||
|
||||
button {
|
||||
@@ -57,8 +60,8 @@
|
||||
background: var(--accent);
|
||||
color: white;
|
||||
border-radius: 10px;
|
||||
padding: 11px 16px;
|
||||
font-size: 15px;
|
||||
padding: 13px 20px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@@ -116,43 +119,43 @@
|
||||
}
|
||||
|
||||
.rules h2 {
|
||||
margin: 0 0 10px;
|
||||
font-size: 17px;
|
||||
margin: 0 0 12px;
|
||||
font-size: 19px;
|
||||
}
|
||||
|
||||
.rule-row {
|
||||
display: grid;
|
||||
grid-template-columns: 180px 1fr auto auto;
|
||||
gap: 8px;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.rule-row.single-row {
|
||||
grid-template-columns: 1fr auto auto;
|
||||
margin-top: 10px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.rule-row.preview-actions {
|
||||
grid-template-columns: auto auto;
|
||||
grid-template-columns: auto auto auto;
|
||||
justify-content: start;
|
||||
}
|
||||
|
||||
.rule-label {
|
||||
font-size: 13px;
|
||||
font-size: 15px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.rule-row input {
|
||||
min-width: 0;
|
||||
padding: 9px 10px;
|
||||
padding: 11px 12px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.rule-row button {
|
||||
padding: 9px 12px;
|
||||
padding: 11px 16px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
@@ -162,7 +165,7 @@
|
||||
|
||||
.rule-status {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
font-size: 14px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
@@ -277,6 +280,7 @@
|
||||
<div class="rule-row single-row preview-actions">
|
||||
<button id="openUnroutedBtn" class="browse">Anteprima non smistati</button>
|
||||
<button id="openDuplicatesBtn" class="browse">Anteprima duplicati</button>
|
||||
<button id="openSkippedBtn" class="browse">Anteprima saltati</button>
|
||||
</div>
|
||||
<div class="rule-status" id="destinationStatus"></div>
|
||||
</section>
|
||||
|
||||
@@ -7,6 +7,7 @@ const browseDestinationBtn = document.getElementById('browseDestinationBtn');
|
||||
const saveDestinationBtn = document.getElementById('saveDestinationBtn');
|
||||
const openUnroutedBtn = document.getElementById('openUnroutedBtn');
|
||||
const openDuplicatesBtn = document.getElementById('openDuplicatesBtn');
|
||||
const openSkippedBtn = document.getElementById('openSkippedBtn');
|
||||
const destinationStatus = document.getElementById('destinationStatus');
|
||||
const previewOverlay = document.getElementById('previewOverlay');
|
||||
const closePreviewBtn = document.getElementById('closePreviewBtn');
|
||||
@@ -29,6 +30,7 @@ function setDestinationLoading(isLoading) {
|
||||
saveDestinationBtn.disabled = isLoading;
|
||||
openUnroutedBtn.disabled = isLoading;
|
||||
openDuplicatesBtn.disabled = isLoading;
|
||||
openSkippedBtn.disabled = isLoading;
|
||||
clearPreviewBtn.disabled = isLoading;
|
||||
}
|
||||
|
||||
@@ -60,18 +62,14 @@ function hidePreview() {
|
||||
}
|
||||
|
||||
async function loadPreviewData(kind) {
|
||||
if (kind === 'duplicates') {
|
||||
return window.api.listDuplicatesFiles();
|
||||
}
|
||||
|
||||
if (kind === 'duplicates') return window.api.listDuplicatesFiles();
|
||||
if (kind === 'skipped') return window.api.listSkippedFiles();
|
||||
return window.api.listUnroutedFiles();
|
||||
}
|
||||
|
||||
async function clearPreviewData(kind) {
|
||||
if (kind === 'duplicates') {
|
||||
return window.api.clearDuplicatesFiles();
|
||||
}
|
||||
|
||||
if (kind === 'duplicates') return window.api.clearDuplicatesFiles();
|
||||
if (kind === 'skipped') return window.api.clearSkippedFiles();
|
||||
return window.api.clearUnroutedFiles();
|
||||
}
|
||||
|
||||
@@ -248,7 +246,22 @@ openDuplicatesBtn.addEventListener('click', async () => {
|
||||
destinationStatus.textContent = 'Caricamento anteprima duplicati...';
|
||||
|
||||
const result = await window.api.listDuplicatesFiles();
|
||||
showPreview('duplicates', 'Anteprima duplicati', result, 'Nessun file presente in duplicati.');
|
||||
showPreview('duplicates', 'Anteprima __DUPLICATI', result, 'Nessun file presente in __DUPLICATI.');
|
||||
destinationStatus.textContent = `Anteprima caricata (${result.files?.length || 0} file).`;
|
||||
} catch (error) {
|
||||
destinationStatus.textContent = `Errore: ${error.message}`;
|
||||
} finally {
|
||||
setDestinationLoading(false);
|
||||
}
|
||||
});
|
||||
|
||||
openSkippedBtn.addEventListener('click', async () => {
|
||||
try {
|
||||
setDestinationLoading(true);
|
||||
destinationStatus.textContent = 'Caricamento anteprima saltati...';
|
||||
|
||||
const result = await window.api.listSkippedFiles();
|
||||
showPreview('skipped', 'Anteprima __SALTATI', result, 'Nessun file presente in __SALTATI.');
|
||||
destinationStatus.textContent = `Anteprima caricata (${result.files?.length || 0} file).`;
|
||||
} catch (error) {
|
||||
destinationStatus.textContent = `Errore: ${error.message}`;
|
||||
@@ -263,9 +276,12 @@ clearPreviewBtn.addEventListener('click', async () => {
|
||||
}
|
||||
|
||||
const isDuplicates = currentPreviewKind === 'duplicates';
|
||||
const isSkipped = currentPreviewKind === 'skipped';
|
||||
const confirmMessage = isDuplicates
|
||||
? 'Confermi la pulizia della cartella duplicati?'
|
||||
: 'Confermi la pulizia della cartella non smistati?';
|
||||
? 'Confermi la pulizia della cartella __DUPLICATI?'
|
||||
: isSkipped
|
||||
? 'Confermi la pulizia della cartella saltati?'
|
||||
: 'Confermi la pulizia della cartella non smistati?';
|
||||
|
||||
if (!window.confirm(confirmMessage)) {
|
||||
return;
|
||||
@@ -277,10 +293,12 @@ clearPreviewBtn.addEventListener('click', async () => {
|
||||
|
||||
const clearResult = await clearPreviewData(currentPreviewKind);
|
||||
const refreshed = await loadPreviewData(currentPreviewKind);
|
||||
const title = isDuplicates ? 'Anteprima duplicati' : 'Anteprima __NON_SMISTATI';
|
||||
const title = isDuplicates ? 'Anteprima __DUPLICATI' : isSkipped ? 'Anteprima __SALTATI' : 'Anteprima __NON_SMISTATI';
|
||||
const emptyMessage = isDuplicates
|
||||
? 'Nessun file presente in duplicati.'
|
||||
: 'Nessun file presente in __NON_SMISTATI.';
|
||||
? 'Nessun file presente in __DUPLICATI.'
|
||||
: isSkipped
|
||||
? 'Nessun file presente in __SALTATI.'
|
||||
: 'Nessun file presente in __NON_SMISTATI.';
|
||||
|
||||
showPreview(currentPreviewKind, title, refreshed, emptyMessage);
|
||||
destinationStatus.textContent = `Cartella pulita: ${clearResult.directory}`;
|
||||
|
||||
@@ -3,7 +3,7 @@ const path = require('path');
|
||||
const { getDestinationDecision, getCadInfo } = require('./router');
|
||||
const { buildDestinationIndex } = require('./destinationIndex');
|
||||
const { buildExistingCadKeyIndex, toCadKey } = require('./duplicateIndex');
|
||||
const { prepareUnroutedTarget, prepareDuplicateTarget } = require('./unrouted');
|
||||
const { prepareUnroutedTarget, prepareDuplicateTarget, getSkippedTarget } = require('./unrouted');
|
||||
|
||||
function parseNumericVersion(version) {
|
||||
const rawVersion = String(version || '').trim();
|
||||
@@ -86,7 +86,10 @@ async function processFolder(folder, config) {
|
||||
|
||||
const cadInfo = getCadInfo(file);
|
||||
if (!cadInfo) {
|
||||
const skippedTarget = await getSkippedTarget(file);
|
||||
await fs.copy(fullPath, skippedTarget.destinationPath);
|
||||
result.skipped += 1;
|
||||
result.copied += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,10 @@ const { getCadInfo } = require('./router');
|
||||
|
||||
const PRIMARY_UNROUTED_DIR = '/cadroute/__NON_SMISTATI';
|
||||
const HOME_UNROUTED_DIR = path.join(os.homedir(), '.cadroute', '__NON_SMISTATI');
|
||||
const PRIMARY_DUPLICATES_DIR = '/cadroute/duplicati';
|
||||
const HOME_DUPLICATES_DIR = path.join(os.homedir(), '.cadroute', 'duplicati');
|
||||
const PRIMARY_DUPLICATES_DIR = '/cadroute/__DUPLICATI';
|
||||
const HOME_DUPLICATES_DIR = path.join(os.homedir(), '.cadroute', '__DUPLICATI');
|
||||
const PRIMARY_SKIPPED_DIR = '/cadroute/__SALTATI';
|
||||
const HOME_SKIPPED_DIR = path.join(os.homedir(), '.cadroute', '__SALTATI');
|
||||
|
||||
const SPECIAL_TARGETS = {
|
||||
unrouted: {
|
||||
@@ -17,6 +19,10 @@ const SPECIAL_TARGETS = {
|
||||
primary: PRIMARY_DUPLICATES_DIR,
|
||||
fallback: HOME_DUPLICATES_DIR,
|
||||
},
|
||||
skipped: {
|
||||
primary: PRIMARY_SKIPPED_DIR,
|
||||
fallback: HOME_SKIPPED_DIR,
|
||||
},
|
||||
};
|
||||
|
||||
const resolvedDirs = new Map();
|
||||
@@ -178,6 +184,22 @@ async function prepareDuplicateTarget(fileName) {
|
||||
return prepareSpecialTarget('duplicates', fileName);
|
||||
}
|
||||
|
||||
async function resolveSkippedDir() {
|
||||
return resolveTargetDir('skipped');
|
||||
}
|
||||
|
||||
async function getSkippedTarget(fileName) {
|
||||
return getTarget('skipped', fileName);
|
||||
}
|
||||
|
||||
async function listSkippedFiles() {
|
||||
return listTargetFiles('skipped');
|
||||
}
|
||||
|
||||
async function clearSkippedFiles() {
|
||||
return clearTargetFiles('skipped');
|
||||
}
|
||||
|
||||
async function listFilesRecursively(rootDir) {
|
||||
const files = [];
|
||||
|
||||
@@ -251,16 +273,22 @@ async function clearDuplicateFiles() {
|
||||
module.exports = {
|
||||
getUnroutedTarget,
|
||||
getDuplicateTarget,
|
||||
getSkippedTarget,
|
||||
prepareUnroutedTarget,
|
||||
prepareDuplicateTarget,
|
||||
resolveUnroutedDir,
|
||||
resolveDuplicatesDir,
|
||||
resolveSkippedDir,
|
||||
listUnroutedFiles,
|
||||
listDuplicateFiles,
|
||||
listSkippedFiles,
|
||||
clearUnroutedFiles,
|
||||
clearDuplicateFiles,
|
||||
clearSkippedFiles,
|
||||
PRIMARY_UNROUTED_DIR,
|
||||
HOME_UNROUTED_DIR,
|
||||
PRIMARY_DUPLICATES_DIR,
|
||||
HOME_DUPLICATES_DIR,
|
||||
PRIMARY_SKIPPED_DIR,
|
||||
HOME_SKIPPED_DIR,
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@ const { pipeline } = require('stream/promises');
|
||||
const { getDestinationDecision, getCadInfo } = require('./router');
|
||||
const { buildDestinationIndex } = require('./destinationIndex');
|
||||
const { buildExistingCadKeyIndex, toCadKey } = require('./duplicateIndex');
|
||||
const { prepareUnroutedTarget, prepareDuplicateTarget } = require('./unrouted');
|
||||
const { prepareUnroutedTarget, prepareDuplicateTarget, getSkippedTarget } = require('./unrouted');
|
||||
|
||||
function parseNumericVersion(version) {
|
||||
const rawVersion = String(version || '').trim();
|
||||
@@ -82,8 +82,10 @@ async function processZip(zipPath, config) {
|
||||
|
||||
const cadInfo = getCadInfo(baseName);
|
||||
if (!cadInfo) {
|
||||
const skippedTarget = await getSkippedTarget(baseName);
|
||||
await pipeline(entry, fs.createWriteStream(skippedTarget.destinationPath));
|
||||
result.skipped += 1;
|
||||
entry.autodrain();
|
||||
result.copied += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user