feat: Bambu NC picker, collapsed by default, sidebar toggle fix, settings layout
Deploy via Portainer / deploy (push) Successful in 0s

This commit is contained in:
Jo
2026-07-07 09:25:57 +02:00
parent b22e5e0fb4
commit b6fc0565ee
2 changed files with 44 additions and 8 deletions
+8 -2
View File
@@ -29,7 +29,7 @@
font-weight: 700; font-size: 1.1rem;
border-bottom: 1px solid #2e323d;
display: flex; align-items: center; justify-content: space-between;
white-space: nowrap;
white-space: nowrap; position: relative;
}
#sidebar .brand .brand-text { transition: opacity .15s; }
#sidebar.collapsed .brand .brand-text { opacity: 0; pointer-events: none; }
@@ -38,10 +38,16 @@
#sidebarToggle {
background: none; border: none; color: #9ba3af; cursor: pointer;
padding: .2rem .3rem; border-radius: 4px; flex-shrink: 0;
transition: color .15s, background .15s;
transition: color .15s, background .15s, right .2s ease;
font-size: 1rem; line-height: 1;
position: relative; z-index: 1;
}
#sidebarToggle:hover { color: #fff; background: #2e323d; }
/* En mode replié, centrer le bouton dans les 52px */
#sidebar.collapsed #sidebarToggle {
position: absolute;
left: 50%; transform: translateX(-50%);
}
#sidebar nav { flex: 1; padding: .5rem 0; overflow: hidden; }
#sidebar nav a {
+36 -6
View File
@@ -22,14 +22,20 @@
</div>
<div class="collapse" id="bambuBody">
<div class="card-body">
<div class="d-flex align-items-center gap-3">
<input type="file" id="file3mf" accept=".3mf" class="form-control" style="max-width:320px">
<div class="d-flex align-items-center gap-2 flex-wrap">
<input type="file" id="file3mf" accept=".3mf" class="form-control" style="max-width:260px">
<button type="button" class="btn btn-outline-warning" onclick="parse3mf()">
<i class="bi bi-magic me-1"></i>Extraire
</button>
<span class="text-muted small">ou</span>
<button type="button" class="btn btn-outline-secondary" id="ncBambuBtn"
data-bs-toggle="modal" data-bs-target="#ncPickerModal"
onclick="ncPickerMode='bambu'">
<i class="bi bi-cloud-arrow-down me-1"></i>Nextcloud
</button>
<span id="parseStatus" class="text-muted small"></span>
</div>
<div class="form-text mt-1">Votre fichier .3mf depuis Bambu Studio pour remplir poids et durée automatiquement.</div>
<div class="form-text mt-1">Choisissez un fichier local <strong>.3mf</strong> ou parcourez Nextcloud — poids et durée seront remplis automatiquement, et le fichier source sera défini.</div>
</div>
</div>
</div>
@@ -63,7 +69,8 @@
value="{{ prefill.source_file if prefill else '' }}">
<button type="button" class="btn btn-outline-secondary" id="ncBrowseBtn"
data-bs-toggle="modal" data-bs-target="#ncPickerModal"
title="Parcourir Nextcloud">
title="Parcourir Nextcloud"
onclick="ncPickerMode='source'">
<i class="bi bi-cloud-arrow-down"></i>
</button>
</div>
@@ -332,7 +339,7 @@
const KEY = 'bambu_open';
const body = document.getElementById('bambuBody');
const chevron = document.getElementById('bambuChevron');
const isOpen = localStorage.getItem(KEY) !== 'false'; // open by default
const isOpen = localStorage.getItem(KEY) === 'true'; // collapsed by default
if (isOpen) {
body.classList.add('show');
chevron.style.transform = 'rotate(180deg)';
@@ -707,6 +714,7 @@ updateMarginDisplay(_initMargin);
if (document.getElementById('weight_g').value) recalc();
// ── Nextcloud File Picker ─────────────────────────────────────────────────────
let ncPickerMode = 'source'; // 'source' = remplit seulement sourceFile, 'bambu' = remplit + parse 3MF
(function () {
const modal = document.getElementById('ncPickerModal');
const body = document.getElementById('ncPickerBody');
@@ -781,7 +789,8 @@ if (document.getElementById('weight_g').value) recalc();
body.appendChild(list);
}
function selectFile(item) {
async function selectFile(item) {
// Toujours remplir le fichier source
sfInput.value = item.path;
// Auto-remplir le nom de commande si vide
const nameField = document.getElementById('jobName');
@@ -789,6 +798,27 @@ if (document.getElementById('weight_g').value) recalc();
nameField.value = item.name.replace(/\.[^.]+$/, '');
}
bootstrap.Modal.getInstance(modal).hide();
// Mode Bambu : récupérer le fichier depuis Nextcloud et le parser comme un 3MF
if (ncPickerMode === 'bambu' && item.name.toLowerCase().endsWith('.3mf')) {
const status = document.getElementById('parseStatus');
status.innerHTML = '<span class="spinner-border spinner-border-sm me-1"></span>Téléchargement…';
try {
const resp = await fetch('/api/nextcloud/file?path=' + encodeURIComponent(item.path));
if (!resp.ok) throw new Error('Erreur téléchargement Nextcloud');
const blob = await resp.blob();
const file = new File([blob], item.name, { type: 'application/octet-stream' });
// Injecter dans l'input local (pour réutiliser parse3mf())
const dt = new DataTransfer();
dt.items.add(file);
document.getElementById('file3mf').files = dt.files;
await parse3mf();
} catch (e) {
document.getElementById('parseStatus').innerHTML =
`<span class="text-danger"><i class="bi bi-x-circle me-1"></i>${e.message}</span>`;
}
}
ncPickerMode = 'source'; // reset
}
// Ouvrir = charger le dossier racine