From 8edb68dbffa0aa0d8189117e1a53381cb2c27608 Mon Sep 17 00:00:00 2001 From: Mutasem Date: Thu, 31 Mar 2022 11:26:45 +0200 Subject: [PATCH] enable stale data in execution run --- packages/editor-ui/src/Interface.ts | 10 ++++++-- packages/editor-ui/src/components/RunData.vue | 25 +++++++++++++++---- packages/editor-ui/src/store.ts | 6 +++++ 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index 6c6e6d566c..3d05ed10aa 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -98,6 +98,12 @@ declare module 'jsplumb' { } } +declare module 'n8n-workflow' { + export interface ITaskData { + updatedAt?: number; + } +} + // EndpointOptions from jsplumb seems incomplete and wrong so we define an own one export interface IEndpointOptions { anchor?: any; // tslint:disable-line:no-any @@ -962,7 +968,7 @@ export type IFormBoxConfig = { export interface ITab { value: string | number; label?: string; - href?: string, + href?: string; icon?: string; align?: 'right'; -}; +} diff --git a/packages/editor-ui/src/components/RunData.vue b/packages/editor-ui/src/components/RunData.vue index 3e6cb36c8e..9290fc8009 100644 --- a/packages/editor-ui/src/components/RunData.vue +++ b/packages/editor-ui/src/components/RunData.vue @@ -270,7 +270,6 @@ export default mixins( MAX_DISPLAY_ITEMS_AUTO_ALL, currentPage: 1, pageSize: 10, - staleData: false, }; }, mounted() { @@ -312,7 +311,7 @@ export default mixins( node (): INodeUi | null { return this.$store.getters.activeNode; }, - runMetadata () { + runTaskData(): ITaskData | null { if (!this.node || this.workflowExecution === null) { return null; } @@ -327,12 +326,28 @@ export default mixins( return null; } - const taskData: ITaskData = runData[this.node.name][this.runIndex]; + return runData[this.node.name][this.runIndex]; + }, + runMetadata (): {executionTime: number, startTime: string} | null { + if (!this.runTaskData) { + return null; + } + return { - executionTime: taskData.executionTime, - startTime: new Date(taskData.startTime).toLocaleString(), + executionTime: this.runTaskData.executionTime, + startTime: new Date(this.runTaskData.startTime).toLocaleString(), }; }, + staleData (): boolean { + if (!this.node || !this.runTaskData || !this.runTaskData.updatedAt) { + return false; + } + + const updatedAt = this.runTaskData.updatedAt; + const runAt = this.runTaskData.startTime; + + return updatedAt > runAt; + }, dataCount (): number { return this.getDataCount(this.runIndex, this.outputIndex); }, diff --git a/packages/editor-ui/src/store.ts b/packages/editor-ui/src/store.ts index 418a22a33f..0f46b1541d 100644 --- a/packages/editor-ui/src/store.ts +++ b/packages/editor-ui/src/store.ts @@ -470,6 +470,12 @@ export const store = new Vuex.Store({ state.stateIsDirty = true; Vue.set(node, 'parameters', updateInformation.value); + if (state.workflowExecutionData && state.workflowExecutionData.data.resultData.runData[node.name]) { + const nodeRuns = state.workflowExecutionData.data.resultData.runData[node.name]; + nodeRuns.forEach((node) => { + Vue.set(node, 'updatedAt', new Date().getTime()); + }); + } }, // Node-Index