feat: unifica lo smistamento CAD su destinazione unica configurabile da UI
This commit is contained in:
@@ -84,6 +84,66 @@
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.rules {
|
||||
margin-top: 18px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
padding: 14px;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.rules h2 {
|
||||
margin: 0 0 10px;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.rule-row {
|
||||
display: grid;
|
||||
grid-template-columns: 180px 1fr auto auto;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.rule-row.single-row {
|
||||
grid-template-columns: 1fr auto auto;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.rule-label {
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.rule-row input {
|
||||
min-width: 0;
|
||||
padding: 9px 10px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.rule-row button {
|
||||
padding: 9px 12px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.rule-row button.browse {
|
||||
background: #334155;
|
||||
}
|
||||
|
||||
.rule-status {
|
||||
margin-top: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.rule-row {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
pre {
|
||||
margin-top: 18px;
|
||||
padding: 14px;
|
||||
@@ -98,15 +158,23 @@
|
||||
</head>
|
||||
<body>
|
||||
<main class="page">
|
||||
<h1>CAD File Router MVP</h1>
|
||||
<p>Seleziona una cartella o uno ZIP. I file .prt/.asm/.drw verranno copiati in base alle regole.</p>
|
||||
<h1>Smistatore automatico</h1>
|
||||
<p>Seleziona una cartella o uno ZIP con i disegni da smistare</p>
|
||||
|
||||
<div class="actions">
|
||||
<button id="folderBtn">Process Folder</button>
|
||||
<button id="zipBtn" class="secondary">Process ZIP</button>
|
||||
</div>
|
||||
|
||||
<div class="info" id="configInfo">Caricamento configurazione...</div>
|
||||
<section class="rules">
|
||||
<h2>Destinazione file CAD</h2>
|
||||
<div class="rule-row single-row">
|
||||
<input id="destinationInput" type="text" placeholder="Percorso destinazione..." />
|
||||
<button id="browseDestinationBtn" class="browse">Sfoglia</button>
|
||||
<button id="saveDestinationBtn">Salva</button>
|
||||
</div>
|
||||
<div class="rule-status" id="destinationStatus"></div>
|
||||
</section>
|
||||
<pre id="output">Pronto.</pre>
|
||||
</main>
|
||||
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
const folderBtn = document.getElementById('folderBtn');
|
||||
const zipBtn = document.getElementById('zipBtn');
|
||||
const output = document.getElementById('output');
|
||||
const configInfo = document.getElementById('configInfo');
|
||||
const destinationInput = document.getElementById('destinationInput');
|
||||
const browseDestinationBtn = document.getElementById('browseDestinationBtn');
|
||||
const saveDestinationBtn = document.getElementById('saveDestinationBtn');
|
||||
const destinationStatus = document.getElementById('destinationStatus');
|
||||
|
||||
function setLoading(isLoading) {
|
||||
folderBtn.disabled = isLoading;
|
||||
zipBtn.disabled = isLoading;
|
||||
}
|
||||
|
||||
function setDestinationLoading(isLoading) {
|
||||
destinationInput.disabled = isLoading;
|
||||
browseDestinationBtn.disabled = isLoading;
|
||||
saveDestinationBtn.disabled = isLoading;
|
||||
}
|
||||
|
||||
function renderResult(title, result) {
|
||||
const details = (result.details || []).slice(0, 20);
|
||||
const detailsText = details.length
|
||||
@@ -50,6 +59,55 @@ async function handleAction(actionName, actionFn) {
|
||||
folderBtn.addEventListener('click', () => handleAction('Process Folder', window.api.selectFolder));
|
||||
zipBtn.addEventListener('click', () => handleAction('Process ZIP', window.api.selectZip));
|
||||
|
||||
window.api.getConfigPath().then(({ configPath }) => {
|
||||
configInfo.textContent = `Config utente: ${configPath}`;
|
||||
browseDestinationBtn.addEventListener('click', async () => {
|
||||
try {
|
||||
setDestinationLoading(true);
|
||||
destinationStatus.textContent = 'Seleziona una cartella...';
|
||||
|
||||
const result = await window.api.selectDestinationFolder();
|
||||
if (!result || result.canceled) {
|
||||
destinationStatus.textContent = 'Selezione annullata.';
|
||||
return;
|
||||
}
|
||||
|
||||
destinationInput.value = result.path;
|
||||
destinationStatus.textContent = 'Cartella selezionata. Premi Salva.';
|
||||
} catch (error) {
|
||||
destinationStatus.textContent = `Errore: ${error.message}`;
|
||||
} finally {
|
||||
setDestinationLoading(false);
|
||||
}
|
||||
});
|
||||
|
||||
saveDestinationBtn.addEventListener('click', async () => {
|
||||
const destination = destinationInput.value.trim();
|
||||
if (!destination) {
|
||||
destinationStatus.textContent = 'Inserisci una destinazione valida.';
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
setDestinationLoading(true);
|
||||
destinationStatus.textContent = 'Salvataggio in corso...';
|
||||
|
||||
const result = await window.api.updateDestination(destination);
|
||||
destinationInput.value = result.destination;
|
||||
destinationStatus.textContent = 'Destinazione salvata.';
|
||||
} catch (error) {
|
||||
destinationStatus.textContent = `Errore: ${error.message}`;
|
||||
} finally {
|
||||
setDestinationLoading(false);
|
||||
}
|
||||
});
|
||||
|
||||
async function initConfigUI() {
|
||||
try {
|
||||
const destinationResult = await window.api.getDestination();
|
||||
destinationInput.value = destinationResult.destination || '';
|
||||
destinationStatus.textContent = '';
|
||||
} catch (error) {
|
||||
destinationStatus.textContent = 'Impossibile caricare la destinazione.';
|
||||
}
|
||||
}
|
||||
|
||||
initConfigUI();
|
||||
|
||||
Reference in New Issue
Block a user