推进 INI 面板 readonly status API
This commit is contained in:
@@ -4,6 +4,9 @@ import {
|
||||
import {
|
||||
loadMachineSessionForControlPageWorkflow,
|
||||
} from "./control-page-session-workflow.js";
|
||||
import {
|
||||
readMachineSessionReadonlyStatus,
|
||||
} from "./readonly-status-api.js";
|
||||
|
||||
export function createMachineSessionControlPageController({
|
||||
panelFrame,
|
||||
@@ -61,6 +64,13 @@ export function createMachineSessionControlPageController({
|
||||
});
|
||||
}
|
||||
|
||||
function readStatus() {
|
||||
return readMachineSessionReadonlyStatus({
|
||||
getPanelApi,
|
||||
getControlView,
|
||||
});
|
||||
}
|
||||
|
||||
function startPolling() {
|
||||
if (!refreshTimer) {
|
||||
refreshTimer = setIntervalFn(render, pollMs);
|
||||
@@ -85,6 +95,7 @@ export function createMachineSessionControlPageController({
|
||||
getPanelWindow,
|
||||
loadSessionState,
|
||||
mount,
|
||||
readStatus,
|
||||
refresh,
|
||||
render,
|
||||
startPolling,
|
||||
|
||||
41
wasm-port/runtime/ui/ini-panel/readonly-status-api.js
Normal file
41
wasm-port/runtime/ui/ini-panel/readonly-status-api.js
Normal file
@@ -0,0 +1,41 @@
|
||||
export function createMachineSessionReadonlyStatus({
|
||||
stateBundle = null,
|
||||
workflowStatus = null,
|
||||
controlView = null,
|
||||
} = {}) {
|
||||
const overview = stateBundle?.overview ?? workflowStatus?.overview ?? null;
|
||||
return {
|
||||
stateBundle,
|
||||
workflowStatus,
|
||||
overview,
|
||||
controlView,
|
||||
report: stateBundle?.report ?? null,
|
||||
runReadiness: workflowStatus?.runReadiness ?? stateBundle?.report?.runReadiness ?? null,
|
||||
run: workflowStatus?.run ?? stateBundle?.report?.run ?? null,
|
||||
session: workflowStatus?.session ?? stateBundle?.report?.session ?? null,
|
||||
status: {
|
||||
lastAction: workflowStatus?.lastAction ?? overview?.status?.lastAction ?? null,
|
||||
error: workflowStatus?.error ?? overview?.status?.error ?? null,
|
||||
runStatus: workflowStatus?.run?.status ?? stateBundle?.report?.run?.status ?? null,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function readMachineSessionReadonlyStatus({ getPanelApi, getControlView } = {}) {
|
||||
if (typeof getPanelApi !== "function") {
|
||||
throw new Error("A panel API getter is required.");
|
||||
}
|
||||
if (typeof getControlView !== "function") {
|
||||
throw new Error("A control view getter is required.");
|
||||
}
|
||||
|
||||
const panelApi = getPanelApi();
|
||||
if (!panelApi) {
|
||||
return createMachineSessionReadonlyStatus();
|
||||
}
|
||||
return createMachineSessionReadonlyStatus({
|
||||
stateBundle: panelApi.getMachineSessionStateBundle?.() ?? null,
|
||||
workflowStatus: panelApi.getMachineSessionWorkflowStatus?.() ?? null,
|
||||
controlView: getControlView(),
|
||||
});
|
||||
}
|
||||
@@ -18,6 +18,10 @@ import {
|
||||
createControlPageSessionLoadState,
|
||||
loadMachineSessionForControlPageWorkflow,
|
||||
} from "./control-page-session-workflow.js";
|
||||
import {
|
||||
createMachineSessionReadonlyStatus,
|
||||
readMachineSessionReadonlyStatus,
|
||||
} from "./readonly-status-api.js";
|
||||
export {
|
||||
controlPageStatusText,
|
||||
createControlPageRefreshState,
|
||||
@@ -27,6 +31,10 @@ export {
|
||||
createControlPageSessionLoadState,
|
||||
loadMachineSessionForControlPageWorkflow,
|
||||
} from "./control-page-session-workflow.js";
|
||||
export {
|
||||
createMachineSessionReadonlyStatus,
|
||||
readMachineSessionReadonlyStatus,
|
||||
} from "./readonly-status-api.js";
|
||||
export {
|
||||
INI_PANEL_ENTRIES,
|
||||
getIniPanelEntryByHref,
|
||||
@@ -62,6 +70,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
|
||||
controlPage: {
|
||||
createController: createMachineSessionControlPageController,
|
||||
loadSessionState: loadMachineSessionForControlPageWorkflow,
|
||||
readStatus: readMachineSessionReadonlyStatus,
|
||||
refresh: refreshMachineSessionControlPage,
|
||||
renderView: renderMachineSessionControlView,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user