@gregoriusrippenstein/node-red-contrib-nodedev 0.1.7 → 0.1.8
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/README.md
CHANGED
|
@@ -62,10 +62,14 @@ Since all this happens in the browser, there is no leaving Node-RED, making it m
|
|
|
62
62
|
### Artifacts
|
|
63
63
|
|
|
64
64
|
- [Flow that maintains](https://flowhub.org/f/b92be5062203ff69) this codebase
|
|
65
|
-
- [GitHub repo](https://
|
|
65
|
+
- [GitHub repo](https://github.com/gorenje/node-red-contrib-nodedev)
|
|
66
66
|
- [NPMjs node package](https://www.npmjs.com/package/@gregoriusrippenstein/node-red-contrib-nodedev)
|
|
67
67
|
- [Node-RED node package](https://flows.nodered.org/node/@gregoriusrippenstein/node-red-contrib-nodedev)
|
|
68
68
|
|
|
69
|
+
### Similar Projects
|
|
70
|
+
|
|
71
|
+
- [node-maker](https://github.com/steveorevo/node-maker) which helps to make UI components for nodes in Node-RED.
|
|
72
|
+
|
|
69
73
|
### Outlook
|
|
70
74
|
|
|
71
75
|
Wherever the road shall lead, there it will go.
|
package/nodes/10-node-factory.js
CHANGED
|
@@ -226,16 +226,22 @@ module.exports = function (RED) {
|
|
|
226
226
|
function createSimpleNodeDefintions(msg,node) {
|
|
227
227
|
var htmlPath = path.join(__dirname, 'templates', 'tmpl.html');
|
|
228
228
|
var jsPath = path.join(__dirname, 'templates', 'tmpl.js');
|
|
229
|
+
var localeJsonPath = path.join(__dirname, 'templates', 'locale', 'en-US', 'tmpl.json')
|
|
230
|
+
var localeHtmlPath = path.join(__dirname, 'templates', 'locale', 'en-US', 'tmpl.html')
|
|
229
231
|
|
|
230
232
|
var content = {};
|
|
231
233
|
|
|
232
234
|
var promises = [
|
|
233
235
|
handleTemplate(msg, node, fs.readFileSync(htmlPath, 'utf8')).then((c) => { content["html"] = c }),
|
|
234
236
|
handleTemplate(msg, node, fs.readFileSync(jsPath, 'utf8')).then((c) => { content["jasc"] = c }),
|
|
237
|
+
handleTemplate(msg, node, fs.readFileSync(localeJsonPath, 'utf8')).then((c) => { content["ljsn"] = c }),
|
|
238
|
+
handleTemplate(msg, node, fs.readFileSync(localeHtmlPath, 'utf8')).then((c) => { content["lhtm"] = c }),
|
|
235
239
|
];
|
|
236
240
|
|
|
237
241
|
return Promise.all(promises).then(() => {
|
|
238
242
|
var secondId = RED.util.generateId();
|
|
243
|
+
var thirdId = RED.util.generateId();
|
|
244
|
+
var fourthId = RED.util.generateId();
|
|
239
245
|
|
|
240
246
|
return [{
|
|
241
247
|
id: RED.util.generateId(),
|
|
@@ -250,7 +256,6 @@ module.exports = function (RED) {
|
|
|
250
256
|
y: 50,
|
|
251
257
|
wires: [[secondId]]
|
|
252
258
|
},
|
|
253
|
-
|
|
254
259
|
{
|
|
255
260
|
id: secondId,
|
|
256
261
|
type: "PkgFile",
|
|
@@ -262,8 +267,35 @@ module.exports = function (RED) {
|
|
|
262
267
|
output: "str",
|
|
263
268
|
x: 100,
|
|
264
269
|
y: 100,
|
|
270
|
+
wires: [[thirdId]]
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
id: thirdId,
|
|
274
|
+
type: "PkgFile",
|
|
275
|
+
name: "Locale: " + msg.node.name + ".json",
|
|
276
|
+
filename: "nodes/locales/en-US/" + msg.node.namelwr + ".json",
|
|
277
|
+
template: content["ljsn"],
|
|
278
|
+
syntax: "mustache",
|
|
279
|
+
format: "json",
|
|
280
|
+
output: "str",
|
|
281
|
+
x: 120,
|
|
282
|
+
y: 150,
|
|
283
|
+
wires: [[fourthId]]
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
id: fourthId,
|
|
287
|
+
type: "PkgFile",
|
|
288
|
+
name: "Locale: " + msg.node.name + ".html",
|
|
289
|
+
filename: "nodes/locales/en-US/" + msg.node.namelwr + ".html",
|
|
290
|
+
template: content["lhtm"],
|
|
291
|
+
syntax: "mustache",
|
|
292
|
+
format: "html",
|
|
293
|
+
output: "str",
|
|
294
|
+
x: 120,
|
|
295
|
+
y: 200,
|
|
265
296
|
wires: [[]]
|
|
266
|
-
}
|
|
297
|
+
}
|
|
298
|
+
]
|
|
267
299
|
})
|
|
268
300
|
}
|
|
269
301
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"{{ node.name }}": {
|
|
3
|
+
{{#node.bak2frtcomm}}
|
|
4
|
+
"notify": {
|
|
5
|
+
"commfrombackend": "Backend sent something to the frontend - check browser console.",
|
|
6
|
+
"msgfrombackend": "message from backend"
|
|
7
|
+
{{ #node.frt2bakcomm }}
|
|
8
|
+
},
|
|
9
|
+
{{ /node.frt2bakcomm }}
|
|
10
|
+
{{ ^node.frt2bakcomm }}
|
|
11
|
+
}
|
|
12
|
+
{{ /node.frt2bakcomm }}
|
|
13
|
+
{{/node.bak2frtcomm}}
|
|
14
|
+
|
|
15
|
+
{{ #node.frt2bakcomm }}
|
|
16
|
+
"notifyf2b": {
|
|
17
|
+
"submissionfailed": "submission failed",
|
|
18
|
+
"buttonpressed": "button pressed on frontend",
|
|
19
|
+
"success": "Successfully sent something to the backend"
|
|
20
|
+
}
|
|
21
|
+
{{ /node.frt2bakcomm }}
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
}),
|
|
16
16
|
|
|
17
17
|
success: function (resp) {
|
|
18
|
-
RED.notify("
|
|
18
|
+
RED.notify( RED._("{{ node.name}}.notifyf2b.success"), {
|
|
19
19
|
type: "warning",
|
|
20
20
|
id: "{{node.name}}",
|
|
21
21
|
timeout: 2000
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
this.messageFromBackendHandler = (topic,dataobj) => {
|
|
85
85
|
console.log( "here goes the code for handling a message from the backend", topic, dataobj);
|
|
86
86
|
|
|
87
|
-
RED.notify("
|
|
87
|
+
RED.notify(RED._("{{ node.name}}.notify.commfrombackend"), {
|
|
88
88
|
type: "success",
|
|
89
89
|
id: "{{node.name}}",
|
|
90
90
|
timeout: 2000
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
|
|
126
126
|
{{ #node.frt2bakcomm }}
|
|
127
127
|
var that = this;
|
|
128
|
-
sendToBackend(that, {"payload": "
|
|
128
|
+
sendToBackend(that, {"payload": RED._("{{ node.name}}.notifyf2b.buttonpressed")})
|
|
129
129
|
{{ /node.frt2bakcomm }}
|
|
130
130
|
|
|
131
131
|
/* here goes the button code to be executed on click */
|
|
@@ -138,13 +138,8 @@
|
|
|
138
138
|
</script>
|
|
139
139
|
|
|
140
140
|
<script type="text/html" data-template-name="{{ node.name }}">
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
</script>
|
|
146
|
-
|
|
147
|
-
<script type="text/html" data-help-name="{{ node.name }}">
|
|
148
|
-
<p>{{{ node.summary }}}</p>
|
|
149
|
-
{{{ node.description }}}
|
|
141
|
+
<div class="form-row">
|
|
142
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
|
|
143
|
+
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
|
|
144
|
+
</div>
|
|
150
145
|
</script>
|
package/nodes/templates/tmpl.js
CHANGED
|
@@ -14,8 +14,8 @@ module.exports = function(RED) {
|
|
|
14
14
|
{{#node.bak2frtcomm}}
|
|
15
15
|
RED.comms.publish("{{node.name}}:message-from-backend",
|
|
16
16
|
RED.util.encodeObject({
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
...msg,
|
|
18
|
+
"data": RED._("{{ node.name}}.notify.msgfrombackend"),
|
|
19
19
|
})
|
|
20
20
|
);
|
|
21
21
|
{{/node.bak2frtcomm}}
|
|
@@ -49,7 +49,7 @@ module.exports = function(RED) {
|
|
|
49
49
|
} catch (err) {
|
|
50
50
|
console.error(err);
|
|
51
51
|
res.status(500).send(err.toString());
|
|
52
|
-
node.error("{{ node.name }}:
|
|
52
|
+
node.error("{{ node.name }}: " + RED._("{{ node.name }}.notifyf2b.submissionfailed") + ": " + err.toString())
|
|
53
53
|
}
|
|
54
54
|
} else {
|
|
55
55
|
res.sendStatus(404);
|