Commit iniziale
This commit is contained in:
115
renderer/index.html
Normal file
115
renderer/index.html
Normal file
@@ -0,0 +1,115 @@
|
||||
<!doctype html>
|
||||
<html lang="it">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>CAD File Router</title>
|
||||
<style>
|
||||
:root {
|
||||
color-scheme: light;
|
||||
--bg: #f6f8fb;
|
||||
--card: #ffffff;
|
||||
--text: #0f172a;
|
||||
--muted: #475569;
|
||||
--accent: #0b5fff;
|
||||
--border: #dbe2ea;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: linear-gradient(130deg, #eaf0ff 0%, var(--bg) 45%, #f9fbff 100%);
|
||||
color: var(--text);
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
}
|
||||
|
||||
.page {
|
||||
max-width: 820px;
|
||||
margin: 40px auto;
|
||||
background: var(--card);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
padding: 26px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
button {
|
||||
border: 1px solid transparent;
|
||||
background: var(--accent);
|
||||
color: white;
|
||||
border-radius: 10px;
|
||||
padding: 11px 16px;
|
||||
font-size: 15px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button.secondary {
|
||||
background: #1f2937;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
opacity: 0.92;
|
||||
}
|
||||
|
||||
button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
.info {
|
||||
margin-top: 18px;
|
||||
padding: 14px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--border);
|
||||
background: #f8fafc;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin-top: 18px;
|
||||
padding: 14px;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--border);
|
||||
background: #0f172a;
|
||||
color: #e2e8f0;
|
||||
overflow: auto;
|
||||
min-height: 180px;
|
||||
}
|
||||
</style>
|
||||
</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>
|
||||
|
||||
<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>
|
||||
<pre id="output">Pronto.</pre>
|
||||
</main>
|
||||
|
||||
<script src="./renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
55
renderer/renderer.js
Normal file
55
renderer/renderer.js
Normal file
@@ -0,0 +1,55 @@
|
||||
const folderBtn = document.getElementById('folderBtn');
|
||||
const zipBtn = document.getElementById('zipBtn');
|
||||
const output = document.getElementById('output');
|
||||
const configInfo = document.getElementById('configInfo');
|
||||
|
||||
function setLoading(isLoading) {
|
||||
folderBtn.disabled = isLoading;
|
||||
zipBtn.disabled = isLoading;
|
||||
}
|
||||
|
||||
function renderResult(title, result) {
|
||||
const details = (result.details || []).slice(0, 20);
|
||||
const detailsText = details.length
|
||||
? details
|
||||
.map((d) => (d.destination ? `- ${d.file} -> ${d.destination}` : `- ${d.file}: ${d.reason}`))
|
||||
.join('\n')
|
||||
: '- nessun dettaglio';
|
||||
|
||||
output.textContent = [
|
||||
title,
|
||||
`scansionati: ${result.scanned ?? 0}`,
|
||||
`copiati: ${result.copied ?? 0}`,
|
||||
`saltati: ${result.skipped ?? 0}`,
|
||||
'',
|
||||
'dettagli (max 20):',
|
||||
detailsText,
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
async function handleAction(actionName, actionFn) {
|
||||
setLoading(true);
|
||||
output.textContent = `${actionName} in corso...`;
|
||||
|
||||
try {
|
||||
const result = await actionFn();
|
||||
|
||||
if (!result || result.canceled) {
|
||||
output.textContent = `${actionName} annullato.`;
|
||||
return;
|
||||
}
|
||||
|
||||
renderResult(actionName, result);
|
||||
} catch (error) {
|
||||
output.textContent = `${actionName} fallito:\n${error.message}`;
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
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}`;
|
||||
});
|
||||
Reference in New Issue
Block a user