@yousolution/node-red-contrib-you-sap-service-layer 0.0.3 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -3
- package/data/package.json +2 -2
- package/nodes/closeSap.html +2 -2
- package/nodes/createSap.html +7 -7
- package/nodes/crossJoinSap.html +269 -263
- package/nodes/deleteSap.html +7 -7
- package/nodes/getSap.html +7 -7
- package/nodes/listSap.html +5 -5
- package/nodes/manipulateEntitySap.html +177 -0
- package/nodes/manipulateEntitySap.js +43 -0
- package/nodes/nextLink.html +1 -1
- package/nodes/patchSap.html +6 -6
- package/nodes/serviceSap.html +207 -0
- package/nodes/serviceSap.js +41 -0
- package/nodes/support.js +29 -3
- package/package.json +4 -2
- package/resources/entities.json +59 -0
- package/resources/services.json +343 -0
- package/test/manipulateEntitySap.spec.js +191 -0
- package/test/serviceSap.spec.js +170 -0
- package/test/support.spec.js +280 -0
package/nodes/deleteSap.html
CHANGED
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
</div>
|
|
71
71
|
|
|
72
72
|
<div class="form-row">
|
|
73
|
-
<label for="node-input-type"><i class="fa fa-
|
|
73
|
+
<label for="node-input-type"><i class="fa fa-cube"></i> Entity</label>
|
|
74
74
|
<select name="node-input-entity" id="node-input-entity">
|
|
75
75
|
<option value="AccountCategory">AccountCategory</option>
|
|
76
76
|
<option value="AccountSegmentations">AccountSegmentations</option>
|
|
@@ -276,35 +276,35 @@
|
|
|
276
276
|
</div>
|
|
277
277
|
|
|
278
278
|
<div class="form-row" style="display:none" id="container-udo">
|
|
279
|
-
<label for="node-input-udo"><i class="fa fa-
|
|
279
|
+
<label for="node-input-udo"><i class="fa fa-gears"></i> UDO</label>
|
|
280
280
|
<input type="text" id="node-input-udo" placeholder="UDO Name">
|
|
281
281
|
</div>
|
|
282
282
|
|
|
283
283
|
<div class="form-row" style="display:none" id="container-udt">
|
|
284
|
-
<label for="node-input-udt"><i class="fa fa-
|
|
284
|
+
<label for="node-input-udt"><i class="fa fa-gears"></i> UDT</label>
|
|
285
285
|
<input type="text" id="node-input-udt" placeholder="UDT Name">
|
|
286
286
|
</div>
|
|
287
287
|
|
|
288
288
|
<div class="form-row" style="display:none" id="container-entityId">
|
|
289
|
-
<label for="node-input-type"><i class="fa fa-
|
|
289
|
+
<label for="node-input-type"><i class="fa fa-key"></i> EntityId</label>
|
|
290
290
|
<input type="text" id="node-input-entityId">
|
|
291
291
|
<input type="hidden" id="node-input-entityId-type">
|
|
292
292
|
</div>
|
|
293
293
|
|
|
294
294
|
<div class="form-row" style="display:none" id="container-docEntry">
|
|
295
|
-
<label for="node-input-type"><i class="fa fa-
|
|
295
|
+
<label for="node-input-type"><i class="fa fa-key"></i> DocEntry</label>
|
|
296
296
|
<input type="text" id="node-input-docEntry">
|
|
297
297
|
<input type="hidden" id="node-input-docEntry-type">
|
|
298
298
|
</div>
|
|
299
299
|
|
|
300
300
|
<div class="form-row" style="display:none" id="container-code">
|
|
301
|
-
<label for="node-input-type"><i class="fa fa-
|
|
301
|
+
<label for="node-input-type"><i class="fa fa-key"></i> Code</label>
|
|
302
302
|
<input type="text" id="node-input-code">
|
|
303
303
|
<input type="hidden" id="node-input-code-type">
|
|
304
304
|
</div>
|
|
305
305
|
|
|
306
306
|
<div class="form-row">
|
|
307
|
-
<label for="node-input-type"><i class="fa fa-
|
|
307
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
|
|
308
308
|
<input type="text" id="node-input-headers">
|
|
309
309
|
<input type="hidden" id="node-input-headers-type">
|
|
310
310
|
</div>
|
package/nodes/getSap.html
CHANGED
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
</div>
|
|
96
96
|
|
|
97
97
|
<div class="form-row">
|
|
98
|
-
<label for="node-input-type"><i class="fa fa-
|
|
98
|
+
<label for="node-input-type"><i class="fa fa-cube"></i> Entity</label>
|
|
99
99
|
<select name="node-input-entity" id="node-input-entity">
|
|
100
100
|
<option value="AccountCategory">AccountCategory</option>
|
|
101
101
|
<option value="AccountSegmentations">AccountSegmentations</option>
|
|
@@ -352,35 +352,35 @@
|
|
|
352
352
|
</div>
|
|
353
353
|
|
|
354
354
|
<div class="form-row" style="display:none" id="container-udo">
|
|
355
|
-
<label for="node-input-udo"><i class="fa fa-
|
|
355
|
+
<label for="node-input-udo"><i class="fa fa-gears"></i> UDO</label>
|
|
356
356
|
<input type="text" id="node-input-udo" placeholder="UDO Name">
|
|
357
357
|
</div>
|
|
358
358
|
|
|
359
359
|
<div class="form-row" style="display:none" id="container-udt">
|
|
360
|
-
<label for="node-input-udt"><i class="fa fa-
|
|
360
|
+
<label for="node-input-udt"><i class="fa fa-gears"></i> UDT</label>
|
|
361
361
|
<input type="text" id="node-input-udt" placeholder="UDT Name">
|
|
362
362
|
</div>
|
|
363
363
|
|
|
364
364
|
<div class="form-row" style="display:none" id="container-entityId">
|
|
365
|
-
<label for="node-input-type"><i class="fa fa-
|
|
365
|
+
<label for="node-input-type"><i class="fa fa-key"></i> EntityId</label>
|
|
366
366
|
<input type="text" id="node-input-entityId">
|
|
367
367
|
<input type="hidden" id="node-input-entityId-type">
|
|
368
368
|
</div>
|
|
369
369
|
|
|
370
370
|
<div class="form-row" style="display:none" id="container-docEntry">
|
|
371
|
-
<label for="node-input-type"><i class="fa fa-
|
|
371
|
+
<label for="node-input-type"><i class="fa fa-key"></i> DocEntry</label>
|
|
372
372
|
<input type="text" id="node-input-docEntry">
|
|
373
373
|
<input type="hidden" id="node-input-docEntry-type">
|
|
374
374
|
</div>
|
|
375
375
|
|
|
376
376
|
<div class="form-row" style="display:none" id="container-code">
|
|
377
|
-
<label for="node-input-type"><i class="fa fa-
|
|
377
|
+
<label for="node-input-type"><i class="fa fa-key"></i> Code</label>
|
|
378
378
|
<input type="text" id="node-input-code">
|
|
379
379
|
<input type="hidden" id="node-input-code-type">
|
|
380
380
|
</div>
|
|
381
381
|
|
|
382
382
|
<div class="form-row">
|
|
383
|
-
<label for="node-input-type"><i class="fa fa-
|
|
383
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
|
|
384
384
|
<input type="text" id="node-input-headers">
|
|
385
385
|
<input type="hidden" id="node-input-headers-type">
|
|
386
386
|
</div>
|
package/nodes/listSap.html
CHANGED
|
@@ -71,19 +71,19 @@
|
|
|
71
71
|
</div>
|
|
72
72
|
|
|
73
73
|
<div class="form-row">
|
|
74
|
-
<label for="node-input-type"><i class="fa fa-
|
|
74
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
|
|
75
75
|
<input type="text" id="node-input-headers">
|
|
76
76
|
<input type="hidden" id="node-input-headers-type">
|
|
77
77
|
</div>
|
|
78
78
|
|
|
79
79
|
<div class="form-row">
|
|
80
|
-
<label for="node-input-type"><i class="fa fa-
|
|
80
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> NextLink</label>
|
|
81
81
|
<input type="text" id="node-input-nextLink">
|
|
82
82
|
<input type="hidden" id="node-input-nextLink-type">
|
|
83
83
|
</div>
|
|
84
84
|
|
|
85
85
|
<div class="form-row">
|
|
86
|
-
<label for="node-input-type"><i class="fa fa-
|
|
86
|
+
<label for="node-input-type"><i class="fa fa-cube"></i> Entity</label>
|
|
87
87
|
<select name="node-input-entity" id="node-input-entity">
|
|
88
88
|
<option value="AccountCategory">AccountCategory</option>
|
|
89
89
|
<option value="AccountSegmentations">AccountSegmentations</option>
|
|
@@ -338,12 +338,12 @@
|
|
|
338
338
|
</div>
|
|
339
339
|
|
|
340
340
|
<div class="form-row" style="display:none" id="container-udo">
|
|
341
|
-
<label for="node-input-udo"><i class="fa fa-
|
|
341
|
+
<label for="node-input-udo"><i class="fa fa-gears"></i> UDO</label>
|
|
342
342
|
<input type="text" id="node-input-udo" placeholder="UDO Name">
|
|
343
343
|
</div>
|
|
344
344
|
|
|
345
345
|
<div class="form-row" style="display:none" id="container-udt">
|
|
346
|
-
<label for="node-input-udt"><i class="fa fa-
|
|
346
|
+
<label for="node-input-udt"><i class="fa fa-gears"></i> UDT</label>
|
|
347
347
|
<input type="text" id="node-input-udt" placeholder="UDT Name">
|
|
348
348
|
</div>
|
|
349
349
|
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
let entities = [];
|
|
3
|
+
let entitiesData = {};
|
|
4
|
+
$.getJSON('entities', (data, status) => {
|
|
5
|
+
for(entity in data) {
|
|
6
|
+
entitiesData = data;
|
|
7
|
+
entities.push(entity);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
RED.nodes.registerType('manipulateEntitySap',{
|
|
11
|
+
category: 'Sap',
|
|
12
|
+
color: '#FFC300',
|
|
13
|
+
defaults: {
|
|
14
|
+
name: {value: ''},
|
|
15
|
+
entity: {value: ''},
|
|
16
|
+
manipulateMethod: {value: ''},
|
|
17
|
+
entityId: {value: ''},
|
|
18
|
+
headers: {value: ''},
|
|
19
|
+
bodyPost: {value: ''}
|
|
20
|
+
},
|
|
21
|
+
inputs:1,
|
|
22
|
+
outputs:1,
|
|
23
|
+
icon: 'font-awesome/fa-pencil-square',
|
|
24
|
+
label: function() {
|
|
25
|
+
return this.name||"Sap manipulate entity";
|
|
26
|
+
},
|
|
27
|
+
oneditprepare: function() {
|
|
28
|
+
|
|
29
|
+
entities.forEach((entity) => {
|
|
30
|
+
$('#node-input-entity')
|
|
31
|
+
.append($("<option></option>")
|
|
32
|
+
.attr("value", entity)
|
|
33
|
+
.text(entity));
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// set the previous value
|
|
37
|
+
if(this.entity) {
|
|
38
|
+
$('#node-input-entity').val(this.entity);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
$("#node-input-entity").change((event) => {
|
|
43
|
+
const entity = $("#node-input-entity").val();
|
|
44
|
+
|
|
45
|
+
$('#node-input-manipulateMethod').empty();
|
|
46
|
+
|
|
47
|
+
if(entitiesData[entity]) {
|
|
48
|
+
entitiesData[entity].forEach((endpoint) => {
|
|
49
|
+
$('#node-input-manipulateMethod')
|
|
50
|
+
.append($("<option></option>")
|
|
51
|
+
.attr("value", endpoint)
|
|
52
|
+
.text(endpoint));
|
|
53
|
+
});
|
|
54
|
+
// trick check if change with click or not
|
|
55
|
+
if(!event.originalEvent){
|
|
56
|
+
$('#node-input-manipulateMethod').val(this.manipulateMethod);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
$("#node-input-entityId").typedInput({
|
|
63
|
+
type:"msg",
|
|
64
|
+
types:["msg"],
|
|
65
|
+
typeField: "#node-input-entityId-type",
|
|
66
|
+
value: 'entityId'
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
$("#node-input-headers").typedInput({
|
|
70
|
+
type:"msg",
|
|
71
|
+
types:["msg"],
|
|
72
|
+
typeField: "#node-input-headers-type",
|
|
73
|
+
value: 'headers'
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
$("#node-input-bodyPost").typedInput({
|
|
77
|
+
type:"msg",
|
|
78
|
+
types:["msg"],
|
|
79
|
+
typeField: "#node-input-bodyPost-type",
|
|
80
|
+
value: 'bodyPost'
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<script type="text/html" data-template-name="manipulateEntitySap">
|
|
89
|
+
<div class="form-row">
|
|
90
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
91
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<div class="form-row">
|
|
95
|
+
<label for="node-input-type"><i class="fa fa-cube"></i> Entity</label>
|
|
96
|
+
<select name="node-input-entity" id="node-input-entity">
|
|
97
|
+
<option></option>
|
|
98
|
+
</select>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<div class="form-row">
|
|
102
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Method</label>
|
|
103
|
+
<select name="node-input-manipulateMethod" id="node-input-manipulateMethod">
|
|
104
|
+
</select>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<div class="form-row" id="container-entityId">
|
|
108
|
+
<label for="node-input-type"><i class="fa fa-key"></i> EntityId</label>
|
|
109
|
+
<input type="text" id="node-input-entityId">
|
|
110
|
+
<input type="hidden" id="node-input-entityId-type">
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<div class="form-row">
|
|
114
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
|
|
115
|
+
<input type="text" id="node-input-headers">
|
|
116
|
+
<input type="hidden" id="node-input-headers-type">
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<div class="form-row">
|
|
120
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> BodyPost</label>
|
|
121
|
+
<input type="text" id="node-input-bodyPost">
|
|
122
|
+
<input type="hidden" id="node-input-bodyPost-type">
|
|
123
|
+
</div>
|
|
124
|
+
</script>
|
|
125
|
+
|
|
126
|
+
<!-- Documentation -->
|
|
127
|
+
<script type="text/html" data-help-name="manipulateEntitySap">
|
|
128
|
+
<p>Manipulate action</p>
|
|
129
|
+
|
|
130
|
+
<h3>Inputs</h3>
|
|
131
|
+
<dl class="message-properties">
|
|
132
|
+
<dt>Name
|
|
133
|
+
<span class="property-type">string</span>
|
|
134
|
+
</dt>
|
|
135
|
+
<dd> the node's name </dd>
|
|
136
|
+
<dt>Entity
|
|
137
|
+
<span class="property-type">string</span>
|
|
138
|
+
</dt>
|
|
139
|
+
<dd> the entity name of SAP </dd>
|
|
140
|
+
<dt>entityId
|
|
141
|
+
<span class="property-type">number | string</span>
|
|
142
|
+
</dt>
|
|
143
|
+
<dd> the id of the entity of SAP </dd>
|
|
144
|
+
<dt>bodyPost
|
|
145
|
+
<span class="property-type">object</span>
|
|
146
|
+
</dt>
|
|
147
|
+
<dd> data to update to the entity </dd>
|
|
148
|
+
</dl>
|
|
149
|
+
|
|
150
|
+
<h3>Outputs</h3>
|
|
151
|
+
<ol class="node-ports">
|
|
152
|
+
<li>Standard output
|
|
153
|
+
<dl class="message-properties">
|
|
154
|
+
<dt>payload <span class="property-type">string</span></dt>
|
|
155
|
+
<dd>the standard output of the command.</dd>
|
|
156
|
+
</dl>
|
|
157
|
+
</li>
|
|
158
|
+
</ol>
|
|
159
|
+
|
|
160
|
+
<h3>Details</h3>
|
|
161
|
+
<p>this node is used to update the entity of SAP.
|
|
162
|
+
See the examples to understand how to use it.
|
|
163
|
+
</p>
|
|
164
|
+
<!-- <p><code>msg.payload</code> is used as the payload of the published message.
|
|
165
|
+
If it contains an Object it will be converted to a JSON string before being sent.
|
|
166
|
+
If it contains a binary Buffer the message will be published as-is.</p>
|
|
167
|
+
<p>The topic used can be configured in the node or, if left blank, can be set
|
|
168
|
+
by <code>msg.topic</code>.</p>
|
|
169
|
+
<p>Likewise the QoS and retain values can be configured in the node or, if left
|
|
170
|
+
blank, set by <code>msg.qos</code> and <code>msg.retain</code> respectively.</p> -->
|
|
171
|
+
|
|
172
|
+
<h3>References</h3>
|
|
173
|
+
<ul>
|
|
174
|
+
<li><a href="https://sap-samples.github.io/smb-summit-hackathon/b1sl.html" target="_black">Service layer API docs</a> - for more details </li>
|
|
175
|
+
<li><a href="https://github.com/yousolution-cloud/node-red-contrib-you-sap-service-layer">@yousolution-cloud/node-red-contrib-you-sap-service-layer</a> - the nodes github repository</li>
|
|
176
|
+
</ul>
|
|
177
|
+
</script>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
2
|
+
const axios = require('axios');
|
|
3
|
+
const Support = require('./support');
|
|
4
|
+
const entities = require('../resources/entities.json');
|
|
5
|
+
|
|
6
|
+
module.exports = function (RED) {
|
|
7
|
+
function ManipulateEntitySap(config) {
|
|
8
|
+
RED.nodes.createNode(this, config);
|
|
9
|
+
const node = this;
|
|
10
|
+
|
|
11
|
+
// reset status
|
|
12
|
+
node.status({});
|
|
13
|
+
|
|
14
|
+
node.on('input', async (msg, send, done) => {
|
|
15
|
+
// reset status
|
|
16
|
+
node.status({});
|
|
17
|
+
try {
|
|
18
|
+
const data = msg[config.bodyPost];
|
|
19
|
+
// if (!data) {
|
|
20
|
+
// node.status({ fill: 'red', shape: 'dot', text: 'bodyPatch must have value' });
|
|
21
|
+
// done(new Error('bodyPatch must have value'));
|
|
22
|
+
// return;
|
|
23
|
+
// }
|
|
24
|
+
const options = { method: 'POST', hasRawQuery: false, hasEntityId: true, isManipulate: true, data: data };
|
|
25
|
+
const login = Support.login;
|
|
26
|
+
const result = await Support.sendRequest({ node, msg, config, axios, login, options });
|
|
27
|
+
msg.payload = result.data;
|
|
28
|
+
msg.statusCode = result.status;
|
|
29
|
+
node.status({ fill: 'green', shape: 'dot', text: 'success' });
|
|
30
|
+
node.send(msg);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
node.status({ fill: 'red', shape: 'dot', text: 'Error' });
|
|
33
|
+
done(error);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
RED.httpAdmin.get('/entities', RED.auth.needsPermission('manipulateEntitySap.read'), (req, res) => {
|
|
39
|
+
console.log('entities');
|
|
40
|
+
res.json(entities);
|
|
41
|
+
});
|
|
42
|
+
RED.nodes.registerType('manipulateEntitySap', ManipulateEntitySap, {});
|
|
43
|
+
};
|
package/nodes/nextLink.html
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
</div>
|
|
34
34
|
|
|
35
35
|
<div class="form-row">
|
|
36
|
-
<label for="node-input-type"><i class="fa fa-
|
|
36
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> NextLink</label>
|
|
37
37
|
<input type="text" id="node-input-nextLink">
|
|
38
38
|
<input type="hidden" id="node-input-nextLink-type">
|
|
39
39
|
</div>
|
package/nodes/patchSap.html
CHANGED
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
</div>
|
|
86
86
|
|
|
87
87
|
<div class="form-row">
|
|
88
|
-
<label for="node-input-type"><i class="fa fa-
|
|
88
|
+
<label for="node-input-type"><i class="fa fa-cube"></i> Entity</label>
|
|
89
89
|
<select name="node-input-entity" id="node-input-entity">
|
|
90
90
|
<option value="AccountCategory">AccountCategory</option>
|
|
91
91
|
<option value="AccountSegmentations">AccountSegmentations</option>
|
|
@@ -341,31 +341,31 @@
|
|
|
341
341
|
</div>
|
|
342
342
|
|
|
343
343
|
<div class="form-row" style="display:none" id="container-entityId">
|
|
344
|
-
<label for="node-input-type"><i class="fa fa-
|
|
344
|
+
<label for="node-input-type"><i class="fa fa-key"></i> EntityId</label>
|
|
345
345
|
<input type="text" id="node-input-entityId">
|
|
346
346
|
<input type="hidden" id="node-input-entityId-type">
|
|
347
347
|
</div>
|
|
348
348
|
|
|
349
349
|
<div class="form-row" style="display:none" id="container-docEntry">
|
|
350
|
-
<label for="node-input-type"><i class="fa fa-
|
|
350
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> DocEntry</label>
|
|
351
351
|
<input type="text" id="node-input-docEntry">
|
|
352
352
|
<input type="hidden" id="node-input-docEntry-type">
|
|
353
353
|
</div>
|
|
354
354
|
|
|
355
355
|
<div class="form-row" style="display:none" id="container-code">
|
|
356
|
-
<label for="node-input-type"><i class="fa fa-
|
|
356
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Code</label>
|
|
357
357
|
<input type="text" id="node-input-code">
|
|
358
358
|
<input type="hidden" id="node-input-code-type">
|
|
359
359
|
</div>
|
|
360
360
|
|
|
361
361
|
<div class="form-row">
|
|
362
|
-
<label for="node-input-type"><i class="fa fa-
|
|
362
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Headers</label>
|
|
363
363
|
<input type="text" id="node-input-headers">
|
|
364
364
|
<input type="hidden" id="node-input-headers-type">
|
|
365
365
|
</div>
|
|
366
366
|
|
|
367
367
|
<div class="form-row">
|
|
368
|
-
<label for="node-input-type"><i class="fa fa-
|
|
368
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> BodyPatch</label>
|
|
369
369
|
<input type="text" id="node-input-bodyPatch">
|
|
370
370
|
<input type="hidden" id="node-input-bodyPatch-type">
|
|
371
371
|
</div>
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
let servicesName = [];
|
|
3
|
+
let servicesData = {};
|
|
4
|
+
$.getJSON('services', (data, status) => {
|
|
5
|
+
for(service in data) {
|
|
6
|
+
servicesData = data;
|
|
7
|
+
servicesName.push(service);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
RED.nodes.registerType('serviceSap',{
|
|
11
|
+
category: 'Sap',
|
|
12
|
+
color: '#FFC300',
|
|
13
|
+
defaults: {
|
|
14
|
+
name: {value: ''},
|
|
15
|
+
serviceName: {value: ''},
|
|
16
|
+
service: {value: ''},
|
|
17
|
+
// entity: {value: ''},
|
|
18
|
+
// udo: {value: ''},
|
|
19
|
+
// udt: {value: ''},
|
|
20
|
+
// entityId: {value: ''},
|
|
21
|
+
// docEntry: {value: ''},
|
|
22
|
+
// code: {value: ''},
|
|
23
|
+
headers: {value: ''},
|
|
24
|
+
bodyPost: {value: ''}
|
|
25
|
+
},
|
|
26
|
+
inputs:1,
|
|
27
|
+
outputs:1,
|
|
28
|
+
icon: 'font-awesome/fa-gears',
|
|
29
|
+
label: function() {
|
|
30
|
+
return this.name||"Sap service";
|
|
31
|
+
},
|
|
32
|
+
oneditprepare: function() {
|
|
33
|
+
// $("#node-input-entityId").typedInput({
|
|
34
|
+
// type:"msg",
|
|
35
|
+
// types:["msg"],
|
|
36
|
+
// typeField: "#node-input-entityId-type",
|
|
37
|
+
// value: 'entityId'
|
|
38
|
+
// });
|
|
39
|
+
|
|
40
|
+
// $("#node-input-docEntry").typedInput({
|
|
41
|
+
// type:"msg",
|
|
42
|
+
// types:["msg"],
|
|
43
|
+
// typeField: "#node-input-docEntry-type",
|
|
44
|
+
// value: 'docEntry'
|
|
45
|
+
// });
|
|
46
|
+
|
|
47
|
+
// $("#node-input-code").typedInput({
|
|
48
|
+
// type:"msg",
|
|
49
|
+
// types:["msg"],
|
|
50
|
+
// typeField: "#node-input-code-type",
|
|
51
|
+
// value: 'code'
|
|
52
|
+
// });
|
|
53
|
+
|
|
54
|
+
$("#node-input-headers").typedInput({
|
|
55
|
+
type:"msg",
|
|
56
|
+
types:["msg"],
|
|
57
|
+
typeField: "#node-input-headers-type",
|
|
58
|
+
value: 'headers'
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
$("#node-input-bodyPost").typedInput({
|
|
62
|
+
type:"msg",
|
|
63
|
+
types:["msg"],
|
|
64
|
+
typeField: "#node-input-bodyPost-type",
|
|
65
|
+
value: 'bodyPost'
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// jQuery("#node-input-entity").change(function() {
|
|
69
|
+
// jQuery('#container-udo').hide();
|
|
70
|
+
// jQuery('#container-docEntry').hide();
|
|
71
|
+
// jQuery('#container-udt').hide();
|
|
72
|
+
// jQuery('#container-code').hide();
|
|
73
|
+
// jQuery('#container-entityId').hide();
|
|
74
|
+
|
|
75
|
+
// if (jQuery(this).val() === 'UDO'){
|
|
76
|
+
// jQuery('#container-udo').show();
|
|
77
|
+
// jQuery('#container-docEntry').show();
|
|
78
|
+
// }
|
|
79
|
+
// if (jQuery(this).val() === 'UDT'){
|
|
80
|
+
// jQuery('#container-udt').show();
|
|
81
|
+
// jQuery('#container-code').show();
|
|
82
|
+
// }
|
|
83
|
+
// if(jQuery(this).val() !== 'UDO' && jQuery(this).val() !== 'UDT') {
|
|
84
|
+
// jQuery('#container-entityId').show();
|
|
85
|
+
// }
|
|
86
|
+
// });
|
|
87
|
+
|
|
88
|
+
servicesName.forEach((service) => {
|
|
89
|
+
$('#node-input-serviceName')
|
|
90
|
+
.append($("<option></option>")
|
|
91
|
+
.attr("value", service)
|
|
92
|
+
.text(service));
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// set the previous value
|
|
96
|
+
if(this.serviceName) {
|
|
97
|
+
$('#node-input-serviceName').val(this.serviceName);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
$("#node-input-serviceName").change((event) => {
|
|
102
|
+
const service = $("#node-input-serviceName").val();
|
|
103
|
+
|
|
104
|
+
$('#node-input-service').empty();
|
|
105
|
+
|
|
106
|
+
if(servicesData[service]) {
|
|
107
|
+
servicesData[service].forEach((endpoint) => {
|
|
108
|
+
$('#node-input-service')
|
|
109
|
+
.append($("<option></option>")
|
|
110
|
+
.attr("value", endpoint)
|
|
111
|
+
.text(endpoint));
|
|
112
|
+
});
|
|
113
|
+
// trick check if change with click or not
|
|
114
|
+
if(!event.originalEvent){
|
|
115
|
+
$('#node-input-service').val(this.service);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
</script>
|
|
123
|
+
|
|
124
|
+
<script type="text/html" data-template-name="serviceSap">
|
|
125
|
+
<div class="form-row">
|
|
126
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
127
|
+
<input type="text" id="node-input-name" placeholder="Name">
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<div class="form-row">
|
|
131
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Service</label>
|
|
132
|
+
<select name="node-input-serviceName" id="node-input-serviceName">
|
|
133
|
+
<option></option>
|
|
134
|
+
</select>
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
<div class="form-row">
|
|
138
|
+
<label for="node-input-type"><i class="fa fa-gears"></i> Endpoint</label>
|
|
139
|
+
<select name="node-input-service" id="node-input-service">
|
|
140
|
+
</select>
|
|
141
|
+
</div>
|
|
142
|
+
|
|
143
|
+
<div class="form-row">
|
|
144
|
+
<label for="node-input-type"><i class="fa fa-cog"></i> Headers</label>
|
|
145
|
+
<input type="text" id="node-input-headers">
|
|
146
|
+
<input type="hidden" id="node-input-headers-type">
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<div class="form-row">
|
|
150
|
+
<label for="node-input-type"><i class="fa fa-cog"></i> BodyPost</label>
|
|
151
|
+
<input type="text" id="node-input-bodyPost">
|
|
152
|
+
<input type="hidden" id="node-input-bodyPost-type">
|
|
153
|
+
</div>
|
|
154
|
+
</script>
|
|
155
|
+
|
|
156
|
+
<!-- Documentation -->
|
|
157
|
+
<script type="text/html" data-help-name="serviceSap">
|
|
158
|
+
<p>Post action</p>
|
|
159
|
+
|
|
160
|
+
<h3>Inputs</h3>
|
|
161
|
+
<dl class="message-properties">
|
|
162
|
+
<dt>Name
|
|
163
|
+
<span class="property-type">string</span>
|
|
164
|
+
</dt>
|
|
165
|
+
<dd> the node's name </dd>
|
|
166
|
+
<dt>Entity
|
|
167
|
+
<span class="property-type">string</span>
|
|
168
|
+
</dt>
|
|
169
|
+
<dd> the entity name of SAP </dd>
|
|
170
|
+
<dt>entityId
|
|
171
|
+
<span class="property-type">number | string</span>
|
|
172
|
+
</dt>
|
|
173
|
+
<dd> the id of the entity of SAP </dd>
|
|
174
|
+
<dt>bodyPost
|
|
175
|
+
<span class="property-type">object</span>
|
|
176
|
+
</dt>
|
|
177
|
+
<dd> data to update to the entity </dd>
|
|
178
|
+
</dl>
|
|
179
|
+
|
|
180
|
+
<h3>Outputs</h3>
|
|
181
|
+
<ol class="node-ports">
|
|
182
|
+
<li>Standard output
|
|
183
|
+
<dl class="message-properties">
|
|
184
|
+
<dt>payload <span class="property-type">string</span></dt>
|
|
185
|
+
<dd>the standard output of the command.</dd>
|
|
186
|
+
</dl>
|
|
187
|
+
</li>
|
|
188
|
+
</ol>
|
|
189
|
+
|
|
190
|
+
<h3>Details</h3>
|
|
191
|
+
<p>this node is used to update the entity of SAP.
|
|
192
|
+
See the examples to understand how to use it.
|
|
193
|
+
</p>
|
|
194
|
+
<!-- <p><code>msg.payload</code> is used as the payload of the published message.
|
|
195
|
+
If it contains an Object it will be converted to a JSON string before being sent.
|
|
196
|
+
If it contains a binary Buffer the message will be published as-is.</p>
|
|
197
|
+
<p>The topic used can be configured in the node or, if left blank, can be set
|
|
198
|
+
by <code>msg.topic</code>.</p>
|
|
199
|
+
<p>Likewise the QoS and retain values can be configured in the node or, if left
|
|
200
|
+
blank, set by <code>msg.qos</code> and <code>msg.retain</code> respectively.</p> -->
|
|
201
|
+
|
|
202
|
+
<h3>References</h3>
|
|
203
|
+
<ul>
|
|
204
|
+
<li><a href="https://sap-samples.github.io/smb-summit-hackathon/b1sl.html" target="_black">Service layer API docs</a> - for more details </li>
|
|
205
|
+
<li><a href="https://github.com/yousolution-cloud/node-red-contrib-you-sap-service-layer">@yousolution-cloud/node-red-contrib-you-sap-service-layer</a> - the nodes github repository</li>
|
|
206
|
+
</ul>
|
|
207
|
+
</script>
|