Skip to content

Commit 5eb44a7

Browse files
committed
Add initialrun to CreateWorkflowInstance
1 parent f42fdf1 commit 5eb44a7

7 files changed

Lines changed: 24 additions & 9 deletions

File tree

OpenFlow/src/Messages/CreateWorkflowInstanceMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class CreateWorkflowInstanceMessage<T extends Base> implements IReplyMess
1313
public targetid: string;
1414
public parentid: string;
1515
public name: string;
16+
public initialrun: boolean;
1617

1718
public payload: any;
1819

OpenFlow/src/Messages/Message.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,10 +1367,10 @@ export class Message {
13671367
var res2 = await Config.db.InsertOne(_data, "workflow_instances", 1, true, msg.jwt);
13681368
msg.newinstanceid = res2._id;
13691369

1370-
1371-
var message = { _id: res2._id };
1372-
cli.consumers[0].sendToQueueWithReply(msg.queue, msg.resultqueue, msg.correlationId, message);
1373-
1370+
if (msg.initialrun) {
1371+
var message = { _id: res2._id };
1372+
cli.consumers[0].sendToQueueWithReply(msg.queue, msg.resultqueue, msg.correlationId, message);
1373+
}
13741374
} catch (error) {
13751375
cli._logger.error(error);
13761376
if (Util.IsNullUndefinded(msg)) { (msg as any) = {}; }

OpenFlowNodeRED/src/Message.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ export class CreateWorkflowInstanceMessage {
303303
public resultqueue: string;
304304
public targetid: string;
305305
public parentid: string;
306+
public initialrun: boolean;
306307

307308
public payload: any;
308309
static assign<T>(o: any): CreateWorkflowInstanceMessage {

OpenFlowNodeRED/src/nodered/nodes/NoderedUtil.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ export class NoderedUtil {
201201
return result;
202202
}
203203

204-
public static async CreateWorkflowInstance(targetid: string, workflowid: string, correlationId: string, resultqueue: string, parentid: string, payload: any, jwt: string): Promise<string> {
204+
public static async CreateWorkflowInstance(targetid: string, workflowid: string, correlationId: string, resultqueue: string, parentid: string, payload: any, initialrun: boolean, jwt: string): Promise<string> {
205205
var q: CreateWorkflowInstanceMessage = new CreateWorkflowInstanceMessage();
206-
q.targetid = targetid; q.workflowid = workflowid; q.resultqueue = resultqueue;
206+
q.targetid = targetid; q.workflowid = workflowid; q.resultqueue = resultqueue; q.initialrun = initialrun;
207207
q.correlationId = correlationId; q.parentid = parentid; q.jwt = jwt; q.payload = payload;
208208
var _msg: Message = new Message();
209209
_msg.command = "createworkflowinstance"; _msg.data = JSON.stringify(q);

OpenFlowNodeRED/src/nodered/nodes/workflow.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,18 @@
166166
</select>
167167
<input id="node-input-targetid" type="hidden">
168168
</div>
169+
<div class="form-row">
170+
<label for="node-input-initialrun"><i class="fa fa-tasks"></i> Initial Run</label>
171+
<input type="checkbox" id="node-input-initialrun">
172+
173+
</div>
169174
</script>
170175
<script type="text/x-red" data-help-name="run workflow">
171176
<p>
172177
Create a new task asssigned to a user or role.<br>
173178
You can set Workflow using msg.workflowid<br>
174179
You can set Target using msg.targetid<br>
180+
You can set Initial Run using msg.initialrun<br>
175181
msg.payload will be sent to the workflow when calling the workflow_forms
176182
<br><br>
177183
will return the result in msg.payload when the workflow completes or fails, ( msg.state = "completed" ? "failed" )
@@ -189,7 +195,8 @@
189195
name: { value: "", required: true },
190196
queue: { value: "", required: true },
191197
targetid: { value: "" },
192-
workflowid: { value: "" }
198+
workflowid: { value: "" },
199+
initialrun: { value: false }
193200
},
194201
inputs: 1,
195202
outputs: 2,

OpenFlowNodeRED/src/nodered/nodes/workflow_nodes.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ export interface Irun_workflow_node {
405405
queue: string;
406406
targetid: string;
407407
workflowid: string;
408+
initialrun: boolean;
408409
}
409410
export class run_workflow_node {
410411
public node: Red = null;
@@ -539,6 +540,11 @@ export class run_workflow_node {
539540
var i: WebSocketClient = WebSocketClient.instance;
540541
jwt = i.jwt;
541542
}
543+
var initialrun = this.config.initialrun;
544+
if (!NoderedUtil.IsNullEmpty(msg.initialrun)) {
545+
initialrun = msg.initialrun;
546+
}
547+
542548

543549
msg.jwt = (await NoderedUtil.RenewToken(jwt, true)).jwt;
544550
// Logger.instanse.info("run workflow called with id " + msg._id + " (" + msg.name + ")");
@@ -554,7 +560,7 @@ export class run_workflow_node {
554560
// Logger.instanse.info("created runner instance with id " + res3._id + " (" + res3.name + ")");
555561
msg._parentid = res3._id;
556562

557-
msg.newinstanceid = await NoderedUtil.CreateWorkflowInstance(targetid, workflowid, null, resultqueue, res3._id, msg.payload, jwt);;
563+
msg.newinstanceid = await NoderedUtil.CreateWorkflowInstance(targetid, workflowid, null, resultqueue, res3._id, msg.payload, initialrun, jwt);;
558564

559565
this.node.send(msg);
560566
this.node.status({ fill: "green", shape: "dot", text: "Connected" });

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.483
1+
0.0.484

0 commit comments

Comments
 (0)