feat: auto-reparse Nextcloud 3mf on job clone (source_nc_path stored in DB)
Deploy via Portainer / deploy (push) Successful in 0s

This commit is contained in:
Jo
2026-07-07 14:59:04 +02:00
parent 0069ab2592
commit 3da19f55a5
2 changed files with 141 additions and 8 deletions
+31
View File
@@ -67,6 +67,8 @@
<input type="text" name="source_file" id="sourceFile" class="form-control"
placeholder="nom_fichier.3mf"
value="{{ prefill.source_file if prefill else '' }}">
<input type="hidden" name="source_nc_path" id="sourceNcPath"
value="{{ prefill.source_nc_path if prefill else '' }}">
<button type="button" class="btn btn-outline-secondary" id="ncBrowseBtn"
data-bs-toggle="modal" data-bs-target="#ncPickerModal"
title="Parcourir Nextcloud"
@@ -883,6 +885,9 @@ let ncPickerMode = 'source'; // 'source' = remplit seulement sourceFile, 'bambu'
}
bootstrap.Modal.getInstance(modal).hide();
// Toujours sauvegarder le chemin Nextcloud pour permettre la duplication
document.getElementById('sourceNcPath').value = item.path;
// Mode Bambu : télécharger et parser le 3MF (gcode.3mf ou projet)
if (ncPickerMode === 'bambu' && (is3mf || isGcode3mf)) {
const status = document.getElementById('parseStatus');
@@ -904,6 +909,32 @@ let ncPickerMode = 'source'; // 'source' = remplit seulement sourceFile, 'bambu'
ncPickerMode = 'source'; // reset
}
// ── Auto-parse au chargement (duplication avec source_nc_path) ────────────
(async function autoParseOnClone() {
const ncPath = document.getElementById('sourceNcPath').value;
if (!ncPath) return;
const status = document.getElementById('parseStatus');
if (!status) return;
status.innerHTML = '<span class="spinner-border spinner-border-sm me-1"></span>Rechargement des plateaux…';
try {
const r = await fetch('/api/nextcloud/parse?path=' + encodeURIComponent(ncPath));
const d = await r.json();
if (d.error) { status.innerHTML = `<span class="text-warning"><i class="bi bi-exclamation-triangle me-1"></i>${d.error}</span>`; return; }
if (d.plates && d.plates.length > 1) {
_3mfPlates = d.plates;
renderPlateSelector(d.plates);
status.innerHTML = `<span class="text-success">${d.plates.length} plateau(x) disponibles — choisissez ou modifiez</span>`;
} else if (d.plates && d.plates.length === 1) {
status.innerHTML = '<span class="text-success"><i class="bi bi-check-circle me-1"></i>Données extraites</span>';
} else {
status.innerHTML = '<span class="text-muted small">Fichier source lié — plateaux non disponibles</span>';
}
} catch(e) {
status.innerHTML = '<span class="text-muted small">Fichier source lié (réimportez si besoin)</span>';
}
})();
// Ouvrir = charger le dossier racine + afficher/masquer hint bambu
modal.addEventListener('show.bs.modal', () => {
bambuHint.classList.toggle('d-none', ncPickerMode !== 'bambu');