Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | import { computed } from 'vue' import { useExecutionStore } from '../../stores/executionStore' import type { NodeExecutionStatus } from '../../stores/executionStore' export function useNodeExecutionStatus() { const executionStore = useExecutionStore() const getNodeStatus = (nodeId: string): NodeExecutionStatus | null => { return executionStore.getNodeStatus(nodeId) } const getNodeStatusClass = (nodeId: string): string => { const status = getNodeStatus(nodeId) if (!status) return '' return `execution-${status.toLowerCase()}` } const isNodeExecuting = (nodeId: string): boolean => { return getNodeStatus(nodeId) === 'Running' } const hasNodeError = (nodeId: string): boolean => { return getNodeStatus(nodeId) === 'Failed' } const hasNodeSuccess = (nodeId: string): boolean => { return getNodeStatus(nodeId) === 'Completed' } const getNodeResult = (nodeId: string) => { return executionStore.nodeResults.get(nodeId) } const getNodeOutputPreview = (nodeId: string, maxLength = 50): string | null => { const result = getNodeResult(nodeId) if (!result?.output) return null let preview = '' if (typeof result.output === 'string') { preview = result.output } else if (typeof result.output === 'object') { try { preview = JSON.stringify(result.output) } catch { preview = '[Object]' } } else { preview = String(result.output) } if (preview.length > maxLength) { return preview.substring(0, maxLength) + '...' } return preview } const getNodeExecutionTime = (nodeId: string): number | null => { const result = getNodeResult(nodeId) return result?.executionTime || null } const formatExecutionTime = (ms: number | null): string => { if (!ms) return '' if (ms < 1000) return `${ms}ms` return `${(ms / 1000).toFixed(2)}s` } const isExecuting = computed(() => executionStore.isExecuting) const hasExecutionResults = computed(() => executionStore.hasResults) return { getNodeStatus, getNodeStatusClass, isNodeExecuting, hasNodeError, hasNodeSuccess, getNodeResult, getNodeOutputPreview, getNodeExecutionTime, formatExecutionTime, isExecuting, hasExecutionResults, } } |