-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from 5minds/feature/emit-event-in-process-engine
Feature/emit event in engine
- Loading branch information
Showing
9 changed files
with
374 additions
and
657 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<script type="text/javascript"> | ||
RED.nodes.registerType('message-event-trigger',{ | ||
category: 'ProcessCube', | ||
color: '#00aed7', | ||
defaults: { | ||
name: {value: ""}, | ||
engine: {value: "", type: "processcube-engine-config"}, | ||
messagename: {value: "", required: true}, | ||
processInstanceId: {value:""} | ||
}, | ||
inputs: 1, | ||
outputs: 1, | ||
icon: "font-awesome/fa-envelope-open", | ||
label: function() { | ||
return this.name||"message-event-trigger"; | ||
} | ||
}); | ||
</script> | ||
|
||
<script type="text/html" data-template-name="message-event-trigger"> | ||
<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-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-messagename"><i class="fa fa-tag"></i> Message Name</label> | ||
<input type="text" id="node-input-messagename" placeholder="Name of the Message-Event"> | ||
</div> | ||
<div class="form-row"> | ||
<label for="node-input-processinstanceid"><i class="fa fa-tag"></i> Process Instance Id</label> | ||
<input type="text" id="node-input-processinstanceid" placeholder="Id of the recipient process instance"> | ||
</div> | ||
</script> | ||
|
||
<script type="text/html" data-help-name="externaltask-input"> | ||
<p>A node which emmits an message event to the Engine.</p> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const process = require('process'); | ||
|
||
const engine_client = require('@5minds/processcube_engine_client'); | ||
|
||
module.exports = function(RED) { | ||
function MessageEventTrigger(config) { | ||
RED.nodes.createNode(this, config); | ||
var node = this; | ||
var nodeContext = node.context(); | ||
|
||
this.engine = this.server = RED.nodes.getNode(config.engine); | ||
|
||
const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000'; | ||
|
||
var client = nodeContext.get('client'); | ||
|
||
if (!client) { | ||
nodeContext.set('client', new engine_client.EngineClient(engineUrl)); | ||
client = nodeContext.get('client'); | ||
} | ||
|
||
node.on('input', function(msg) { | ||
|
||
client.events.triggerMessageEvent( | ||
config.messagename, | ||
{ | ||
processInstanceId: config.processinstanceid, | ||
payload: msg.payload | ||
} | ||
|
||
).then((result) => { | ||
|
||
msg.payload = result; | ||
|
||
node.send(msg); | ||
node.status({fill: "blue", shape: "dot", text: `message event triggered`}); | ||
|
||
}).catch((error) => { | ||
node.error(error); | ||
}); | ||
}); | ||
} | ||
RED.nodes.registerType("message-event-trigger", MessageEventTrigger); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.