feat(workbench): integrate runtime data and map tooling
This commit is contained in:
@@ -3,7 +3,8 @@ import {
|
||||
getRunningWorkflowState
|
||||
} from "../data/running-workflows";
|
||||
import type {
|
||||
ScheduledConditionRecord
|
||||
ScheduledConditionRecord,
|
||||
WorkbenchRuntimeDataSource
|
||||
} from "../types";
|
||||
|
||||
export type ConditionStepTickerItem = {
|
||||
@@ -14,8 +15,7 @@ export type ConditionStepTickerItem = {
|
||||
|
||||
export type ConditionStepTickerView = {
|
||||
title: string;
|
||||
progressLabel: string;
|
||||
progressValue: number;
|
||||
progressValue?: number;
|
||||
currentStep: ConditionStepTickerItem | null;
|
||||
};
|
||||
|
||||
@@ -41,7 +41,8 @@ export function selectTickerCondition(
|
||||
export function createVisibleTickerCards(
|
||||
runningConditions: ScheduledConditionRecord[],
|
||||
rotationIndex: number,
|
||||
nowMs: number
|
||||
nowMs: number,
|
||||
dataSource: WorkbenchRuntimeDataSource = "mock"
|
||||
): TickerStackCard[] {
|
||||
if (runningConditions.length === 0) {
|
||||
return [];
|
||||
@@ -55,7 +56,7 @@ export function createVisibleTickerCards(
|
||||
|
||||
return {
|
||||
condition,
|
||||
view: createConditionStepView(condition, nowMs, runningConditions.length),
|
||||
view: createConditionStepView(condition, nowMs, runningConditions.length, dataSource),
|
||||
stackIndex
|
||||
};
|
||||
});
|
||||
@@ -64,8 +65,23 @@ export function createVisibleTickerCards(
|
||||
function createConditionStepView(
|
||||
condition: ScheduledConditionRecord,
|
||||
nowMs: number,
|
||||
runningConditionCount: number
|
||||
runningConditionCount: number,
|
||||
dataSource: WorkbenchRuntimeDataSource
|
||||
): ConditionStepTickerView {
|
||||
const effectiveDataSource = condition.dataSource ?? dataSource;
|
||||
if (effectiveDataSource !== "mock") {
|
||||
return {
|
||||
title: runningConditionCount > 1
|
||||
? `${condition.title} · 后端执行中 · ${runningConditionCount} 个执行中`
|
||||
: `${condition.title} · 后端执行中`,
|
||||
currentStep: {
|
||||
id: "backend-status",
|
||||
title: "后端状态",
|
||||
detail: condition.detail ?? condition.summary
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const workflow = getRunningWorkflowDefinition(condition);
|
||||
const workflowState = getRunningWorkflowState(condition, workflow, nowMs);
|
||||
const currentStep = workflow.steps[workflowState.currentStepIndex];
|
||||
@@ -79,9 +95,8 @@ function createConditionStepView(
|
||||
|
||||
return {
|
||||
title: runningConditionCount > 1
|
||||
? `${workflow.title} · ${condition.title} · ${runningConditionCount} 个执行中`
|
||||
: `${workflow.title} · ${condition.title}`,
|
||||
progressLabel: `${workflowState.progress}%`,
|
||||
? `演示 · ${workflow.title} · ${condition.title} · ${runningConditionCount} 个执行中`
|
||||
: `演示 · ${workflow.title} · ${condition.title}`,
|
||||
progressValue: workflowState.progress,
|
||||
currentStep: currentStepItem
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user