Salva apre il «Salva con nome» prima di scaricare; riepilogo senza deviazione 0 per quota NaN (Refs #119 #118)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019A9CSrh9rfM5WwqKtg8BSE
This commit is contained in:
@@ -440,7 +440,8 @@ def task_complete(recipe_id: int):
|
|||||||
m["subtask"] = st
|
m["subtask"] = st
|
||||||
m["task_info"] = subtask_task_map.get(m.get("subtask_id"), {})
|
m["task_info"] = subtask_task_map.get(m.get("subtask_id"), {})
|
||||||
# Compute deviation if not present
|
# Compute deviation if not present
|
||||||
if m.get("deviation") is None and st.get("nominal") is not None:
|
# #118: quota non misurata (value None): la deviazione resta None (il template mostra NaN)
|
||||||
|
if m.get("deviation") is None and st.get("nominal") is not None and m.get("value") is not None:
|
||||||
try:
|
try:
|
||||||
m["deviation"] = m["value"] - st["nominal"]
|
m["deviation"] = m["value"] - st["nominal"]
|
||||||
except (TypeError, KeyError):
|
except (TypeError, KeyError):
|
||||||
|
|||||||
@@ -40,17 +40,22 @@ async function tmfBlobToPng(blob) {
|
|||||||
|
|
||||||
// #119: scarica `src`, lo porta a PNG e lo salva; true = salvato, false = annullato dall'utente o errore
|
// #119: scarica `src`, lo porta a PNG e lo salva; true = salvato, false = annullato dall'utente o errore
|
||||||
async function tmfSaveImage(src, baseName) {
|
async function tmfSaveImage(src, baseName) {
|
||||||
|
if (!src) return false; // #119: nessuna immagine mostrata
|
||||||
try {
|
try {
|
||||||
|
var name = tmfSaveImageName(baseName, new Date());
|
||||||
|
// #119: «Salva con nome» per primo, finche' vale il gesto dell'utente (Chrome lo rifiuta dopo ~5 s di fetch e conversione)
|
||||||
|
var handle = null;
|
||||||
|
if (typeof window !== 'undefined' && typeof window.showSaveFilePicker === 'function') {
|
||||||
|
handle = await window.showSaveFilePicker({
|
||||||
|
suggestedName: name,
|
||||||
|
types: [{ description: 'PNG', accept: { 'image/png': ['.png'] } }],
|
||||||
|
});
|
||||||
|
}
|
||||||
var resp = await fetch(src);
|
var resp = await fetch(src);
|
||||||
if (!resp.ok) return false;
|
if (!resp.ok) return false;
|
||||||
var blob = await resp.blob();
|
var blob = await resp.blob();
|
||||||
if (blob.type !== 'image/png') blob = await tmfBlobToPng(blob);
|
if (blob.type !== 'image/png') blob = await tmfBlobToPng(blob);
|
||||||
var name = tmfSaveImageName(baseName, new Date());
|
if (handle) {
|
||||||
if (typeof window !== 'undefined' && typeof window.showSaveFilePicker === 'function') {
|
|
||||||
var handle = await window.showSaveFilePicker({
|
|
||||||
suggestedName: name,
|
|
||||||
types: [{ description: 'PNG', accept: { 'image/png': ['.png'] } }],
|
|
||||||
});
|
|
||||||
var w = await handle.createWritable();
|
var w = await handle.createWritable();
|
||||||
await w.write(blob);
|
await w.write(blob);
|
||||||
await w.close();
|
await w.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user