推进 INI 面板 session snapshot workflow helper
This commit is contained in:
65
wasm-port/runtime/ui/ini-panel/session-workflow.js
Normal file
65
wasm-port/runtime/ui/ini-panel/session-workflow.js
Normal file
@@ -0,0 +1,65 @@
|
||||
import {
|
||||
createSessionSnapshotSummary,
|
||||
sessionSnapshotSummaryLogLines,
|
||||
} from "./session-summary.js";
|
||||
|
||||
export function createSessionSnapshotFieldState(summary) {
|
||||
return {
|
||||
sessionIni: summary.iniOpfsPath,
|
||||
sessionParameters: summary.parameterOpfsPath,
|
||||
sessionToolTable: summary.toolTableOpfsPath,
|
||||
sessionGcode: summary.gcodeOpfsPath,
|
||||
sessionSnapshot: summary.snapshotLabel,
|
||||
};
|
||||
}
|
||||
|
||||
export function sessionSnapshotSaveLogLines(summary) {
|
||||
return [
|
||||
...sessionSnapshotSummaryLogLines(summary),
|
||||
`INI: ${summary.iniOpfsPath}`,
|
||||
`Parameter file: ${summary.parameterOpfsPath}`,
|
||||
`Tool table file: ${summary.toolTableOpfsPath}`,
|
||||
`G-code: ${summary.gcodeOpfsPath}`,
|
||||
];
|
||||
}
|
||||
|
||||
export async function saveMachineSessionSnapshotWorkflow({
|
||||
machineId,
|
||||
snapshotId,
|
||||
snapshotFilename,
|
||||
snapshotLabel,
|
||||
iniText,
|
||||
toolTableText,
|
||||
parameterText,
|
||||
gcodeFilename,
|
||||
gcodeText,
|
||||
metadata,
|
||||
saveMachineTextFiles,
|
||||
saveGcodeProgram,
|
||||
saveMachineSessionSnapshot,
|
||||
}) {
|
||||
await Promise.all([
|
||||
saveMachineTextFiles(machineId, {
|
||||
ini: iniText,
|
||||
toolTable: toolTableText,
|
||||
parameters: parameterText,
|
||||
}),
|
||||
saveGcodeProgram(gcodeFilename, gcodeText),
|
||||
]);
|
||||
const snapshot = await saveMachineSessionSnapshot(
|
||||
snapshotId,
|
||||
machineId,
|
||||
{
|
||||
filename: snapshotFilename,
|
||||
gcodeFilename,
|
||||
metadata,
|
||||
},
|
||||
);
|
||||
const summary = createSessionSnapshotSummary(snapshot, snapshotLabel);
|
||||
return {
|
||||
snapshot,
|
||||
summary,
|
||||
fields: createSessionSnapshotFieldState(summary),
|
||||
logLines: sessionSnapshotSaveLogLines(summary),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user