feat: Bambu NC picker, collapsed by default, sidebar toggle fix, settings layout
Deploy via Portainer / deploy (push) Successful in 0s
Deploy via Portainer / deploy (push) Successful in 0s
This commit is contained in:
+36
-6
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user