@gregoriusrippenstein/node-red-contrib-nodedev 0.1.3 → 0.1.4
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 +11 -0
- package/nodes/templates/tmplsidebar.html +55 -2
- package/nodes/templates/tmplsidebarnode.js +21 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,17 @@ Examples are included:
|
|
|
28
28
|
- Converting an existing tar-gzip package file into a collection of `PkgFile` nodes for testing and maintaince and development --> [flow](https://flowhub.org/f/eef4037a6d25a1e0)
|
|
29
29
|
- `NodeFactory` example of creating a boilerplate node for inclusion in a node package that can be installed into Node-RED --> [flow](https://flowhub.org/f/7bece6814c033925)
|
|
30
30
|
|
|
31
|
+
### Config node with sidebar
|
|
32
|
+
|
|
33
|
+
The following [animation](https://cdn.openmindmap.org/content/1697462227098_confignode2.gif) shows how the example of a config node with sidebar button works:
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
This [animation](https://cdn.openmindmap.org/content/1697013164685_out-fps15.gif) shows the development and installation of a palette node:
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
|
|
31
42
|
### Tips
|
|
32
43
|
|
|
33
44
|
*How to avoid restarting Node-RED?*
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
if (globalYourConfigNode === null) {
|
|
17
17
|
var configNodes = [];
|
|
18
18
|
RED.nodes.eachConfig(function(configNode) {
|
|
19
|
-
if (configNode.type === '{{ node.name }}') {
|
|
19
|
+
if (configNode.type === '{{ node.name }}Cfg') {
|
|
20
20
|
configNodes.push(configNode);
|
|
21
21
|
}
|
|
22
22
|
});
|
|
@@ -80,6 +80,51 @@
|
|
|
80
80
|
|
|
81
81
|
ensureYourConfigNodeExists();
|
|
82
82
|
|
|
83
|
+
{{#node.frt2bakcomm}}
|
|
84
|
+
$('#node-input-button-to-server').on('click', (e) => {
|
|
85
|
+
if ( e ) { e.preventDefault(); }
|
|
86
|
+
$.ajax({
|
|
87
|
+
url: "{{ node.name }}Cfg",
|
|
88
|
+
type: "POST",
|
|
89
|
+
contentType: "application/json; charset=utf-8",
|
|
90
|
+
|
|
91
|
+
data: JSON.stringify({
|
|
92
|
+
"data": globalYourConfigNode.data
|
|
93
|
+
}),
|
|
94
|
+
|
|
95
|
+
success: function (resp) {
|
|
96
|
+
RED.notify("Server responded: " + resp.value, {
|
|
97
|
+
type: "success",
|
|
98
|
+
timeout: 2000
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
error: function (jqXHR, textStatus, errorThrown) {
|
|
104
|
+
if (jqXHR.status == 404) {
|
|
105
|
+
RED.notify("Node has not yet been deployed, please deploy.", "error");
|
|
106
|
+
} else if (jqXHR.status == 405) {
|
|
107
|
+
RED.notify("Not Allowed.", "error");
|
|
108
|
+
} else if (jqXHR.status == 500) {
|
|
109
|
+
RED.notify(node._("common.notification.error", {
|
|
110
|
+
message: node._("inject.errors.failed")
|
|
111
|
+
}), "error");
|
|
112
|
+
} else if (jqXHR.status == 0) {
|
|
113
|
+
RED.notify(node._("common.notification.error", {
|
|
114
|
+
message: node._("common.notification.errors.no-response")
|
|
115
|
+
}), "error");
|
|
116
|
+
} else {
|
|
117
|
+
RED.notify(node._("common.notification.error", {
|
|
118
|
+
message: node._("common.notification.errors.unexpected", {
|
|
119
|
+
status: jqXHR.status, message: textStatus
|
|
120
|
+
})
|
|
121
|
+
}), "error");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
{{/node.frt2bakcomm}}
|
|
127
|
+
|
|
83
128
|
{{#node.hasbutton}}
|
|
84
129
|
var doSomething = (e) => {
|
|
85
130
|
if (e) { e.preventDefault(); }
|
|
@@ -131,8 +176,16 @@
|
|
|
131
176
|
{{#node.hasbutton}}
|
|
132
177
|
<div class="form-row">
|
|
133
178
|
<div style="position: relative; height: 100%; margin: 15px;">
|
|
134
|
-
<button id="node-input-button"
|
|
179
|
+
<button id="node-input-button" style="width: 100%; margin-top: 30px">Do something</button>
|
|
135
180
|
</div>
|
|
136
181
|
</div>
|
|
137
182
|
{{/node.hasbutton}}
|
|
183
|
+
|
|
184
|
+
{{#node.frt2bakcomm}}
|
|
185
|
+
<div class="form-row">
|
|
186
|
+
<div style="position: relative; height: 100%; margin: 15px;">
|
|
187
|
+
<button id="node-input-button-to-server" style="width: 100%; margin-top: 30px">Send Data To Server</button>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
{{/node.frt2bakcomm}}
|
|
138
191
|
</script>
|
|
@@ -2,5 +2,26 @@ module.exports = function (RED) {
|
|
|
2
2
|
function Config{{ node.name }}Functionality(config) {
|
|
3
3
|
RED.nodes.createNode(this, config)
|
|
4
4
|
}
|
|
5
|
+
|
|
5
6
|
RED.nodes.registerType('{{ node.name }}Cfg', Config{{ node.name }}Functionality);
|
|
7
|
+
|
|
8
|
+
{{ #node.frt2bakcomm }}
|
|
9
|
+
RED.httpAdmin.post("/{{ node.name }}Cfg",
|
|
10
|
+
RED.auth.needsPermission("{{ node.name }}Cfg.write"),
|
|
11
|
+
(req, res) => {
|
|
12
|
+
try {
|
|
13
|
+
if (req.body) {
|
|
14
|
+
res.status(200).send({
|
|
15
|
+
"status": "ok",
|
|
16
|
+
"value": "server says, data was : '" + req.body.data + "'"
|
|
17
|
+
})
|
|
18
|
+
} else {
|
|
19
|
+
res.sendStatus(404);
|
|
20
|
+
}
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.error(err);
|
|
23
|
+
res.status(500).send(err.toString());
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
{{ /node.frt2bakcomm }}
|
|
6
27
|
}
|