推进 INI 面板 control view helper

This commit is contained in:
2026-06-14 22:40:47 +08:00
parent e6f55d775f
commit 4133d202f0
6 changed files with 237 additions and 2 deletions

View File

@@ -46,6 +46,7 @@ import {
saveMachineSessionSnapshotWorkflow,
} from "./session-workflow.js";
import {
createMachineSessionControlView,
createMachineSessionStateSnapshot,
createMachineSessionStateBundle,
createMachineSessionStateReport,
@@ -171,6 +172,10 @@ function getMachineSessionStateBundle() {
return createMachineSessionStateBundle(window.linuxCncIniPanelMachineSessionState);
}
function getMachineSessionControlView() {
return createMachineSessionControlView(getMachineSessionStateBundle());
}
function updatePanelMachineSessionState(patch = {}) {
panelMachineSessionState = createMachineSessionStateSnapshot({
...panelMachineSessionState,
@@ -185,11 +190,13 @@ function updatePanelMachineSessionState(patch = {}) {
}
window.linuxCncIniPanelApi = {
getMachineSessionControlView,
getMachineSessionStateBundle,
getMachineSessionStateReport,
getMachineSessionStateReportExport,
getMachineSessionWorkflowStatus,
};
window.getMachineSessionControlView = getMachineSessionControlView;
window.getMachineSessionStateBundle = getMachineSessionStateBundle;
window.getMachineSessionStateReport = getMachineSessionStateReport;
window.getMachineSessionStateReportExport = getMachineSessionStateReportExport;

View File

@@ -140,3 +140,48 @@ export function createMachineSessionStateBundle(state = {}, options = {}) {
workflowStatus,
};
}
export function createMachineSessionControlView(bundle = {}) {
const report = bundle.report ?? {};
const workflowStatus = bundle.workflowStatus ?? {};
const session = workflowStatus.session ?? report.session ?? {};
const run = workflowStatus.run ?? report.run ?? {};
return {
status: {
lastAction: workflowStatus.lastAction ?? report.status?.lastAction ?? null,
error: workflowStatus.error ?? report.status?.error ?? null,
runStatus: run.status ?? null,
},
sections: [
{
id: "readiness",
title: "Readiness",
rows: [
{ label: "INI", value: workflowStatus.readiness?.ini ?? report.readiness?.ini ?? null },
{ label: "Interpreter", value: workflowStatus.readiness?.interp ?? report.readiness?.interp ?? null },
{ label: "OPFS", value: workflowStatus.readiness?.opfs ?? report.readiness?.opfs ?? null },
],
},
{
id: "session",
title: "Session",
rows: [
{ label: "Snapshot", value: session.snapshotLabel ?? null },
{ label: "Workflow", value: session.workflow ?? null },
{ label: "INI", value: session.ini ?? null },
{ label: "G-code", value: session.gcode ?? null },
],
},
{
id: "run",
title: "Run",
rows: [
{ label: "Status", value: run.status ?? null },
{ label: "Canonical events", value: run.canonicalEventCount ?? 0 },
{ label: "Motion snapshots", value: run.motionSnapshotCount ?? 0 },
{ label: "INI WASM", value: run.iniWasmPath ?? null },
],
},
],
};
}