mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 16:44:07 -08:00
parent
463ecb5cff
commit
7e0cd9d352
|
@ -1,5 +1,6 @@
|
||||||
|
import axios from 'axios';
|
||||||
import type express from 'express';
|
import type express from 'express';
|
||||||
import { FORM_NODE_TYPE, Workflow } from 'n8n-workflow';
|
import { FORM_NODE_TYPE, sleep, Workflow } from 'n8n-workflow';
|
||||||
import { Service } from 'typedi';
|
import { Service } from 'typedi';
|
||||||
|
|
||||||
import { ConflictError } from '@/errors/response-errors/conflict.error';
|
import { ConflictError } from '@/errors/response-errors/conflict.error';
|
||||||
|
@ -37,6 +38,25 @@ export class WaitingForms extends WaitingWebhooks {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async reloadForm(req: WaitingWebhookRequest, res: express.Response) {
|
||||||
|
try {
|
||||||
|
await sleep(1000);
|
||||||
|
|
||||||
|
const url = `${req.protocol}://${req.get('host')}${req.originalUrl}`;
|
||||||
|
const page = await axios({ url });
|
||||||
|
|
||||||
|
if (page) {
|
||||||
|
res.send(`
|
||||||
|
<script>
|
||||||
|
setTimeout(function() {
|
||||||
|
window.location.reload();
|
||||||
|
}, 1);
|
||||||
|
</script>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
} catch (error) {}
|
||||||
|
}
|
||||||
|
|
||||||
async executeWebhook(
|
async executeWebhook(
|
||||||
req: WaitingWebhookRequest,
|
req: WaitingWebhookRequest,
|
||||||
res: express.Response,
|
res: express.Response,
|
||||||
|
@ -62,7 +82,7 @@ export class WaitingForms extends WaitingWebhooks {
|
||||||
|
|
||||||
if (execution.status === 'running') {
|
if (execution.status === 'running') {
|
||||||
if (this.includeForms && req.method === 'GET') {
|
if (this.includeForms && req.method === 'GET') {
|
||||||
await this.reloadForm(executionId, res);
|
await this.reloadForm(req, res);
|
||||||
return { noWebhookResponse: true };
|
return { noWebhookResponse: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import axios from 'axios';
|
|
||||||
import type express from 'express';
|
import type express from 'express';
|
||||||
import {
|
import {
|
||||||
FORM_NODE_TYPE,
|
FORM_NODE_TYPE,
|
||||||
|
@ -6,7 +5,6 @@ import {
|
||||||
type IWorkflowBase,
|
type IWorkflowBase,
|
||||||
NodeHelpers,
|
NodeHelpers,
|
||||||
SEND_AND_WAIT_OPERATION,
|
SEND_AND_WAIT_OPERATION,
|
||||||
sleep,
|
|
||||||
WAIT_NODE_TYPE,
|
WAIT_NODE_TYPE,
|
||||||
Workflow,
|
Workflow,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
@ -19,7 +17,6 @@ import type { IExecutionResponse, IWorkflowDb } from '@/interfaces';
|
||||||
import { Logger } from '@/logging/logger.service';
|
import { Logger } from '@/logging/logger.service';
|
||||||
import { NodeTypes } from '@/node-types';
|
import { NodeTypes } from '@/node-types';
|
||||||
import * as WebhookHelpers from '@/webhooks/webhook-helpers';
|
import * as WebhookHelpers from '@/webhooks/webhook-helpers';
|
||||||
import { getBase } from '@/workflow-execute-additional-data';
|
|
||||||
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
|
import * as WorkflowExecuteAdditionalData from '@/workflow-execute-additional-data';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
|
@ -83,26 +80,6 @@ export class WaitingWebhooks implements IWebhookManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async reloadForm(executionId: string, res: express.Response) {
|
|
||||||
try {
|
|
||||||
await sleep(1000);
|
|
||||||
|
|
||||||
const { formWaitingBaseUrl } = await getBase();
|
|
||||||
const url = `${formWaitingBaseUrl}/${executionId}`;
|
|
||||||
const page = await axios({ url });
|
|
||||||
|
|
||||||
if (page) {
|
|
||||||
res.send(`
|
|
||||||
<script>
|
|
||||||
setTimeout(function() {
|
|
||||||
window.location.reload();
|
|
||||||
}, 1);
|
|
||||||
</script>
|
|
||||||
`);
|
|
||||||
}
|
|
||||||
} catch (error) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
async executeWebhook(
|
async executeWebhook(
|
||||||
req: WaitingWebhookRequest,
|
req: WaitingWebhookRequest,
|
||||||
res: express.Response,
|
res: express.Response,
|
||||||
|
@ -221,7 +198,6 @@ export class WaitingWebhooks implements IWebhookManager {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (hasChildForms) {
|
if (hasChildForms) {
|
||||||
await this.reloadForm(executionId, res);
|
|
||||||
return { noWebhookResponse: true };
|
return { noWebhookResponse: true };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -751,6 +751,18 @@
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isWaitingForm = window.location.href.includes('form-waiting');
|
||||||
|
if(isWaitingForm) {
|
||||||
|
const interval = setInterval(function() {
|
||||||
|
const isSubmited = document.querySelector('#submitted-form').style.display;
|
||||||
|
if(isSubmited === 'block') {
|
||||||
|
clearInterval(interval);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.location.reload();
|
||||||
|
}, 2000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue