From b6fc0565ee639b1223a5890a51f0c8f794dfb5b4 Mon Sep 17 00:00:00 2001 From: Jo Date: Tue, 7 Jul 2026 09:25:57 +0200 Subject: [PATCH] feat: Bambu NC picker, collapsed by default, sidebar toggle fix, settings layout --- templates/base.html | 10 ++++++++-- templates/new_job.html | 42 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/templates/base.html b/templates/base.html index bd9d973..6b8075a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -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 { diff --git a/templates/new_job.html b/templates/new_job.html index 6a9c099..a91ec7a 100644 --- a/templates/new_job.html +++ b/templates/new_job.html @@ -22,14 +22,20 @@
-
- +
+ + ou +
-
Votre fichier .3mf depuis Bambu Studio pour remplir poids et durée automatiquement.
+
Choisissez un fichier local .3mf ou parcourez Nextcloud — poids et durée seront remplis automatiquement, et le fichier source sera défini.
@@ -63,7 +69,8 @@ value="{{ prefill.source_file if prefill else '' }}"> @@ -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 = '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 = + `${e.message}`; + } + } + ncPickerMode = 'source'; // reset } // Ouvrir = charger le dossier racine