@gregoriusrippenstein/node-red-contrib-nodedev 0.2.7 → 0.2.9
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.
|
@@ -132,34 +132,7 @@
|
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
function
|
|
136
|
-
|
|
137
|
-
var data = {};
|
|
138
|
-
|
|
139
|
-
/* the data has not been stored on the node when this is called,
|
|
140
|
-
need to retrieve everything from the various fields...
|
|
141
|
-
*/
|
|
142
|
-
data["summary"] = node.editorSummary.getValue();
|
|
143
|
-
data["description"] = node.editorDesc.getValue();
|
|
144
|
-
|
|
145
|
-
data["color"] = $('#node-input-colour').val();
|
|
146
|
-
data["icon"] = $('#red-ui-editor-node-icon').val();
|
|
147
|
-
data["iconclass"] = "fa " + data["icon"].split("/")[1]; /* Assume font-awesomeness */
|
|
148
|
-
data["name"] = $('#node-input-nodename').val();
|
|
149
|
-
data["namelwr"] = data["name"].toLowerCase();
|
|
150
|
-
data["outputcount"] = $('#node-input-outputcount').val();
|
|
151
|
-
data["category"] = $('#node-input-category').val();
|
|
152
|
-
|
|
153
|
-
data["hasbutton"] = $('#node-input-hasbutton').is(":checked");
|
|
154
|
-
data["minify"] = $('#node-input-minify').is(":checked");
|
|
155
|
-
data["hasinput"] = $('#node-input-hasinput').is(":checked");
|
|
156
|
-
data["bak2frtcomm"] = $('#node-input-bak2frtcomm').is(":checked");
|
|
157
|
-
data["frt2bakcomm"] = $('#node-input-frt2bakcomm').is(":checked");
|
|
158
|
-
data["createmanifest"] = $('#node-input-createmanifest').is(":checked");
|
|
159
|
-
data["isplugin"] = $('#node-input-isplugin').is(":checked");
|
|
160
|
-
|
|
161
|
-
data["__task"] = "generate_from_templates";
|
|
162
|
-
|
|
135
|
+
function postDataOff(node,data) {
|
|
163
136
|
$.ajax({
|
|
164
137
|
url: "NodeFactory/" + node.id,
|
|
165
138
|
type: "POST",
|
|
@@ -201,7 +174,52 @@
|
|
|
201
174
|
}
|
|
202
175
|
});
|
|
203
176
|
}
|
|
204
|
-
|
|
177
|
+
|
|
178
|
+
function doSubmission(node) {
|
|
179
|
+
let data = {};
|
|
180
|
+
|
|
181
|
+
/* the data has not been stored on the node when this is called,
|
|
182
|
+
need to retrieve everything from the various fields...
|
|
183
|
+
*/
|
|
184
|
+
data["summary"] = node.editorSummary.getValue();
|
|
185
|
+
data["description"] = node.editorDesc.getValue();
|
|
186
|
+
|
|
187
|
+
data["color"] = $('#node-input-colour').val();
|
|
188
|
+
data["icon"] = $('#red-ui-editor-node-icon').val();
|
|
189
|
+
data["iconclass"] = "fa " + data["icon"].split("/")[1]; /* Assume font-awesomeness */
|
|
190
|
+
data["name"] = $('#node-input-nodename').val();
|
|
191
|
+
data["namelwr"] = data["name"].toLowerCase();
|
|
192
|
+
data["outputcount"] = $('#node-input-outputcount').val();
|
|
193
|
+
data["category"] = $('#node-input-category').val();
|
|
194
|
+
|
|
195
|
+
data["hasbutton"] = $('#node-input-hasbutton').is(":checked");
|
|
196
|
+
data["minify"] = $('#node-input-minify').is(":checked");
|
|
197
|
+
data["hasinput"] = $('#node-input-hasinput').is(":checked");
|
|
198
|
+
data["bak2frtcomm"] = $('#node-input-bak2frtcomm').is(":checked");
|
|
199
|
+
data["frt2bakcomm"] = $('#node-input-frt2bakcomm').is(":checked");
|
|
200
|
+
data["createmanifest"] = $('#node-input-createmanifest').is(":checked");
|
|
201
|
+
data["isplugin"] = $('#node-input-isplugin').is(":checked");
|
|
202
|
+
|
|
203
|
+
data["__task"] = "generate_from_templates";
|
|
204
|
+
|
|
205
|
+
postDataOff(node,data)
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function doButtonSubmission(node) {
|
|
209
|
+
let data = {}
|
|
210
|
+
|
|
211
|
+
Object.keys(node._def.defaults).forEach( attrname => {
|
|
212
|
+
data[attrname] = node[attrname]
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
data["name"] = node.nodename; // name clashes with the default 'name' attribute
|
|
216
|
+
data["namelwr"] = data["name"].toLowerCase();
|
|
217
|
+
data["iconclass"] = "fa " + data["icon"].split("/")[1]; /* Assume font-awesomeness */
|
|
218
|
+
data["__task"] = "generate_from_templates";
|
|
219
|
+
|
|
220
|
+
postDataOff(node,data)
|
|
221
|
+
}
|
|
222
|
+
|
|
205
223
|
RED.nodes.registerType('NodeFactory', {
|
|
206
224
|
color: "#e5e4ef",
|
|
207
225
|
category: 'nodedev',
|
|
@@ -364,6 +382,22 @@
|
|
|
364
382
|
|
|
365
383
|
oneditresize: function (size) {
|
|
366
384
|
},
|
|
385
|
+
|
|
386
|
+
button: {
|
|
387
|
+
enabled: function() {
|
|
388
|
+
return !this.changed
|
|
389
|
+
},
|
|
390
|
+
|
|
391
|
+
onclick: function () {
|
|
392
|
+
if (this.changed) {
|
|
393
|
+
return RED.notify(RED._("notification.warning", {
|
|
394
|
+
message: RED._("notification.warnings.undeployedChanges")
|
|
395
|
+
}), "warning");
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
doButtonSubmission(this)
|
|
399
|
+
}
|
|
400
|
+
},
|
|
367
401
|
});
|
|
368
402
|
})();
|
|
369
403
|
|
package/nodes/10-node-factory.js
CHANGED
|
@@ -225,6 +225,7 @@ module.exports = function (RED) {
|
|
|
225
225
|
|
|
226
226
|
function createSimpleNodeDefintions(msg,node) {
|
|
227
227
|
var htmlPath = path.join(__dirname, 'templates', 'tmpl.html');
|
|
228
|
+
var htmlJsPath = path.join(__dirname, 'templates', 'tmpl.html.js');
|
|
228
229
|
var jsPath = path.join(__dirname, 'templates', 'tmpl.js');
|
|
229
230
|
var localeJsonPath = path.join(__dirname, 'templates', 'locale', 'en-US', 'tmpl.json')
|
|
230
231
|
var localeHtmlPath = path.join(__dirname, 'templates', 'locale', 'en-US', 'tmpl.html')
|
|
@@ -233,6 +234,7 @@ module.exports = function (RED) {
|
|
|
233
234
|
|
|
234
235
|
var promises = [
|
|
235
236
|
handleTemplate(msg, node, fs.readFileSync(htmlPath, 'utf8')).then((c) => { content["html"] = c }),
|
|
237
|
+
handleTemplate(msg, node, fs.readFileSync(htmlJsPath, 'utf8')).then((c) => { content["htjs"] = c }),
|
|
236
238
|
handleTemplate(msg, node, fs.readFileSync(jsPath, 'utf8')).then((c) => { content["jasc"] = c }),
|
|
237
239
|
handleTemplate(msg, node, fs.readFileSync(localeJsonPath, 'utf8')).then((c) => { content["ljsn"] = c }),
|
|
238
240
|
handleTemplate(msg, node, fs.readFileSync(localeHtmlPath, 'utf8')).then((c) => { content["lhtm"] = c }),
|
|
@@ -240,6 +242,7 @@ module.exports = function (RED) {
|
|
|
240
242
|
|
|
241
243
|
return Promise.all(promises).then(() => {
|
|
242
244
|
var secondId = RED.util.generateId();
|
|
245
|
+
var secondIdTempJs = RED.util.generateId();
|
|
243
246
|
var thirdId = RED.util.generateId();
|
|
244
247
|
var fourthId = RED.util.generateId();
|
|
245
248
|
|
|
@@ -254,7 +257,24 @@ module.exports = function (RED) {
|
|
|
254
257
|
output: "str",
|
|
255
258
|
x: 100,
|
|
256
259
|
y: 50,
|
|
257
|
-
wires: [[
|
|
260
|
+
wires: [[secondIdTempJs]]
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"id": secondIdTempJs,
|
|
264
|
+
"type": "template",
|
|
265
|
+
"name": msg.node.name + ".html.js",
|
|
266
|
+
"field": msg.node.name+ "TmplJs",
|
|
267
|
+
"fieldType": "msg",
|
|
268
|
+
"format": "javascript",
|
|
269
|
+
"syntax": "mustache",
|
|
270
|
+
"template": content["htjs"],
|
|
271
|
+
"x": 100,
|
|
272
|
+
"y": 100,
|
|
273
|
+
"wires": [
|
|
274
|
+
[
|
|
275
|
+
secondId
|
|
276
|
+
]
|
|
277
|
+
]
|
|
258
278
|
},
|
|
259
279
|
{
|
|
260
280
|
id: secondId,
|
|
@@ -266,7 +286,7 @@ module.exports = function (RED) {
|
|
|
266
286
|
format: "html",
|
|
267
287
|
output: "str",
|
|
268
288
|
x: 100,
|
|
269
|
-
y:
|
|
289
|
+
y: 150,
|
|
270
290
|
wires: [[thirdId]]
|
|
271
291
|
},
|
|
272
292
|
{
|
|
@@ -279,7 +299,7 @@ module.exports = function (RED) {
|
|
|
279
299
|
format: "json",
|
|
280
300
|
output: "str",
|
|
281
301
|
x: 120,
|
|
282
|
-
y:
|
|
302
|
+
y: 200,
|
|
283
303
|
wires: [[fourthId]]
|
|
284
304
|
},
|
|
285
305
|
{
|
|
@@ -292,7 +312,7 @@ module.exports = function (RED) {
|
|
|
292
312
|
format: "html",
|
|
293
313
|
output: "str",
|
|
294
314
|
x: 120,
|
|
295
|
-
y:
|
|
315
|
+
y: 250,
|
|
296
316
|
wires: [[]]
|
|
297
317
|
}
|
|
298
318
|
]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"{{ node.
|
|
2
|
+
"{{ node.namelwr }}": {
|
|
3
3
|
{{#node.bak2frtcomm}}
|
|
4
4
|
"label": {
|
|
5
5
|
"commfrombackend": "Backend sent something to the frontend - check browser console.",
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
"buttonpressed": "button pressed on frontend",
|
|
11
11
|
"success": "Successfully sent something to the backend"
|
|
12
12
|
{{ /node.frt2bakcomm }}
|
|
13
|
+
,
|
|
14
|
+
"statusset": "Status Set"
|
|
13
15
|
},
|
|
14
16
|
{{/node.bak2frtcomm}}
|
|
15
17
|
|
|
@@ -18,7 +20,8 @@
|
|
|
18
20
|
"label": {
|
|
19
21
|
"submissionfailed": "submission failed",
|
|
20
22
|
"buttonpressed": "button pressed on frontend",
|
|
21
|
-
"success": "Successfully sent something to the backend"
|
|
23
|
+
"success": "Successfully sent something to the backend",
|
|
24
|
+
"statusset": "Status Set"
|
|
22
25
|
},
|
|
23
26
|
{{/node.frt2bakcomm }}
|
|
24
27
|
{{/node.bak2frtcomm}}
|
|
@@ -26,17 +29,11 @@
|
|
|
26
29
|
{{^node.bak2frtcomm}}
|
|
27
30
|
{{^node.frt2bakcomm }}
|
|
28
31
|
"label": {
|
|
29
|
-
"
|
|
32
|
+
"statusset": "Status Set"
|
|
30
33
|
},
|
|
31
34
|
{{/node.frt2bakcomm }}
|
|
32
35
|
{{/node.bak2frtcomm}}
|
|
33
36
|
|
|
34
|
-
"error": {
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
"tip": {
|
|
38
|
-
|
|
39
|
-
},
|
|
40
37
|
"status": {
|
|
41
38
|
"waiting": "Waiting for Godot",
|
|
42
39
|
"timeout": "No more time to waiting"
|
|
@@ -1,145 +1,5 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
{{ #node.frt2bakcomm }}
|
|
5
|
-
function sendToBackend(node,data = {}) {
|
|
6
|
-
|
|
7
|
-
$.ajax({
|
|
8
|
-
url: "{{ node.name }}/" + node.id,
|
|
9
|
-
type: "POST",
|
|
10
|
-
contentType: "application/json; charset=utf-8",
|
|
11
|
-
|
|
12
|
-
data: JSON.stringify({
|
|
13
|
-
...data,
|
|
14
|
-
hello: "world",
|
|
15
|
-
}),
|
|
16
|
-
|
|
17
|
-
success: function (resp) {
|
|
18
|
-
RED.notify( RED._("{{ node.name}}.label.success"), {
|
|
19
|
-
type: "warning",
|
|
20
|
-
id: "{{node.name}}",
|
|
21
|
-
timeout: 2000
|
|
22
|
-
});
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
error: function (jqXHR, textStatus, errorThrown) {
|
|
26
|
-
if (jqXHR.status == 404) {
|
|
27
|
-
RED.notify("Node has not yet been deployed, please deploy.", "error");
|
|
28
|
-
} else if (jqXHR.status == 405) {
|
|
29
|
-
RED.notify("Not Allowed.", "error");
|
|
30
|
-
} else if (jqXHR.status == 500) {
|
|
31
|
-
RED.notify(node._("common.notification.error", {
|
|
32
|
-
message: node._("inject.errors.failed")
|
|
33
|
-
}), "error");
|
|
34
|
-
} else if (jqXHR.status == 0) {
|
|
35
|
-
RED.notify(node._("common.notification.error", {
|
|
36
|
-
message: node._("common.notification.errors.no-response")
|
|
37
|
-
}), "error");
|
|
38
|
-
} else {
|
|
39
|
-
RED.notify(node._("common.notification.error", {
|
|
40
|
-
message: node._("common.notification.errors.unexpected", {
|
|
41
|
-
status: jqXHR.status, message: textStatus }) }), "error");
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
{{ /node.frt2bakcomm }}
|
|
47
|
-
|
|
48
|
-
function frontendSupportFunction() {
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
var functTwo = (arg) => {
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
RED.nodes.registerType('{{ node.name }}',{
|
|
56
|
-
color: '{{ node.color }}',
|
|
57
|
-
icon: "{{{ node.icon }}}",
|
|
58
|
-
category: '{{ node.category }}',
|
|
59
|
-
defaults: {
|
|
60
|
-
name: {
|
|
61
|
-
value:"",
|
|
62
|
-
},
|
|
63
|
-
{{#node.minify}}
|
|
64
|
-
l: { value: false },
|
|
65
|
-
{{/node.minify}}
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
{{#node.hasinput}}
|
|
69
|
-
inputs: 1,
|
|
70
|
-
{{/node.hasinput}}
|
|
71
|
-
{{^node.hasinput}}
|
|
72
|
-
inputs: 0,
|
|
73
|
-
{{/node.hasinput}}
|
|
74
|
-
|
|
75
|
-
outputs: {{ node.outputcount }},
|
|
76
|
-
|
|
77
|
-
label: function() {
|
|
78
|
-
return (this.name || this._def.paletteLabel);
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
labelStyle: function() {
|
|
82
|
-
return this.name?"node_label_italic":"";
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
onpaletteadd: function() {
|
|
86
|
-
{{#node.bak2frtcomm}}
|
|
87
|
-
this.messageFromBackendHandler = (topic,dataobj) => {
|
|
88
|
-
console.log( "here goes the code for handling a message from the backend", topic, dataobj);
|
|
89
|
-
|
|
90
|
-
RED.notify(RED._("{{ node.name}}.label.commfrombackend"), {
|
|
91
|
-
type: "success",
|
|
92
|
-
id: "{{node.name}}",
|
|
93
|
-
timeout: 2000
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
RED.comms.subscribe('{{node.name}}:message-from-backend',this.messageFromBackendHandler);
|
|
97
|
-
{{/node.bak2frtcomm}}
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
onpaletteremove: function() {
|
|
101
|
-
{{#node.bak2frtcomm}}
|
|
102
|
-
RED.comms.unsubscribe('{{node.name}}:message-from-backend',this.messageFromBackendHandler);
|
|
103
|
-
{{/node.bak2frtcomm}}
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
oneditprepare: function() {
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
oneditcancel: function() {
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
oneditsave: function() {
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
oneditresize: function(size) {
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
{{#node.hasbutton}}
|
|
119
|
-
button: {
|
|
120
|
-
enabled: function() {
|
|
121
|
-
return !this.changed
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
onclick: function () {
|
|
125
|
-
if (this.changed) {
|
|
126
|
-
return RED.notify(RED._("notification.warning", {
|
|
127
|
-
message: RED._("notification.warnings.undeployedChanges")
|
|
128
|
-
}), "warning");
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
{{ #node.frt2bakcomm }}
|
|
132
|
-
var that = this;
|
|
133
|
-
sendToBackend(that, {"payload": RED._("{{ node.name}}.label.buttonpressed")})
|
|
134
|
-
{{ /node.frt2bakcomm }}
|
|
135
|
-
|
|
136
|
-
/* here goes the button code to be executed on click */
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
{{/node.hasbutton}}
|
|
140
|
-
|
|
141
|
-
});
|
|
142
|
-
})();
|
|
2
|
+
{{ __.ocb3 }} {{ node.name }}TmplJs {{ __.ccb3 }}
|
|
143
3
|
</script>
|
|
144
4
|
|
|
145
5
|
<script type="text/html" data-template-name="{{ node.name }}">
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
(function(){
|
|
2
|
+
|
|
3
|
+
{{ #node.frt2bakcomm }}
|
|
4
|
+
function sendToBackend(node,data = {}) {
|
|
5
|
+
|
|
6
|
+
$.ajax({
|
|
7
|
+
url: "{{ node.name }}/" + node.id,
|
|
8
|
+
type: "POST",
|
|
9
|
+
contentType: "application/json; charset=utf-8",
|
|
10
|
+
|
|
11
|
+
data: JSON.stringify({
|
|
12
|
+
...data,
|
|
13
|
+
hello: "world",
|
|
14
|
+
}),
|
|
15
|
+
|
|
16
|
+
success: function (resp) {
|
|
17
|
+
RED.notify( node._("{{ node.namelwr }}.label.success"), {
|
|
18
|
+
type: "warning",
|
|
19
|
+
timeout: 2000
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
error: function (jqXHR, textStatus, errorThrown) {
|
|
24
|
+
if (jqXHR.status == 404) {
|
|
25
|
+
RED.notify("Node has not yet been deployed, please deploy.", "error");
|
|
26
|
+
} else if (jqXHR.status == 405) {
|
|
27
|
+
RED.notify("Not Allowed.", "error");
|
|
28
|
+
} else if (jqXHR.status == 500) {
|
|
29
|
+
RED.notify(node._("common.notification.error", {
|
|
30
|
+
message: node._("inject.errors.failed")
|
|
31
|
+
}), "error");
|
|
32
|
+
} else if (jqXHR.status == 0) {
|
|
33
|
+
RED.notify(node._("common.notification.error", {
|
|
34
|
+
message: node._("common.notification.errors.no-response")
|
|
35
|
+
}), "error");
|
|
36
|
+
} else {
|
|
37
|
+
RED.notify(node._("common.notification.error", {
|
|
38
|
+
message: node._("common.notification.errors.unexpected", {
|
|
39
|
+
status: jqXHR.status, message: textStatus }) }), "error");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
{{ /node.frt2bakcomm }}
|
|
45
|
+
|
|
46
|
+
function frontendSupportFunction() {
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var functTwo = (arg) => {
|
|
50
|
+
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
RED.nodes.registerType('{{ node.name }}',{
|
|
54
|
+
color: '{{ node.color }}',
|
|
55
|
+
icon: "{{{ node.icon }}}",
|
|
56
|
+
category: '{{ node.category }}',
|
|
57
|
+
defaults: {
|
|
58
|
+
name: {
|
|
59
|
+
value:"",
|
|
60
|
+
},
|
|
61
|
+
{{#node.minify}}
|
|
62
|
+
l: { value: false },
|
|
63
|
+
{{/node.minify}}
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
{{#node.hasinput}}
|
|
67
|
+
inputs: 1,
|
|
68
|
+
{{/node.hasinput}}
|
|
69
|
+
{{^node.hasinput}}
|
|
70
|
+
inputs: 0,
|
|
71
|
+
{{/node.hasinput}}
|
|
72
|
+
|
|
73
|
+
outputs: {{ node.outputcount }},
|
|
74
|
+
|
|
75
|
+
label: function() {
|
|
76
|
+
return (this.name || this._def.paletteLabel);
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
labelStyle: function() {
|
|
80
|
+
return this.name?"node_label_italic":"";
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
onpaletteadd: function() {
|
|
84
|
+
{{#node.bak2frtcomm}}
|
|
85
|
+
this.messageFromBackendHandler = (topic,dataobj) => {
|
|
86
|
+
console.log( "here goes the code for handling a message from the backend", topic, dataobj);
|
|
87
|
+
|
|
88
|
+
RED.notify(this._("{{ node.namelwr}}.label.commfrombackend"), {
|
|
89
|
+
type: "success",
|
|
90
|
+
timeout: 2000
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
RED.comms.subscribe('{{node.name}}:message-from-backend',this.messageFromBackendHandler);
|
|
94
|
+
{{/node.bak2frtcomm}}
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
onpaletteremove: function() {
|
|
98
|
+
{{#node.bak2frtcomm}}
|
|
99
|
+
RED.comms.unsubscribe('{{node.name}}:message-from-backend',this.messageFromBackendHandler);
|
|
100
|
+
{{/node.bak2frtcomm}}
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
oneditprepare: function() {
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
oneditcancel: function() {
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
oneditsave: function() {
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
oneditresize: function(size) {
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
{{#node.hasbutton}}
|
|
116
|
+
button: {
|
|
117
|
+
enabled: function() {
|
|
118
|
+
return !this.changed
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
onclick: function () {
|
|
122
|
+
if (this.changed) {
|
|
123
|
+
return RED.notify(RED._("notification.warning", {
|
|
124
|
+
message: RED._("notification.warnings.undeployedChanges")
|
|
125
|
+
}), "warning");
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
{{ #node.frt2bakcomm }}
|
|
129
|
+
var that = this;
|
|
130
|
+
sendToBackend(that, { "payload": that._("{{ node.namelwr}}.label.buttonpressed")})
|
|
131
|
+
{{ /node.frt2bakcomm }}
|
|
132
|
+
|
|
133
|
+
/* here goes the button code to be executed on click */
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{{/node.hasbutton}}
|
|
137
|
+
|
|
138
|
+
});
|
|
139
|
+
})();
|
package/nodes/templates/tmpl.js
CHANGED
|
@@ -15,12 +15,12 @@ module.exports = function(RED) {
|
|
|
15
15
|
RED.comms.publish("{{node.name}}:message-from-backend",
|
|
16
16
|
RED.util.encodeObject({
|
|
17
17
|
...msg,
|
|
18
|
-
"data": RED._("{{ node.
|
|
18
|
+
"data": RED._("{{ node.namelwr}}.label.msgfrombackend"),
|
|
19
19
|
})
|
|
20
20
|
);
|
|
21
21
|
{{/node.bak2frtcomm}}
|
|
22
22
|
// How to send a status update
|
|
23
|
-
node.status({ fill: "green", shape: "ring", text: "
|
|
23
|
+
node.status({ fill: "green", shape: "ring", text: RED._("{{ node.namelwr}}.label.statusset") });
|
|
24
24
|
|
|
25
25
|
// Send a message and how to handle errors.
|
|
26
26
|
try {
|
|
@@ -66,7 +66,7 @@ module.exports = function(RED) {
|
|
|
66
66
|
} catch (err) {
|
|
67
67
|
console.error(err);
|
|
68
68
|
res.status(500).send(err.toString());
|
|
69
|
-
node.error("{{ node.name }}: " + RED._("{{ node.
|
|
69
|
+
node.error("{{ node.name }}: " + RED._("{{ node.namelwr }}.label.submissionfailed") + ": " + err.toString(), { error: err })
|
|
70
70
|
}
|
|
71
71
|
} else {
|
|
72
72
|
res.sendStatus(404);
|