n8n/packages/editor-ui/src/components/VariableSelector.vue

649 lines
19 KiB
Vue
Raw Normal View History

2019-06-23 03:35:23 -07:00
<template>
<div @keydown.stop class="variable-selector-wrapper">
<div class="input-wrapper">
2021-12-15 04:16:53 -08:00
<n8n-input :placeholder="$locale.baseText('variableSelector.variableFilter')" v-model="variableFilter" ref="inputField" size="small" type="text"></n8n-input>
2019-06-23 03:35:23 -07:00
</div>
<div class="result-wrapper">
<variable-selector-item :item="option" v-for="option in currentResults" :key="option.key" :extendAll="extendAll" @itemSelected="forwardItemSelected"></variable-selector-item>
</div>
</div>
</template>
<script lang="ts">
:sparkles: Implement Wait functionality (#1817) * refactor saving * refactor api layer to be stateless * refactor header details * set variable for menu height * clean up scss * clean up indentation * clean up dropdown impl * refactor no tags view * split away header * Fix tslint issues * Refactor tag manager * add tags to patch request * clean up scss * :zap: Refactor types to entities * fix issues * update no workflow error * clean up tagscontainer * use getters instead of state * remove imports * use custom colors * clean up tags container * clean up dropdown * clean up focusoncreate * :zap: Ignore mistaken ID in POST /workflows * :zap: Fix undefined tag ID in PATCH /workflows * :zap: Shorten response for POST /tags * remove scss mixins * clean up imports * :zap: Implement validation with class-validator * address ivan's comments * implement modals * Fix lint issues * fix disabling shortcuts * fix focus issues * fix focus issues * fix focus issues with modal * fix linting issues * use dispatch * use constants for modal keys * fix focus * fix lint issues * remove unused prop * add modal root * fix lint issues * remove unused methods * fix shortcut * remove max width * :zap: Fix duplicate entry error for pg and MySQL * update rename messaging * update order of buttons * fix firefox overflow on windows * fix dropdown height * :hammer: refactor tag crud controllers * 🧹 remove unused imports * use variable for number of items * fix dropdown spacing * :zap: Restore type to fix build * :zap: Fix post-refactor PATCH /workflows/:id * :zap: Fix PATCH /workflows/:id for zero tags * :zap: Fix usage count becoming stringified * address max's comments * fix filter spacing * fix blur bug * address most of ivan's comments * address tags type concern * remove defaults * :zap: return tag id as string * :hammer: add hooks to tag CUD operations * 🏎 simplify timestamp pruning * remove blur event * fix onblur bug * :zap: Fix fs import to fix build * address max's comments * implement responsive tag container * fix lint issues * update tag limits * address ivan's comments * remove rename, refactor header, implement new designs for save, remove responsive tag container * update styling * update styling * implement responsive tag container * implement header tags edit * implement header tags edit * fix lint issues * implement expandable input * minor fixes * minor fixes * use variable * rename save as * duplicate fixes * minor edit fixes * lint fixes * style fixes * hook up saving name * hook up tags * clean up impl * fix dirty state bug * update limit * update notification messages * on click outside * fix minor bug with count * lint fixes * handle minor edge cases * handle minor edge cases * handle minor bugs; fix firefox dropdown issue * Fix min width * apply tags only after api success * remove count fix * clean up workflow tags impl, fix tags delete bug * fix minor issue * fix minor spacing issue * disable wrap for ops * fix viewport root; save on click in dropdown * save button loading when saving name/tags * implement max width on tags container * implement cleaner create experience * disable edit while updating * codacy hex color * refactor tags container * fix clickability * fix workflow open and count * clean up structure * fix up lint issues * fix button size * increase workflow name limit for larger screen * tslint fixes * disable responsiveness for workflow modal * rename event * change min width for tags * clean up pr * address max's comments on styles * remove success toasts * add hover mode to name * minor fixes * refactor name preview * fix name input not to jiggle * finish up name input * Fix up add tags * clean up param * clean up scss * fix resizing name * fix resizing name * fix resize bug * clean up edit spacing * ignore on esc * fix input bug * focus input on clear * build * fix up add tags clickablity * remove scrollbars * move into folders * clean up multiple patch req * remove padding top from edit * update tags on enter * build * rollout blur on enter behavior * rollout esc behavior * fix tags bug when duplicating tags * move key to reload tags * update header spacing * build * update hex case * refactor workflow title * remove unusued prop * keep focus on error, fix bug on error * Fix bug with name / tags toggle on error * fix connection push bug * :spakles: Implement wait functionality * :bug: Do not delete waiting executions with prune * :zap: Improve SQLite migration to not lose execution data anymore * :zap: Make it possible to restart waiting execution via webhook * :zap: Add missing file * :bug: Some more merge fixes * :zap: Do not show error for Wait-Nodes if in time-mode * :zap: Make $executionId available in expressions * :shirt: Fix lint issue * :shirt: Fix lint issue * :shirt: Fix lint issue * :zap: Set the unlimited sleep time as a variable * :zap: Add also sleeping webhook path to config * :zap: Make it possible to retrieve restartUrl in workflow * :zap: Add authentication to Wait-Node in Webhook-Mode * :zap: Return 404 when trying to restart execution via webhook which does not support it * :sparkles: Make it possible to set absolute time on Wait-Node * :zap: Remove not needed imports * :zap: Fix description format * :sparkles: Implement missing webhook features on Wait-Node * :zap: Display webhook variable in NodeWebhooks * :zap: Include also date in displayed sleep time * :zap: Make it possible to see sleep time on node * :zap: Make sure that no executions does get executed twice * :zap: Add comment * :zap: Further improvements * :zap: Make Wait-Node easier to use * :sparkles: Add support for "notice" parameter type * Fixing wait node to work with queue, improved logging and execution view * Added support for mysql and pg * :sparkles: Add support for webhook postfix path * :sparkles: Make it possible to stop sleeping executions * :zap: Fix issue with webhook paths in not webhook mode * :zap: Remove not needed console.log * :zap: Update TODOs * :zap: Increase min time of workflow staying active to descrease possible issue with overlap * :shirt: Fix lint issue * :bug: Fix issues with webhooks * :zap: Make error message clearer * :zap: Fix issue with missing execution ID in scaling mode * Fixed execution list to correctly display waiting executins * Feature: enable webhook wait workflows to continue after specified time * Fixed linting * :zap: Improve waiting description text * :zap: Fix parameter display issue and rename * :zap: Remove comment * :zap: Do not display webhooks on Wait-Node * Changed wording from restart to resume on wait node * Fixed wording and inconsistent screen when changing resume modes * Removed dots from the descriptions * Changed docs url and renaming postfix to suffix * Changed names from sleep to wait * :zap: Apply suggestions from ben Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com> * Some fixes by Ben * :zap: Remove console.logs * :zap: Fixes and improvements Co-authored-by: Mutasem <mutdmour@gmail.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com> Co-authored-by: Omar Ajoue <krynble@gmail.com>
2021-08-21 05:11:32 -07:00
import {
PLACEHOLDER_FILLED_AT_EXECUTION_TIME,
} from '@/constants';
2019-06-23 03:35:23 -07:00
import {
GenericValue,
2019-06-23 03:35:23 -07:00
IContextObject,
IDataObject,
IRunData,
IRunExecutionData,
:sparkles: Implement Wait functionality (#1817) * refactor saving * refactor api layer to be stateless * refactor header details * set variable for menu height * clean up scss * clean up indentation * clean up dropdown impl * refactor no tags view * split away header * Fix tslint issues * Refactor tag manager * add tags to patch request * clean up scss * :zap: Refactor types to entities * fix issues * update no workflow error * clean up tagscontainer * use getters instead of state * remove imports * use custom colors * clean up tags container * clean up dropdown * clean up focusoncreate * :zap: Ignore mistaken ID in POST /workflows * :zap: Fix undefined tag ID in PATCH /workflows * :zap: Shorten response for POST /tags * remove scss mixins * clean up imports * :zap: Implement validation with class-validator * address ivan's comments * implement modals * Fix lint issues * fix disabling shortcuts * fix focus issues * fix focus issues * fix focus issues with modal * fix linting issues * use dispatch * use constants for modal keys * fix focus * fix lint issues * remove unused prop * add modal root * fix lint issues * remove unused methods * fix shortcut * remove max width * :zap: Fix duplicate entry error for pg and MySQL * update rename messaging * update order of buttons * fix firefox overflow on windows * fix dropdown height * :hammer: refactor tag crud controllers * 🧹 remove unused imports * use variable for number of items * fix dropdown spacing * :zap: Restore type to fix build * :zap: Fix post-refactor PATCH /workflows/:id * :zap: Fix PATCH /workflows/:id for zero tags * :zap: Fix usage count becoming stringified * address max's comments * fix filter spacing * fix blur bug * address most of ivan's comments * address tags type concern * remove defaults * :zap: return tag id as string * :hammer: add hooks to tag CUD operations * 🏎 simplify timestamp pruning * remove blur event * fix onblur bug * :zap: Fix fs import to fix build * address max's comments * implement responsive tag container * fix lint issues * update tag limits * address ivan's comments * remove rename, refactor header, implement new designs for save, remove responsive tag container * update styling * update styling * implement responsive tag container * implement header tags edit * implement header tags edit * fix lint issues * implement expandable input * minor fixes * minor fixes * use variable * rename save as * duplicate fixes * minor edit fixes * lint fixes * style fixes * hook up saving name * hook up tags * clean up impl * fix dirty state bug * update limit * update notification messages * on click outside * fix minor bug with count * lint fixes * handle minor edge cases * handle minor edge cases * handle minor bugs; fix firefox dropdown issue * Fix min width * apply tags only after api success * remove count fix * clean up workflow tags impl, fix tags delete bug * fix minor issue * fix minor spacing issue * disable wrap for ops * fix viewport root; save on click in dropdown * save button loading when saving name/tags * implement max width on tags container * implement cleaner create experience * disable edit while updating * codacy hex color * refactor tags container * fix clickability * fix workflow open and count * clean up structure * fix up lint issues * fix button size * increase workflow name limit for larger screen * tslint fixes * disable responsiveness for workflow modal * rename event * change min width for tags * clean up pr * address max's comments on styles * remove success toasts * add hover mode to name * minor fixes * refactor name preview * fix name input not to jiggle * finish up name input * Fix up add tags * clean up param * clean up scss * fix resizing name * fix resizing name * fix resize bug * clean up edit spacing * ignore on esc * fix input bug * focus input on clear * build * fix up add tags clickablity * remove scrollbars * move into folders * clean up multiple patch req * remove padding top from edit * update tags on enter * build * rollout blur on enter behavior * rollout esc behavior * fix tags bug when duplicating tags * move key to reload tags * update header spacing * build * update hex case * refactor workflow title * remove unusued prop * keep focus on error, fix bug on error * Fix bug with name / tags toggle on error * fix connection push bug * :spakles: Implement wait functionality * :bug: Do not delete waiting executions with prune * :zap: Improve SQLite migration to not lose execution data anymore * :zap: Make it possible to restart waiting execution via webhook * :zap: Add missing file * :bug: Some more merge fixes * :zap: Do not show error for Wait-Nodes if in time-mode * :zap: Make $executionId available in expressions * :shirt: Fix lint issue * :shirt: Fix lint issue * :shirt: Fix lint issue * :zap: Set the unlimited sleep time as a variable * :zap: Add also sleeping webhook path to config * :zap: Make it possible to retrieve restartUrl in workflow * :zap: Add authentication to Wait-Node in Webhook-Mode * :zap: Return 404 when trying to restart execution via webhook which does not support it * :sparkles: Make it possible to set absolute time on Wait-Node * :zap: Remove not needed imports * :zap: Fix description format * :sparkles: Implement missing webhook features on Wait-Node * :zap: Display webhook variable in NodeWebhooks * :zap: Include also date in displayed sleep time * :zap: Make it possible to see sleep time on node * :zap: Make sure that no executions does get executed twice * :zap: Add comment * :zap: Further improvements * :zap: Make Wait-Node easier to use * :sparkles: Add support for "notice" parameter type * Fixing wait node to work with queue, improved logging and execution view * Added support for mysql and pg * :sparkles: Add support for webhook postfix path * :sparkles: Make it possible to stop sleeping executions * :zap: Fix issue with webhook paths in not webhook mode * :zap: Remove not needed console.log * :zap: Update TODOs * :zap: Increase min time of workflow staying active to descrease possible issue with overlap * :shirt: Fix lint issue * :bug: Fix issues with webhooks * :zap: Make error message clearer * :zap: Fix issue with missing execution ID in scaling mode * Fixed execution list to correctly display waiting executins * Feature: enable webhook wait workflows to continue after specified time * Fixed linting * :zap: Improve waiting description text * :zap: Fix parameter display issue and rename * :zap: Remove comment * :zap: Do not display webhooks on Wait-Node * Changed wording from restart to resume on wait node * Fixed wording and inconsistent screen when changing resume modes * Removed dots from the descriptions * Changed docs url and renaming postfix to suffix * Changed names from sleep to wait * :zap: Apply suggestions from ben Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com> * Some fixes by Ben * :zap: Remove console.logs * :zap: Fixes and improvements Co-authored-by: Mutasem <mutdmour@gmail.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com> Co-authored-by: Omar Ajoue <krynble@gmail.com>
2021-08-21 05:11:32 -07:00
IWorkflowDataProxyAdditionalKeys,
2019-06-23 03:35:23 -07:00
Workflow,
WorkflowDataProxy,
} from 'n8n-workflow';
import VariableSelectorItem from '@/components/VariableSelectorItem.vue';
import {
IExecutionResponse,
INodeUi,
2019-06-23 03:35:23 -07:00
IVariableItemSelected,
IVariableSelectorOption,
} from '@/Interface';
import { workflowHelpers } from '@/components/mixins/workflowHelpers';
import mixins from 'vue-typed-mixins';
export default mixins(
workflowHelpers,
)
.extend({
name: 'VariableSelector',
components: {
VariableSelectorItem,
},
props: [
'path',
],
data () {
return {
variableFilter: '',
selectorOpenInputIndex: null as number | null,
};
},
computed: {
extendAll (): boolean {
if (this.variableFilter) {
return true;
}
return false;
},
currentResults (): IVariableSelectorOption[] {
return this.getFilterResults(this.variableFilter.toLowerCase(), 0);
},
workflow (): Workflow {
return this.getWorkflow();
},
},
methods: {
forwardItemSelected (eventData: IVariableItemSelected) {
this.$emit('itemSelected', eventData);
},
sortOptions (options: IVariableSelectorOption[] | null): IVariableSelectorOption[] | null {
if (options === null) {
return null;
}
return options.sort((a: IVariableSelectorOption, b: IVariableSelectorOption) => {
const aHasOptions = a.hasOwnProperty('options');
const bHasOptions = b.hasOwnProperty('options');
if (bHasOptions && !aHasOptions) {
// When b has options but a not list it first
return 1;
} else if (!bHasOptions && aHasOptions) {
// When a has options but b not list it first
return -1;
}
// Else simply sort alphabetically
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
},
removeEmptyEntries (inputData: IVariableSelectorOption[] | IVariableSelectorOption | null): IVariableSelectorOption[] | IVariableSelectorOption | null {
if (Array.isArray(inputData)) {
const newItems: IVariableSelectorOption[] = [];
let tempItem: IVariableSelectorOption;
inputData.forEach((item) => {
tempItem = this.removeEmptyEntries(item) as IVariableSelectorOption;
if (tempItem !== null) {
newItems.push(tempItem);
}
});
return newItems;
}
if (inputData && inputData.options) {
const newOptions = this.removeEmptyEntries(inputData.options);
if (Array.isArray(newOptions) && newOptions.length) {
// Has still options left so return
inputData.options = this.sortOptions(newOptions);
return inputData;
} else if (Array.isArray(newOptions) && newOptions.length === 0) {
delete inputData.options;
return inputData;
2019-06-23 03:35:23 -07:00
}
// Has no options left so remove
return null;
} else {
// Is an item no category
return inputData;
}
},
// Normalizes the path so compare paths which have use dots or brakets
getPathNormalized (path: string | undefined): string {
if (path === undefined) {
return '';
}
const pathArray = path.split('.');
const finalArray = [];
let item: string;
for (const pathPart of pathArray) {
const pathParts = pathPart.match(/\[.*?\]/g);
if (pathParts === null) {
// Does not have any brakets so add as it is
finalArray.push(pathPart);
} else {
// Has brakets so clean up the items and add them
if (pathPart.charAt(0) !== '[') {
// Does not start with a braket so there is a part before
// we have to add
finalArray.push(pathPart.substr(0, pathPart.indexOf('[')));
}
for (item of pathParts) {
item = item.slice(1, -1);
if (['"', "'"].includes(item.charAt(0))) {
// Is a string
item = item.slice(1, -1);
finalArray.push(item);
} else {
// Is a number
finalArray.push(`[${item}]`);
}
}
}
}
return finalArray.join('|');
},
jsonDataToFilterOption (inputData: IDataObject | GenericValue | IDataObject[] | GenericValue[] | null, parentPath: string, propertyName: string, filterText?: string, propertyIndex?: number, displayName?: string, skipKey?: string): IVariableSelectorOption[] {
let fullpath = `${parentPath}["${propertyName}"]`;
if (propertyIndex !== undefined) {
fullpath += `[${propertyIndex}]`;
}
const returnData: IVariableSelectorOption[] = [];
if (inputData === null) {
returnData.push(
{
name: propertyName,
key: fullpath,
value: '[null]',
} as IVariableSelectorOption,
);
2019-06-23 03:35:23 -07:00
return returnData;
} else if (Array.isArray(inputData)) {
let newPropertyName = propertyName;
let newParentPath = parentPath;
2019-06-23 03:35:23 -07:00
if (propertyIndex !== undefined) {
newParentPath += `["${propertyName}"]`;
newPropertyName = propertyIndex.toString();
2019-06-23 03:35:23 -07:00
}
const arrayData: IVariableSelectorOption[] = [];
for (let i = 0; i < inputData.length; i++) {
arrayData.push.apply(arrayData, this.jsonDataToFilterOption(inputData[i], newParentPath, newPropertyName, filterText, i, `[Item: ${i}]`, skipKey));
2019-06-23 03:35:23 -07:00
}
returnData.push(
{
name: displayName || propertyName,
options: arrayData,
key: fullpath,
allowParentSelect: true,
dataType: 'array',
} as IVariableSelectorOption,
2019-06-23 03:35:23 -07:00
);
} else if (typeof inputData === 'object') {
const tempValue: IVariableSelectorOption[] = [];
for (const key of Object.keys(inputData)) {
tempValue.push.apply(tempValue, this.jsonDataToFilterOption((inputData as IDataObject)[key], fullpath, key, filterText, undefined, undefined, skipKey));
}
if (tempValue.length) {
returnData.push(
{
name: displayName || propertyName,
options: this.sortOptions(tempValue),
key: fullpath,
allowParentSelect: true,
dataType: 'object',
} as IVariableSelectorOption,
2019-06-23 03:35:23 -07:00
);
}
} else {
if (filterText !== undefined && propertyName.toLowerCase().indexOf(filterText) === -1) {
return returnData;
}
// Skip is currently only needed for leafs so only check here
if (this.getPathNormalized(skipKey) !== this.getPathNormalized(fullpath)) {
returnData.push(
{
name: propertyName,
key: fullpath,
value: inputData,
} as IVariableSelectorOption,
2019-06-23 03:35:23 -07:00
);
}
}
return returnData;
},
/**
* Returns the data the a node does output
*
* @param {IRunData} runData The data of the run to get the data of
* @param {string} nodeName The name of the node to get the data of
* @param {string} filterText Filter text for parameters
* @param {number} [itemIndex=0] The index of the item
* @param {number} [runIndex=0] The index of the run
* @param {string} [inputName='main'] The name of the input
* @param {number} [outputIndex=0] The index of the output
* @returns
* @memberof Workflow
*/
getNodeOutputData (runData: IRunData, nodeName: string, filterText: string, itemIndex = 0, runIndex = 0, inputName = 'main', outputIndex = 0, useShort = false): IVariableSelectorOption[] | null {
2019-06-23 03:35:23 -07:00
if (!runData.hasOwnProperty(nodeName)) {
// No data found for node
return null;
}
if (runData[nodeName].length <= runIndex) {
// No data for given runIndex
return null;
}
if (!runData[nodeName][runIndex].hasOwnProperty('data') ||
runData[nodeName][runIndex].data === null ||
runData[nodeName][runIndex].data === undefined) {
// Data property does not exist or is not set (even though it normally has to)
return null;
}
if (!runData[nodeName][runIndex].data!.hasOwnProperty(inputName)) {
// No data found for inputName
return null;
}
if (runData[nodeName][runIndex].data![inputName].length <= outputIndex) {
// No data found for output Index
return null;
}
// The data should be identical no matter to which node it gets so always select the first one
if (runData[nodeName][runIndex].data![inputName][outputIndex] === null ||
runData[nodeName][runIndex].data![inputName][outputIndex]!.length <= itemIndex) {
// No data found for node connection found
return null;
}
const outputData = runData[nodeName][runIndex].data![inputName][outputIndex]![itemIndex];
const returnData: IVariableSelectorOption[] = [];
// Get json data
if (outputData.hasOwnProperty('json')) {
const jsonPropertyPrefix = useShort === true ? '$json' : `$node["${nodeName}"].json`;
2019-06-23 03:35:23 -07:00
const jsonDataOptions: IVariableSelectorOption[] = [];
for (const propertyName of Object.keys(outputData.json)) {
jsonDataOptions.push.apply(jsonDataOptions, this.jsonDataToFilterOption(outputData.json[propertyName], jsonPropertyPrefix, propertyName, filterText));
2019-06-23 03:35:23 -07:00
}
if (jsonDataOptions.length) {
returnData.push(
{
name: 'JSON',
options: this.sortOptions(jsonDataOptions),
},
2019-06-23 03:35:23 -07:00
);
}
}
// Get binary data
if (outputData.hasOwnProperty('binary')) {
const binaryPropertyPrefix = useShort === true ? '$binary' : `$node["${nodeName}"].binary`;
2019-06-23 03:35:23 -07:00
const binaryData = [];
let binaryPropertyData = [];
for (const dataPropertyName of Object.keys(outputData.binary!)) {
binaryPropertyData = [];
for (const propertyName in outputData.binary![dataPropertyName]) {
if (propertyName === 'data') {
continue;
}
if (filterText && propertyName.toLowerCase().indexOf(filterText) === -1) {
// If filter is set apply it
continue;
}
binaryPropertyData.push(
{
name: propertyName,
key: `${binaryPropertyPrefix}.${dataPropertyName}.${propertyName}`,
2019-06-23 03:35:23 -07:00
value: outputData.binary![dataPropertyName][propertyName],
},
2019-06-23 03:35:23 -07:00
);
}
if (binaryPropertyData.length) {
binaryData.push(
{
name: dataPropertyName,
key: `${binaryPropertyPrefix}.${dataPropertyName}`,
2019-06-23 03:35:23 -07:00
options: this.sortOptions(binaryPropertyData),
allowParentSelect: true,
},
2019-06-23 03:35:23 -07:00
);
}
}
if (binaryData.length) {
returnData.push(
{
name: 'Binary',
key: binaryPropertyPrefix,
2019-06-23 03:35:23 -07:00
options: this.sortOptions(binaryData),
allowParentSelect: true,
},
2019-06-23 03:35:23 -07:00
);
}
}
return returnData;
},
getNodeContext (workflow: Workflow, runExecutionData: IRunExecutionData | null, parentNode: string[], nodeName: string, filterText: string): IVariableSelectorOption[] | null {
const inputIndex = 0;
const itemIndex = 0;
const inputName = 'main';
const runIndex = 0;
const returnData: IVariableSelectorOption[] = [];
const connectionInputData = this.connectionInputData(parentNode, inputName, runIndex, inputIndex);
if (connectionInputData === null) {
return returnData;
}
:sparkles: Implement Wait functionality (#1817) * refactor saving * refactor api layer to be stateless * refactor header details * set variable for menu height * clean up scss * clean up indentation * clean up dropdown impl * refactor no tags view * split away header * Fix tslint issues * Refactor tag manager * add tags to patch request * clean up scss * :zap: Refactor types to entities * fix issues * update no workflow error * clean up tagscontainer * use getters instead of state * remove imports * use custom colors * clean up tags container * clean up dropdown * clean up focusoncreate * :zap: Ignore mistaken ID in POST /workflows * :zap: Fix undefined tag ID in PATCH /workflows * :zap: Shorten response for POST /tags * remove scss mixins * clean up imports * :zap: Implement validation with class-validator * address ivan's comments * implement modals * Fix lint issues * fix disabling shortcuts * fix focus issues * fix focus issues * fix focus issues with modal * fix linting issues * use dispatch * use constants for modal keys * fix focus * fix lint issues * remove unused prop * add modal root * fix lint issues * remove unused methods * fix shortcut * remove max width * :zap: Fix duplicate entry error for pg and MySQL * update rename messaging * update order of buttons * fix firefox overflow on windows * fix dropdown height * :hammer: refactor tag crud controllers * 🧹 remove unused imports * use variable for number of items * fix dropdown spacing * :zap: Restore type to fix build * :zap: Fix post-refactor PATCH /workflows/:id * :zap: Fix PATCH /workflows/:id for zero tags * :zap: Fix usage count becoming stringified * address max's comments * fix filter spacing * fix blur bug * address most of ivan's comments * address tags type concern * remove defaults * :zap: return tag id as string * :hammer: add hooks to tag CUD operations * 🏎 simplify timestamp pruning * remove blur event * fix onblur bug * :zap: Fix fs import to fix build * address max's comments * implement responsive tag container * fix lint issues * update tag limits * address ivan's comments * remove rename, refactor header, implement new designs for save, remove responsive tag container * update styling * update styling * implement responsive tag container * implement header tags edit * implement header tags edit * fix lint issues * implement expandable input * minor fixes * minor fixes * use variable * rename save as * duplicate fixes * minor edit fixes * lint fixes * style fixes * hook up saving name * hook up tags * clean up impl * fix dirty state bug * update limit * update notification messages * on click outside * fix minor bug with count * lint fixes * handle minor edge cases * handle minor edge cases * handle minor bugs; fix firefox dropdown issue * Fix min width * apply tags only after api success * remove count fix * clean up workflow tags impl, fix tags delete bug * fix minor issue * fix minor spacing issue * disable wrap for ops * fix viewport root; save on click in dropdown * save button loading when saving name/tags * implement max width on tags container * implement cleaner create experience * disable edit while updating * codacy hex color * refactor tags container * fix clickability * fix workflow open and count * clean up structure * fix up lint issues * fix button size * increase workflow name limit for larger screen * tslint fixes * disable responsiveness for workflow modal * rename event * change min width for tags * clean up pr * address max's comments on styles * remove success toasts * add hover mode to name * minor fixes * refactor name preview * fix name input not to jiggle * finish up name input * Fix up add tags * clean up param * clean up scss * fix resizing name * fix resizing name * fix resize bug * clean up edit spacing * ignore on esc * fix input bug * focus input on clear * build * fix up add tags clickablity * remove scrollbars * move into folders * clean up multiple patch req * remove padding top from edit * update tags on enter * build * rollout blur on enter behavior * rollout esc behavior * fix tags bug when duplicating tags * move key to reload tags * update header spacing * build * update hex case * refactor workflow title * remove unusued prop * keep focus on error, fix bug on error * Fix bug with name / tags toggle on error * fix connection push bug * :spakles: Implement wait functionality * :bug: Do not delete waiting executions with prune * :zap: Improve SQLite migration to not lose execution data anymore * :zap: Make it possible to restart waiting execution via webhook * :zap: Add missing file * :bug: Some more merge fixes * :zap: Do not show error for Wait-Nodes if in time-mode * :zap: Make $executionId available in expressions * :shirt: Fix lint issue * :shirt: Fix lint issue * :shirt: Fix lint issue * :zap: Set the unlimited sleep time as a variable * :zap: Add also sleeping webhook path to config * :zap: Make it possible to retrieve restartUrl in workflow * :zap: Add authentication to Wait-Node in Webhook-Mode * :zap: Return 404 when trying to restart execution via webhook which does not support it * :sparkles: Make it possible to set absolute time on Wait-Node * :zap: Remove not needed imports * :zap: Fix description format * :sparkles: Implement missing webhook features on Wait-Node * :zap: Display webhook variable in NodeWebhooks * :zap: Include also date in displayed sleep time * :zap: Make it possible to see sleep time on node * :zap: Make sure that no executions does get executed twice * :zap: Add comment * :zap: Further improvements * :zap: Make Wait-Node easier to use * :sparkles: Add support for "notice" parameter type * Fixing wait node to work with queue, improved logging and execution view * Added support for mysql and pg * :sparkles: Add support for webhook postfix path * :sparkles: Make it possible to stop sleeping executions * :zap: Fix issue with webhook paths in not webhook mode * :zap: Remove not needed console.log * :zap: Update TODOs * :zap: Increase min time of workflow staying active to descrease possible issue with overlap * :shirt: Fix lint issue * :bug: Fix issues with webhooks * :zap: Make error message clearer * :zap: Fix issue with missing execution ID in scaling mode * Fixed execution list to correctly display waiting executins * Feature: enable webhook wait workflows to continue after specified time * Fixed linting * :zap: Improve waiting description text * :zap: Fix parameter display issue and rename * :zap: Remove comment * :zap: Do not display webhooks on Wait-Node * Changed wording from restart to resume on wait node * Fixed wording and inconsistent screen when changing resume modes * Removed dots from the descriptions * Changed docs url and renaming postfix to suffix * Changed names from sleep to wait * :zap: Apply suggestions from ben Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com> * Some fixes by Ben * :zap: Remove console.logs * :zap: Fixes and improvements Co-authored-by: Mutasem <mutdmour@gmail.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com> Co-authored-by: Omar Ajoue <krynble@gmail.com>
2021-08-21 05:11:32 -07:00
const additionalKeys: IWorkflowDataProxyAdditionalKeys = {
$executionId: PLACEHOLDER_FILLED_AT_EXECUTION_TIME,
$resumeWebhookUrl: PLACEHOLDER_FILLED_AT_EXECUTION_TIME,
};
const dataProxy = new WorkflowDataProxy(workflow, runExecutionData, runIndex, itemIndex, nodeName, connectionInputData, {}, 'manual', additionalKeys);
2019-06-23 03:35:23 -07:00
const proxy = dataProxy.getDataProxy();
// @ts-ignore
const nodeContext = proxy.$node[nodeName].context as IContextObject;
for (const key of Object.keys(nodeContext)) {
if (filterText !== undefined && key.toLowerCase().indexOf(filterText) === -1) {
// If filter is set apply it
continue;
}
returnData.push({
name: key,
key: `$node["${nodeName}"].context["${key}"]`,
// @ts-ignore
value: nodeContext[key],
});
}
return returnData;
},
/**
* Returns all the node parameters with values
*
* @param {string} nodeName The name of the node to return data of
* @param {string} path The path to the node to pretend to key
* @param {string} [skipParameter] Parameter to skip
* @param {string} [filterText] Filter text for parameters
* @returns
* @memberof Workflow
*/
getNodeParameters (nodeName: string, path: string, skipParameter?: string, filterText?: string): IVariableSelectorOption[] | null {
const node = this.workflow.getNode(nodeName);
if (node === null) {
return null;
}
const returnParameters: IVariableSelectorOption[] = [];
for (const parameterName in node.parameters) {
if (parameterName === skipParameter) {
// Skip the parameter
continue;
}
if (filterText !== undefined && parameterName.toLowerCase().indexOf(filterText) === -1) {
// If filter is set apply it
continue;
}
returnParameters.push.apply(returnParameters, this.jsonDataToFilterOption(node.parameters[parameterName], path, parameterName, filterText, undefined, undefined, skipParameter));
}
return returnParameters;
},
getFilterResults (filterText: string, itemIndex: number): IVariableSelectorOption[] {
const inputName = 'main';
const activeNode: INodeUi | null = this.$store.getters.activeNode;
if (activeNode === null) {
return [];
}
2019-06-23 03:35:23 -07:00
const executionData = this.$store.getters.getWorkflowExecution as IExecutionResponse | null;
let parentNode = this.workflow.getParentNodes(activeNode.name, inputName, 1);
let runData = this.$store.getters.getWorkflowRunData as IRunData | null;
if (runData === null) {
runData = {};
}
let returnData: IVariableSelectorOption[] | null = [];
// -----------------------------------------
// Add the parameters of the current node
// -----------------------------------------
// Add the parameters
const currentNodeData: IVariableSelectorOption[] = [];
let tempOptions: IVariableSelectorOption[];
if (executionData !== null) {
const runExecutionData: IRunExecutionData = executionData.data;
tempOptions = this.getNodeContext(this.workflow, runExecutionData, parentNode, activeNode.name, filterText) as IVariableSelectorOption[];
if (tempOptions.length) {
currentNodeData.push(
{
name: 'Context',
options: this.sortOptions(tempOptions),
} as IVariableSelectorOption,
);
}
}
let tempOutputData;
if (parentNode.length) {
// If the node has an input node add the input data
// Check from which output to read the data.
// Depends on how the nodes are connected.
// (example "IF" node. If node is connected to "true" or to "false" output)
const outputIndex = this.workflow.getNodeConnectionOutputIndex(activeNode.name, parentNode[0], 'main');
tempOutputData = this.getNodeOutputData(runData, parentNode[0], filterText, itemIndex, 0, 'main', outputIndex, true) as IVariableSelectorOption[];
2019-06-23 03:35:23 -07:00
if (tempOutputData) {
if (JSON.stringify(tempOutputData).length < 102400) {
// Data is reasonable small (< 100kb) so add it
currentNodeData.push(
{
name: 'Input Data',
options: this.sortOptions(tempOutputData),
},
);
} else {
// Data is to large so do not add
currentNodeData.push(
{
name: 'Input Data',
options: [
{
name: '[Data to large]',
2019-10-04 04:45:41 -07:00
},
],
},
);
}
2019-06-23 03:35:23 -07:00
}
}
const initialPath = '$parameter';
let skipParameter = this.path;
if (skipParameter.startsWith('parameters.')) {
skipParameter = initialPath + skipParameter.substring(10);
}
currentNodeData.push(
{
2021-12-15 04:16:53 -08:00
name: this.$locale.baseText('variableSelector.parameters'),
2019-06-23 03:35:23 -07:00
options: this.sortOptions(this.getNodeParameters(activeNode.name, initialPath, skipParameter, filterText) as IVariableSelectorOption[]),
},
2019-06-23 03:35:23 -07:00
);
returnData.push(
{
2021-12-15 04:16:53 -08:00
name: this.$locale.baseText('variableSelector.currentNode'),
2019-06-23 03:35:23 -07:00
options: this.sortOptions(currentNodeData),
},
2019-06-23 03:35:23 -07:00
);
// Add the input data
// -----------------------------------------
// Add all the nodes and their data
// -----------------------------------------
const allNodesData: IVariableSelectorOption[] = [];
let nodeOptions: IVariableSelectorOption[];
const upstreamNodes = this.workflow.getParentNodes(activeNode.name, inputName);
2021-11-20 09:28:05 -08:00
for (const [nodeName, node] of Object.entries(this.workflow.nodes)) {
2019-06-23 03:35:23 -07:00
// Add the parameters of all nodes
// TODO: Later have to make sure that no parameters can be referenced which have expression which use input-data (for nodes which are not parent nodes)
if (nodeName === activeNode.name) {
// Skip the current node as this one get added separately
continue;
}
nodeOptions = [
{
2021-12-15 04:16:53 -08:00
name: this.$locale.baseText('variableSelector.parameters'),
2019-06-23 03:35:23 -07:00
options: this.sortOptions(this.getNodeParameters(nodeName, `$node["${nodeName}"].parameter`, undefined, filterText)),
} as IVariableSelectorOption,
];
if (executionData !== null) {
const runExecutionData: IRunExecutionData = executionData.data;
parentNode = this.workflow.getParentNodes(nodeName, inputName, 1);
tempOptions = this.getNodeContext(this.workflow, runExecutionData, parentNode, nodeName, filterText) as IVariableSelectorOption[];
if (tempOptions.length) {
nodeOptions = [
{
2021-12-15 04:16:53 -08:00
name: this.$locale.baseText('variableSelector.context'),
2019-06-23 03:35:23 -07:00
options: this.sortOptions(tempOptions),
} as IVariableSelectorOption,
];
}
}
if (upstreamNodes.includes(nodeName)) {
// If the node is an upstream node add also the output data which can be referenced
tempOutputData = this.getNodeOutputData(runData, nodeName, filterText, itemIndex);
if (tempOutputData) {
nodeOptions.push(
{
2021-12-15 04:16:53 -08:00
name: this.$locale.baseText('variableSelector.outputData'),
2019-06-23 03:35:23 -07:00
options: this.sortOptions(tempOutputData),
} as IVariableSelectorOption,
2019-06-23 03:35:23 -07:00
);
}
}
2021-12-15 04:16:53 -08:00
const shortNodeType = this.$locale.shortNodeType(node.type);
2021-11-20 09:28:05 -08:00
2019-06-23 03:35:23 -07:00
allNodesData.push(
{
2021-12-15 04:16:53 -08:00
name: this.$locale.headerText({
2021-11-20 09:28:05 -08:00
key: `headers.${shortNodeType}.displayName`,
fallback: nodeName,
}),
2019-06-23 03:35:23 -07:00
options: this.sortOptions(nodeOptions),
},
2019-06-23 03:35:23 -07:00
);
}
returnData.push(
{
2021-12-15 04:16:53 -08:00
name: this.$locale.baseText('variableSelector.nodes'),
2019-06-23 03:35:23 -07:00
options: this.sortOptions(allNodesData),
},
2019-06-23 03:35:23 -07:00
);
// Remove empty entries and return
returnData = this.removeEmptyEntries(returnData) as IVariableSelectorOption[] | null;
if (returnData === null) {
return [];
}
return returnData;
},
},
});
</script>
<style scoped lang="scss">
.variable-selector-wrapper {
border-radius: 0 0 4px 4px;
width: 100%;
height: 100%;
position: relative;
}
.result-wrapper {
line-height: 1em;
height: 370px;
overflow-x: hidden;
overflow-y: auto;
margin: 0.5em 0;
width: 100%;
}
.result-item {
font-size: 0.7em;
}
</style>