mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
move metadata to its own state
This commit is contained in:
parent
8fe417afe4
commit
da5241395e
|
@ -746,6 +746,10 @@ export interface ITemplatesNode extends IVersionNode {
|
||||||
categories?: ITemplatesCategory[];
|
categories?: ITemplatesCategory[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface INodeMetadata {
|
||||||
|
parametersLastUpdatedAt?: number;
|
||||||
|
};
|
||||||
|
|
||||||
export interface IRootState {
|
export interface IRootState {
|
||||||
activeExecutions: IExecutionsCurrentSummaryExtended[];
|
activeExecutions: IExecutionsCurrentSummaryExtended[];
|
||||||
activeWorkflows: string[];
|
activeWorkflows: string[];
|
||||||
|
@ -783,6 +787,7 @@ export interface IRootState {
|
||||||
workflow: IWorkflowDb;
|
workflow: IWorkflowDb;
|
||||||
sidebarMenuItems: IMenuItem[];
|
sidebarMenuItems: IMenuItem[];
|
||||||
instanceId: string;
|
instanceId: string;
|
||||||
|
nodeMetadata: {[nodeName: string]: INodeMetadata};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ICredentialTypeMap {
|
export interface ICredentialTypeMap {
|
||||||
|
|
|
@ -270,7 +270,6 @@ export default mixins(
|
||||||
MAX_DISPLAY_ITEMS_AUTO_ALL,
|
MAX_DISPLAY_ITEMS_AUTO_ALL,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
staleData: false,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -312,7 +311,7 @@ export default mixins(
|
||||||
node (): INodeUi | null {
|
node (): INodeUi | null {
|
||||||
return this.$store.getters.activeNode;
|
return this.$store.getters.activeNode;
|
||||||
},
|
},
|
||||||
runMetadata () {
|
runTaskData (): ITaskData | null {
|
||||||
if (!this.node || this.workflowExecution === null) {
|
if (!this.node || this.workflowExecution === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -327,12 +326,28 @@ export default mixins(
|
||||||
return null;
|
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 {
|
return {
|
||||||
executionTime: taskData.executionTime,
|
executionTime: this.runTaskData.executionTime,
|
||||||
startTime: new Date(taskData.startTime).toLocaleString(),
|
startTime: new Date(this.runTaskData.startTime).toLocaleString(),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
staleData(): boolean {
|
||||||
|
if (!this.node) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const updatedAt = this.$store.getters.getParametersLastUpdated(this.node.name);
|
||||||
|
if (!updatedAt || !this.runTaskData) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const runAt = this.runTaskData.startTime;
|
||||||
|
return updatedAt > runAt;
|
||||||
|
},
|
||||||
dataCount (): number {
|
dataCount (): number {
|
||||||
return this.getDataCount(this.runIndex, this.outputIndex);
|
return this.getDataCount(this.runIndex, this.outputIndex);
|
||||||
},
|
},
|
||||||
|
|
|
@ -90,6 +90,7 @@ const state: IRootState = {
|
||||||
},
|
},
|
||||||
sidebarMenuItems: [],
|
sidebarMenuItems: [],
|
||||||
instanceId: '',
|
instanceId: '',
|
||||||
|
nodeMetadata: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
const modules = {
|
const modules = {
|
||||||
|
@ -470,6 +471,11 @@ export const store = new Vuex.Store({
|
||||||
|
|
||||||
state.stateIsDirty = true;
|
state.stateIsDirty = true;
|
||||||
Vue.set(node, 'parameters', updateInformation.value);
|
Vue.set(node, 'parameters', updateInformation.value);
|
||||||
|
|
||||||
|
if (!state.nodeMetadata[node.name]) {
|
||||||
|
Vue.set(state.nodeMetadata, node.name, {});
|
||||||
|
}
|
||||||
|
Vue.set(state.nodeMetadata[node.name], 'parametersLastUpdatedAt', new Date().getTime());
|
||||||
},
|
},
|
||||||
|
|
||||||
// Node-Index
|
// Node-Index
|
||||||
|
@ -666,6 +672,10 @@ export const store = new Vuex.Store({
|
||||||
return state.activeExecutions;
|
return state.activeExecutions;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getParametersLastUpdated: (state): ((name: string) => number | undefined) => {
|
||||||
|
return (nodeName: string) => state.nodeMetadata[nodeName] && state.nodeMetadata[nodeName].parametersLastUpdatedAt;
|
||||||
|
},
|
||||||
|
|
||||||
getBaseUrl: (state): string => {
|
getBaseUrl: (state): string => {
|
||||||
return state.baseUrl;
|
return state.baseUrl;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue