@5minds/node-red-contrib-processcube
Version:
Node-RED nodes for ProcessCube
137 lines (116 loc) • 5.67 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('externaltask-input', {
category: 'ProcessCube',
color: '#02AFD6',
defaults: {
name: { value: '' },
workername: { value: '' },
engine: { value: '', type: 'processcube-engine-config' },
topic: { value: '' },
topicType: { value: '' },
workerConfig: { value: '{}'},
workerConfigType: { value: 'json'},
traces: { value: [] },
},
inputs: 0,
outputs: 1,
icon: 'externaltask_input.svg',
label: function () {
return this.name || (this.topic ? `topic: ${this.topic}` : 'externaltask-input');
},
oneditprepare: function () {
$('#node-input-workerConfig').typedInput({
default: 'json',
types: ['json'],
});
$('#node-input-workerConfig').typedInput('value', this.workerConfig);
$('#node-input-workerConfig').typedInput('type', this.workerConfigType);
$('#node-input-topic').typedInput({
default: 'str',
types: ['str', 'env'],
});
$('#node-input-topic').typedInput('value', this.topic);
$('#node-input-topic').typedInput('type', this.topicType);
const allTraces = [
{ value: "start", label: "Start" },
{ value: "enter", label: "Enter" },
{ value: "exit", label: "Exit" },
{ value: "error", label: "Error" },
{ value: "finish", label: "Finish" }
];
const selectEl = $("#node-input-traces");
// Optionen einfügen
allTraces.forEach(opt => {
selectEl.append(new Option(opt.label, opt.value));
});
// Bereits gespeicherte Werte setzen
const selectedOptions = this.traces || [];
selectEl.val(selectedOptions);
},
oneditsave: function () {
this.workerConfig = $('#node-input-workerConfig').typedInput('value');
if (this.workerConfig == '') {
this.workerConfig = '{}'
$('#node-input-workerConfig').typedInput('value', '{}');
}
this.workerConfigType = $('#node-input-workerConfig').typedInput('type');
this.topic = $('#node-input-topic').typedInput('value');
this.topicType = $('#node-input-topic').typedInput('type');
const selected = $("#node-input-traces").val();
this.traces = selected;
},
});
</script>
<script type="text/html" data-template-name="externaltask-input">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name" />
</div>
<div class="form-row">
<label for="node-input-workername"><i class="fa fa-tag"></i> Workername</label>
<input type="text" id="node-input-workername" placeholder="(optional) Workername" />
</div>
<div class="form-row">
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine</label>
<input type="text" id="node-input-engine" placeholder="Engine" />
</div>
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tag"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic of ExternalTask" />
</div>
<div class="form-row">
<label for="node-input-workerConfig"><i class="fa fa-tag"></i> Config</label>
<input type="text" id="node-input-workerConfig" />
</div>
<div class="form-row">
<label for="node-input-traces"><i class="fa fa-check-square"></i> Traces</label>
<select id="node-input-traces" multiple size="5" style="width: 100%"></select>
</div>
</script>
<script type="text/markdown" data-help-name="externaltask-input">
Waiting for external tasks that correspond to the `Topic` configured in
the connected ProcessCube Engine for processing.
## Configs
: name (string) : The name of the node
: workername (string) : The optional name of the worker otherwise it will be generated with the pattern
nodered:NODERED_NAME-host:HOST_NAME-pid:PID-id:ID of the node
: engine (engine-node) : The ProcessCube Engine to connect to
: topic (string) : The topic of the external task
: workerConfig (object) : The configuration for the worker
### workerConfig
- workerId (string): The id of the worker
- lockDuration (number): The duration in milliseconds the external task is locked for execution
- maxTasks (number): The maximum number of tasks that can be fetched at once
- longpollingTimeout (number): The duration in milliseconds the external task is locked for execution
- payloadFilter (Req-Expression): The filter for the payload of the external task
## Outputs
: payload (string) : The payload the external task was started with.
: task (object) : The external task object
: flowNodeInstanceId (string) : The unique identifier of the external task, which is needed to complete the task
### Details
- To finish the external task the `externaltask-output` node is required.
- For handling a error while executing a flow as external task the `externaltask-error` node is required.
### References
- [The ProcessCube© Developer Network](https://processcube.io) - All documentation for the ProcessCube© platform
- [ProcessCube© LowCode Integration](https://processcube.io/docs/node-red) - LowCode integration in ProcessCube©
</script>