feat: plate_name + pieces auto-fill + object names from 3MF
Deploy via Portainer / deploy (push) Successful in 0s

This commit is contained in:
Jo
2026-07-07 09:56:05 +02:00
parent d160686e0c
commit b571a5ef0c
3 changed files with 66 additions and 14 deletions
+4
View File
@@ -75,6 +75,10 @@
{% endif %}
{% else %}—{% endif %}
</td></tr>
{% if job.plate_name %}
<tr><th class="text-muted fw-normal">Référence plateau</th>
<td><span class="badge bg-light text-dark border">{{ job.plate_name }}</span></td></tr>
{% endif %}
<tr><th class="text-muted fw-normal">Date</th><td>{{ job.created_at[:10] }}</td></tr>
<tr><th class="text-muted fw-normal">Poids plateau</th><td>{{ job.weight_g }} g</td></tr>
<tr><th class="text-muted fw-normal">Pieces / plateau</th><td>{{ job.pieces_per_plate or 1 }}</td></tr>
+38 -7
View File
@@ -152,6 +152,15 @@
<div class="form-text">Nombre total de pièces à produire.</div>
</div>
</div>
<div class="row g-3 mt-0">
<div class="col-12">
<label class="form-label fw-semibold">Nom / référence du plateau <span class="text-muted fw-normal small">(optionnel)</span></label>
<input type="text" name="plate_name" id="plate_name" class="form-control"
placeholder="ex : «Plateau 2» ou nom custom Bambu Studio"
value="{{ prefill.plate_name if prefill else '' }}">
<div id="plateObjectsHint" class="form-text"></div>
</div>
</div>
</div>
</div>
@@ -387,7 +396,11 @@ function parse3mf() {
return;
}
// ── Plaque unique ou fallback ──
applyPlateData(d.weight_g, d.hours, d.minutes);
const p0 = (d.plates && d.plates.length === 1) ? d.plates[0] : null;
applyPlateData(d.weight_g, d.hours, d.minutes,
p0 ? p0.pieces : null,
p0 ? (p0.name || `Plateau ${p0.index}`) : null,
p0 ? p0.object_names : null);
const ok = d.weight_g || d.hours != null;
status.innerHTML = ok
? '<span class="text-success"><i class="bi bi-check-circle me-1"></i>Données extraites</span>'
@@ -396,10 +409,19 @@ function parse3mf() {
.catch(() => { status.innerHTML = '<span class="text-danger">Erreur de lecture</span>'; });
}
function applyPlateData(weight_g, hours, minutes) {
if (weight_g != null) document.getElementById('weight_g').value = weight_g;
if (hours != null) document.getElementById('hours').value = hours;
if (minutes != null) document.getElementById('minutes').value = minutes;
function applyPlateData(weight_g, hours, minutes, pieces, plate_name, object_names) {
if (weight_g != null) document.getElementById('weight_g').value = weight_g;
if (hours != null) document.getElementById('hours').value = hours;
if (minutes != null) document.getElementById('minutes').value = minutes;
if (pieces != null) document.getElementById('pieces_per_plate').value = pieces;
if (plate_name != null) document.getElementById('plate_name').value = plate_name;
// Afficher les noms des modèles comme aide
const hint = document.getElementById('plateObjectsHint');
if (hint && object_names && object_names.length) {
hint.innerHTML = `<i class="bi bi-layers me-1 text-muted"></i>Modèles : <span class="text-muted">${object_names.join(', ')}</span>`;
} else if (hint) {
hint.textContent = '';
}
recalc();
}
@@ -420,11 +442,20 @@ function renderPlateSelector(plates) {
const dots = p.filaments.map(f =>
`<span style="display:inline-block;width:10px;height:10px;border-radius:50%;background:${f.color || '#ccc'};border:1px solid #aaa;margin-right:2px"></span>`
).join('');
btn.innerHTML = `${dots}<strong>Plateau ${p.index}</strong> — ${p.weight_g} g — ${Math.floor(p.print_time_s/3600)}h${String(Math.floor((p.print_time_s%3600)/60)).padStart(2,'0')}m`;
const piecesLabel = p.pieces != null ? ` ${p.pieces} pce` : '';
const nameLabel = p.name ? ` «${p.name}»` : '';
btn.innerHTML = `${dots}<strong>Plateau ${p.index}${nameLabel}</strong> — ${p.weight_g} g — ${Math.floor(p.print_time_s/3600)}h${String(Math.floor((p.print_time_s%3600)/60)).padStart(2,'0')}m${piecesLabel}`;
btn.addEventListener('click', () => {
document.querySelectorAll('#plateSelectorWrap button').forEach(b => b.classList.replace('btn-warning','btn-outline-warning'));
btn.classList.replace('btn-outline-warning','btn-warning');
applyPlateData(p.weight_g, Math.floor(p.print_time_s/3600), Math.floor((p.print_time_s%3600)/60));
applyPlateData(
p.weight_g,
Math.floor(p.print_time_s/3600),
Math.floor((p.print_time_s%3600)/60),
p.pieces,
p.name || `Plateau ${p.index}`,
p.object_names
);
document.getElementById('parseStatus').innerHTML =
`<span class="text-success"><i class="bi bi-check-circle me-1"></i>Plateau ${p.index} appliqué</span>`;
});