推进 INI 面板状态 report JSON 导出 helper
This commit is contained in:
@@ -48,6 +48,7 @@ import {
|
||||
import {
|
||||
createMachineSessionStateSnapshot,
|
||||
createMachineSessionStateReport,
|
||||
createMachineSessionStateReportExport,
|
||||
} from "./panel-state-summary.js";
|
||||
|
||||
const SAMPLE_PATH =
|
||||
@@ -156,6 +157,10 @@ function getMachineSessionStateReport() {
|
||||
return createMachineSessionStateReport(window.linuxCncIniPanelMachineSessionState);
|
||||
}
|
||||
|
||||
function getMachineSessionStateReportExport() {
|
||||
return createMachineSessionStateReportExport(window.linuxCncIniPanelMachineSessionState);
|
||||
}
|
||||
|
||||
function updatePanelMachineSessionState(patch = {}) {
|
||||
panelMachineSessionState = createMachineSessionStateSnapshot({
|
||||
...panelMachineSessionState,
|
||||
@@ -170,6 +175,7 @@ function updatePanelMachineSessionState(patch = {}) {
|
||||
}
|
||||
|
||||
window.getMachineSessionStateReport = getMachineSessionStateReport;
|
||||
window.getMachineSessionStateReportExport = getMachineSessionStateReportExport;
|
||||
window.linuxCncIniPanelMachineSessionState = panelMachineSessionState;
|
||||
|
||||
function setBadge(node, text, className = "badge") {
|
||||
|
||||
@@ -108,3 +108,13 @@ export function createMachineSessionStateReport(state = {}) {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function createMachineSessionStateReportExport(state = {}, options = {}) {
|
||||
const report = createMachineSessionStateReport(state);
|
||||
return {
|
||||
filename: options.filename ?? "machine-session-state-report.json",
|
||||
mediaType: "application/json",
|
||||
report,
|
||||
text: `${JSON.stringify(report, null, 2)}\n`,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user