forked from openiap/opencore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflow.html
More file actions
320 lines (298 loc) · 13 KB
/
Copy pathworkflow.html
File metadata and controls
320 lines (298 loc) · 13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<script type="text/x-red" data-template-name="workflow in">
<div class="form-row">
<label ><i class="fa fa-tag"></i> Queue name</label>
<input type="text" id="node-input-queue" placeholder="Queue name">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> RPA</label>
<input type="checkbox" id="node-input-rpa" style="width: auto;">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> WEB</label>
<input type="checkbox" id="node-input-web" style="width: auto;">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> EXCHANGE</label>
<input type="checkbox" id="node-input-exchange" style="width: auto;">
</div>
<div class="form-row">
<label ><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Node name">
</div>
</script>
<script type="text/x-red" data-help-name="workflow in">
Create an entry point that can be activated either from openflow web or a RPA robot.<br>
The workflow MUST end with a workflow out node, to send a reply back to the webpage/robot.<br>
msg.jwt will contain the token of the calling user<br>
msg.user will contain the TokenUser of the calling user<br>
Check WEB to list the workflow on the workflow tab in OpenFlow<br>
Check RPA to list the workflow in the Invoke OpenFlow activity in OpenRPA<br>
Check EXCHANGE to register an exchange for the workflow to send messages to listening web clients<br>
</script>
<script type="text/javascript">
RED.nodes.registerType('workflow in', {
category: 'rpa',
color: "#87A980",
paletteLabel: 'workflow',
icon: "font-awesome/fa-indent",
defaults: {
queue: { value: "", required: true },
rpa: { value: false, required: true },
web: { value: false, required: true },
exchange: { value: false, required: true },
name: { value: "" }
},
inputs: 0,
outputs: 1,
label: function () {
return this.name || "workflow in";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
});
</script>
<script type="text/x-red" data-template-name="workflow out">
<div class="form-row">
<label ><i class="fa fa-tag"></i> State</label>
<select id="node-input-state">
<option>idle</option>
<option>completed</option>
<option>failed</option>
<option>processing</option>
</select>
</div>
<div class="form-row">
<label ><i class="fa fa-tag"></i> Userform</label>
<select id="node-input-form-select">
<option>Loading...</option>
</select>
<input id="node-input-form" type="hidden">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Remove state data</label>
<input type="checkbox" id="node-input-removestate" style="width: auto;">
</div>
<div class="form-row">
<label ><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Node name">
</div>
</script>
<script type="text/x-red" data-help-name="workflow out">
Send payload as data to the calling webpage or robot.<br>
Set state to idle if you want to keep the payload alive for multiple requests.<br>
For web select a form to request or give feedback, or set to None to redirect the user to the main page.<br>
The form will show values from msg.payload mapping each property to the field name. So if you have a web form field called "firstname"
you can set the value using msg.payload.firstname.<br>
For tables, select and others with multiple values, you can send the values for the field using
msg.payload.values. Say you have a dropdown list named users then you fill the list using <br>
msg.payload.values.users = [{id:1, "name": "Allan"}, {id:2, "name": "Bettina"}];<br>
and you can set the selected value using payload <br>
msg.payload.users = 2;<br>
If you have buttons on the form, you can get the name of the button clicked in msg.payload.submitbutton
</script>
<script type="text/javascript">
RED.nodes.registerType('workflow out', {
category: 'rpa',
color: "#87A980",
paletteLabel: 'workflow',
icon: "font-awesome/fa-dedent",
defaults: {
name: { value: "" },
form: { value: "" },
state: { value: "completed", required: true },
removestate: { value: false, required: true }
},
inputs: 1,
outputs: 1,
align: "right",
label: function () {
return this.name || "workflow out";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function () {
$.getJSON('workflow_forms', function (data) {
$('#node-input-form-select').empty();
$('#node-input-form-select').append($('<option>', {
value: "",
text: "none"
}));
$.each(data, function (i, ele) {
$('#node-input-form-select').append($('<option>', {
value: ele._id,
text: ele.name
}));
});
$('#node-input-form-select').val($('#node-input-form').val());
}).error(function (jqXHR, textStatus, errorThrown) {
console.error("error " + textStatus);
console.error("incoming Text " + jqXHR.responseText);
alert("error:" + jqXHR.responseText);
});
},
oneditsave: function () {
$('#node-input-form').val($('#node-input-form-select').val());
}
});
</script>
<script type="text/x-red" data-template-name="assign workflow">
<div class="form-row">
<label ><i class="fa fa-tag"></i> Queue name</label>
<input type="text" id="node-input-queue" placeholder="Name">
</div>
<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-workflowid-search"><i class="fa fa-tasks"></i> Search</label>
<input type="text" id="node-input-workflowid-search" placeholder="Search" >
</div>
<div class="form-row">
<label for="node-input-workflowid"><i class="fa fa-tasks"></i> Workflow</label>
<select id="node-input-workflowid-select">
<option>Loading...</option>
</select>
<input id="node-input-workflowid" type="hidden">
</div>
<div class="form-row">
<label for="node-input-targetid-search"><i class="fa fa-tasks"></i> Search</label>
<input type="text" id="node-input-targetid-search" placeholder="Search" >
</div>
<div class="form-row">
<label for="node-input-targetid"><i class="fa fa-tasks"></i> Target</label>
<select id="node-input-targetid-select">
<option>Loading...</option>
</select>
<input id="node-input-targetid" type="hidden">
</div>
<div class="form-row">
<label for="node-input-initialrun"><i class="fa fa-tasks"></i> Initial Run</label>
<input type="hidden" id="node-input-initialruntype">
<input style="width:70%" type="text" id="node-input-initialrun">
</div>
</script>
<script type="text/x-red" data-help-name="assign workflow">
<p>
Create a new task asssigned to a user or role.<br>
You can set Workflow using msg.workflowid<br>
You can set Target using msg.targetid<br>
You can set Initial Run using msg.initialrun<br>
msg.payload will be sent to the workflow when calling the workflow_forms
<br><br>
will return the result in msg.payload when the workflow completes or fails, ( msg.state = "completed" ? "failed" )
</p>
</script>
<script type="text/javascript">
function generateUuid() {
return Math.random().toString(36).substr(2, 9);
}
RED.nodes.registerType('assign workflow', {
category: 'rpa',
color: "#DEB887",
paletteLabel: 'assign',
icon: "font-awesome/fa-user-plus",
defaults: {
name: { value: "" },
queue: { value: "", required: true },
initialrun: { value: false, validate: RED.validators.typedInput("initialruntype"), required: true },
initialruntype: { value: "" },
targetid: { value: "" },
workflowid: { value: "" },
},
inputs: 1,
outputs: 2,
outputLabels: ["scheduled", "result"],
label: function () {
return this.name || "assign workflow";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function () {
let queue = $('#node-input-queue').val();
if (queue === null || queue === undefined || queue === "") {
queue = generateUuid();
$('#node-input-queue').val(queue);
}
const reloadUsers = function (firstrun) {
$('#node-input-targetid-select').empty();
$('#node-input-targetid-select').append($('<option>', {
value: -1,
text: "Loading..."
}));
$('#node-input-targetid-select').val(-1);
$.getJSON('api_userroles', { name: $('#node-input-targetid-search').val(), id: $('#node-input-targetid').val() }, function (data) {
$('#node-input-targetid-select').empty();
$('#node-input-targetid-select').append($('<option>', {
value: "",
text: "from msg.targetid"
}));
$.each(data, function (i, ele) {
$('#node-input-targetid-select').append($('<option>', {
value: ele._id,
text: ele.name
}));
});
$('#node-input-targetid-select').val($('#node-input-targetid').val());
// if (firstrun) {
// $('#node-input-targetid-select').val($('#node-input-targetid').val());
// }
}).error(function (jqXHR, textStatus, errorThrown) {
console.error("error " + textStatus);
console.error("incoming Text " + jqXHR.responseText);
alert("error:" + jqXHR.responseText);
});
}
$('#node-input-targetid-search').change(() => {
reloadUsers(false);
})
reloadUsers(true);
const reloadWorkflows = function (firstrun) {
$('#node-input-workflowid-select').empty();
$('#node-input-workflowid-select').append($('<option>', {
value: -1,
text: "Loading..."
}));
$('#node-input-workflowid-select').val(-1);
$.getJSON('workflows', { name: $('#node-input-workflowid-search').val(), id: $('#node-input-workflowid').val() }, function (data) {
$('#node-input-workflowid-select').empty();
$('#node-input-workflowid-select').append($('<option>', {
value: "",
text: "from msg.workflowid"
}));
$.each(data, function (i, ele) {
$('#node-input-workflowid-select').append($('<option>', {
value: ele._id,
text: ele.name
}));
});
$('#node-input-workflowid-select').val($('#node-input-workflowid').val());
// if (firstrun) {
// $('#node-input-workflowid-select').val($('#node-input-workflowid').val());
// }
}).error(function (jqXHR, textStatus, errorThrown) {
console.error("error " + textStatus);
console.error("incoming Text " + jqXHR.responseText);
alert("error:" + jqXHR.responseText);
});
}
$('#node-input-workflowid-search').change(() => {
reloadWorkflows(false);
})
reloadWorkflows(true);
},
oneditsave: function () {
$('#node-input-targetid').val($('#node-input-targetid-select').val());
$('#node-input-workflowid').val($('#node-input-workflowid-select').val());
if (this.initialruntype === 'val') $("#node-input-initialruntype").val('str');
$("#node-input-initialrun").typedInput({
default: 'bool',
typeField: $("#node-input-initialruntype"),
types: ['msg', 'bool', 'flow', 'global']
});
}
});
</script>