Add functionality to send console.log messages to editor-UI (#1816)

*  Send console.log messages to editor-UI

*  Send message only to session which started workflow

*  Made it also work in own process

*  Add support for console.log UI forward also to FunctionItem Node

* 👕 Fix lint issue

* 👕 Fix linting issue

*  Improve code

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
Jan
2021-05-29 13:41:25 -05:00
committed by GitHub
parent 8e793e27b3
commit 4946bfcd3e
11 changed files with 84 additions and 11 deletions

View File

@@ -356,11 +356,11 @@ export interface IExecutionDeleteFilter {
}
export interface IPushData {
data: IPushDataExecutionFinished | IPushDataNodeExecuteAfter | IPushDataNodeExecuteBefore | IPushDataTestWebhook;
data: IPushDataExecutionFinished | IPushDataNodeExecuteAfter | IPushDataNodeExecuteBefore | IPushDataTestWebhook | IPushDataConsoleMessage;
type: IPushDataType;
}
export type IPushDataType = 'executionFinished' | 'executionStarted' | 'nodeExecuteAfter' | 'nodeExecuteBefore' | 'testWebhookDeleted' | 'testWebhookReceived';
export type IPushDataType = 'executionFinished' | 'executionStarted' | 'nodeExecuteAfter' | 'nodeExecuteBefore' | 'sendConsoleMessage' | 'testWebhookDeleted' | 'testWebhookReceived';
export interface IPushDataExecutionStarted {
executionId: string;
@@ -397,6 +397,11 @@ export interface IPushDataTestWebhook {
workflowId: string;
}
export interface IPushDataConsoleMessage {
source: string;
message: string;
}
export interface IN8nUISettings {
endpointWebhook: string;
endpointWebhookTest: string;

View File

@@ -1,6 +1,7 @@
import {
IExecutionsCurrentSummaryExtended,
IPushData,
IPushDataConsoleMessage,
IPushDataExecutionFinished,
IPushDataExecutionStarted,
IPushDataNodeExecuteAfter,
@@ -161,6 +162,12 @@ export const pushConnection = mixins(
return false;
}
if (receivedData.type === 'sendConsoleMessage') {
const pushData = receivedData.data as IPushDataConsoleMessage;
console.log(pushData.source, pushData.message); // eslint-disable-line no-console
return true;
}
if (!['testWebhookReceived'].includes(receivedData.type) && isRetry !== true && this.pushMessageQueue.length) {
// If there are already messages in the queue add the new one that all of them
// get executed in order