Moonraker - added print time, filename, and disabled showing layer data when none is available
Added print time block that is available from print_stats endpoint. Added a check whether current and total layer info is available. It is not returned by the api if it is not explicitly configured in the slicer. Most of the time that is not a default setting. Added a filename display that shows the current file that is being printed. Similar layout as in jellyfin widget.
This commit is contained in:
parent
1e556e105d
commit
1b58bda714
@ -625,6 +625,7 @@
|
|||||||
"wanDownload": "WAN Download"
|
"wanDownload": "WAN Download"
|
||||||
},
|
},
|
||||||
"moonraker": {
|
"moonraker": {
|
||||||
|
"time": "Time",
|
||||||
"printer_state": "Printer State",
|
"printer_state": "Printer State",
|
||||||
"print_status": "Print Status",
|
"print_status": "Print Status",
|
||||||
"print_progress": "Progress",
|
"print_progress": "Progress",
|
||||||
|
|||||||
@ -35,16 +35,25 @@ export default function Component({ service }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const printStatsInfo = printStats.result.status.print_stats.info ?? {};
|
const printStatsInfo = printStats.result.status.print_stats.info ?? {};
|
||||||
|
const totalDurationSeconds = printStats.result.status.print_stats.total_duration ?? 0;
|
||||||
|
const fileName = printStats.result.status.print_stats.filename;
|
||||||
const { current_layer: currentLayer = "-", total_layer: totalLayer = "-" } = printStatsInfo;
|
const { current_layer: currentLayer = "-", total_layer: totalLayer = "-" } = printStatsInfo;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<Container service={service}>
|
<Container service={service}>
|
||||||
<Block label="moonraker.layers" value={`${currentLayer} / ${totalLayer}`} />
|
{/* current_layer and total_layer variables are not available if not exposed by the slicer */}
|
||||||
<Block
|
{currentLayer && totalLayer ? <Block label="moonraker.layers" value={`${currentLayer} / ${totalLayer}`} /> : null}
|
||||||
label="moonraker.print_progress"
|
<Block label="moonraker.print_progress" value={t("common.percent", { value: displayStatus.result.status.display_status.progress * 100 })} />
|
||||||
value={t("common.percent", { value: displayStatus.result.status.display_status.progress * 100 })}
|
{totalDurationSeconds > 0 ? <Block label="moonraker.time" value={t("common.duration", {value: totalDurationSeconds})} /> : null }
|
||||||
/>
|
|
||||||
<Block label="moonraker.print_status" value={printStats.result.status.print_stats.state} />
|
<Block label="moonraker.print_status" value={printStats.result.status.print_stats.state} />
|
||||||
</Container>
|
</Container>
|
||||||
|
{fileName ? <div className="flex flex-col pb-1 mx-1">
|
||||||
|
<div
|
||||||
|
className="text-theme-700 dark:text-theme-200 text-xs relative h-5 w-full rounded-md bg-theme-200/50 dark:bg-theme-900/20 mt-1">
|
||||||
|
<span className="absolute left-2 text-xs mt-[2px] w-full truncate pr-3">{fileName}</span>
|
||||||
|
</div>
|
||||||
|
</div> : null }
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user