@gregoriusrippenstein/node-red-contrib-nodedev 0.0.6 → 0.0.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
@@ -25,8 +25,8 @@ It also gets more confusing since these nodes will open the Node-RED import dial
25
25
 
26
26
  Examples are included:
27
27
 
28
- - Converting an existing tar-gzip package file into a collection of `PkgFile` nodes for testing and maintaince and development
29
- - `NodeFactory` example of creating a boilerplate node for inclusion in a node package that can be installed into Node-RED
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
+ - `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
31
  ### Tips
32
32
 
@@ -2,47 +2,29 @@
2
2
  {
3
3
  "id": "b84864b2ff870a45",
4
4
  "type": "group",
5
- "z": "b92be5062203ff69",
5
+ "z": "eef4037a6d25a1e0",
6
6
  "name": "automatically creating nodes that represent package files",
7
7
  "style": {
8
8
  "label": true
9
9
  },
10
10
  "nodes": [
11
- "7f69502a67b8c689",
12
11
  "ea7b1b985ba6ac70",
13
- "aeb3094ecf54b2b2",
14
12
  "24b26f5122abf1bb",
15
- "ab37a3f877541c5b"
13
+ "ab37a3f877541c5b",
14
+ "11289b70b58c767b",
15
+ "96278268709caba6",
16
+ "fc620efcbaf77846",
17
+ "d981181116ccfb16"
16
18
  ],
17
- "x": 2018.142822265625,
18
- "y": 735.7142333984375,
19
- "w": 865.857177734375,
20
- "h": 311.2857666015625
21
- },
22
- {
23
- "id": "7f69502a67b8c689",
24
- "type": "inject",
25
- "z": "b92be5062203ff69",
26
- "g": "b84864b2ff870a45",
27
- "name": "Trigger",
28
- "props": [],
29
- "repeat": "",
30
- "crontab": "",
31
- "once": false,
32
- "onceDelay": 0.1,
33
- "topic": "",
34
- "x": 2114.142822265625,
35
- "y": 776.7142333984375,
36
- "wires": [
37
- [
38
- "aeb3094ecf54b2b2"
39
- ]
40
- ]
19
+ "x": 504,
20
+ "y": 489.2857666015625,
21
+ "w": 1037.857177734375,
22
+ "h": 363.7142333984375
41
23
  },
42
24
  {
43
25
  "id": "ea7b1b985ba6ac70",
44
26
  "type": "NodeFactory",
45
- "z": "b92be5062203ff69",
27
+ "z": "eef4037a6d25a1e0",
46
28
  "g": "b84864b2ff870a45",
47
29
  "name": "",
48
30
  "nodename": "",
@@ -55,41 +37,16 @@
55
37
  "summary": "",
56
38
  "description": "",
57
39
  "icon": "font-awesome/fa-industry",
58
- "x": 2788,
59
- "y": 948,
40
+ "x": 1445.857177734375,
41
+ "y": 532.2857666015625,
60
42
  "wires": [
61
43
  []
62
44
  ]
63
45
  },
64
- {
65
- "id": "aeb3094ecf54b2b2",
66
- "type": "http request",
67
- "z": "b92be5062203ff69",
68
- "g": "b84864b2ff870a45",
69
- "name": "http request to npmjs",
70
- "method": "GET",
71
- "ret": "bin",
72
- "paytoqs": "ignore",
73
- "url": "https://registry.npmjs.org/@gregoriusrippenstein/node-red-contrib-introspection/-/node-red-contrib-introspection-0.4.3.tgz",
74
- "tls": "",
75
- "persist": false,
76
- "proxy": "",
77
- "insecureHTTPParser": false,
78
- "authType": "",
79
- "senderr": false,
80
- "headers": [],
81
- "x": 2394,
82
- "y": 865,
83
- "wires": [
84
- [
85
- "ea7b1b985ba6ac70"
86
- ]
87
- ]
88
- },
89
46
  {
90
47
  "id": "24b26f5122abf1bb",
91
48
  "type": "file in",
92
- "z": "b92be5062203ff69",
49
+ "z": "eef4037a6d25a1e0",
93
50
  "g": "b84864b2ff870a45",
94
51
  "name": "",
95
52
  "filename": "/some/path/to/local/package.tgz",
@@ -99,8 +56,8 @@
99
56
  "sendError": false,
100
57
  "encoding": "none",
101
58
  "allProps": false,
102
- "x": 2443,
103
- "y": 1006,
59
+ "x": 1100.857177734375,
60
+ "y": 590.2857666015625,
104
61
  "wires": [
105
62
  [
106
63
  "ea7b1b985ba6ac70"
@@ -110,7 +67,7 @@
110
67
  {
111
68
  "id": "ab37a3f877541c5b",
112
69
  "type": "inject",
113
- "z": "b92be5062203ff69",
70
+ "z": "eef4037a6d25a1e0",
114
71
  "g": "b84864b2ff870a45",
115
72
  "name": "Trigger",
116
73
  "props": [],
@@ -119,12 +76,122 @@
119
76
  "once": false,
120
77
  "onceDelay": 0.1,
121
78
  "topic": "",
122
- "x": 2123,
123
- "y": 946,
79
+ "x": 780.857177734375,
80
+ "y": 530.2857666015625,
124
81
  "wires": [
125
82
  [
126
83
  "24b26f5122abf1bb"
127
84
  ]
128
85
  ]
86
+ },
87
+ {
88
+ "id": "11289b70b58c767b",
89
+ "type": "inject",
90
+ "z": "eef4037a6d25a1e0",
91
+ "g": "b84864b2ff870a45",
92
+ "name": "inject package details",
93
+ "props": [
94
+ {
95
+ "p": "packagename",
96
+ "v": "@gregoriusrippenstein/node-red-contrib-introspection",
97
+ "vt": "str"
98
+ },
99
+ {
100
+ "p": "packageversion",
101
+ "v": "0.4.3",
102
+ "vt": "str"
103
+ }
104
+ ],
105
+ "repeat": "",
106
+ "crontab": "",
107
+ "once": false,
108
+ "onceDelay": 0.1,
109
+ "topic": "",
110
+ "x": 650,
111
+ "y": 647,
112
+ "wires": [
113
+ [
114
+ "96278268709caba6"
115
+ ]
116
+ ]
117
+ },
118
+ {
119
+ "id": "96278268709caba6",
120
+ "type": "function",
121
+ "z": "eef4037a6d25a1e0",
122
+ "g": "b84864b2ff870a45",
123
+ "name": "retrieve tgz URL for package",
124
+ "func": "pacote.manifest(\n msg.packagename + \"@\" + msg.packageversion\n).then(manifest => {\n msg.payload = manifest._resolved\n node.send(msg)\n}).catch( err => {\n msg.error = err\n node.error(\"failed to get url\", msg)\n})\n\n\n",
125
+ "outputs": 1,
126
+ "timeout": 0,
127
+ "noerr": 0,
128
+ "initialize": "",
129
+ "finalize": "",
130
+ "libs": [
131
+ {
132
+ "var": "pacote",
133
+ "module": "pacote"
134
+ }
135
+ ],
136
+ "x": 822,
137
+ "y": 812,
138
+ "wires": [
139
+ [
140
+ "fc620efcbaf77846"
141
+ ]
142
+ ]
143
+ },
144
+ {
145
+ "id": "fc620efcbaf77846",
146
+ "type": "change",
147
+ "z": "eef4037a6d25a1e0",
148
+ "g": "b84864b2ff870a45",
149
+ "name": "",
150
+ "rules": [
151
+ {
152
+ "t": "set",
153
+ "p": "url",
154
+ "pt": "msg",
155
+ "to": "payload",
156
+ "tot": "msg"
157
+ }
158
+ ],
159
+ "action": "",
160
+ "property": "",
161
+ "from": "",
162
+ "to": "",
163
+ "reg": false,
164
+ "x": 1128,
165
+ "y": 770,
166
+ "wires": [
167
+ [
168
+ "d981181116ccfb16"
169
+ ]
170
+ ]
171
+ },
172
+ {
173
+ "id": "d981181116ccfb16",
174
+ "type": "http request",
175
+ "z": "eef4037a6d25a1e0",
176
+ "g": "b84864b2ff870a45",
177
+ "name": "",
178
+ "method": "GET",
179
+ "ret": "bin",
180
+ "paytoqs": "ignore",
181
+ "url": "",
182
+ "tls": "",
183
+ "persist": false,
184
+ "proxy": "",
185
+ "insecureHTTPParser": false,
186
+ "authType": "",
187
+ "senderr": false,
188
+ "headers": [],
189
+ "x": 1316,
190
+ "y": 689,
191
+ "wires": [
192
+ [
193
+ "ea7b1b985ba6ac70"
194
+ ]
195
+ ]
129
196
  }
130
197
  ]
@@ -4,13 +4,6 @@
4
4
  <div style="display: inline-block; width: calc(100% - 105px)"><input type="text" id="node-input-name" placeholder="Name"></div>
5
5
  </div>
6
6
 
7
- <div class="form-row">
8
- <label for="node-input-autoimport">
9
- <span>Auto Import of Nodes?</span>
10
- </label>
11
- <input type="checkbox" id="node-input-autoimport" style="display:inline-block; width:15px; vertical-align:baseline;">
12
- </div>
13
-
14
7
  <div class="form-row">
15
8
  <label for="node-input-nodename"><i class="fa fa-tag"></i> Node Name</label>
16
9
  <div style="display: inline-block; width: calc(100% - 105px)"><input type="text" id="node-input-nodename" placeholder="Node Name">
@@ -69,6 +62,12 @@
69
62
  </div>
70
63
  </div>
71
64
 
65
+
66
+ <div class="form-row">
67
+ <button id="node-input-generate-tmplnodes-but"
68
+ class="red-ui-button">Generate Template Nodes</button>
69
+ </div>
70
+
72
71
  </script>
73
72
 
74
73
  <script type="text/javascript">
@@ -76,25 +75,37 @@
76
75
 
77
76
  RED.comms.subscribe("nodedev:perform-autoimport-nodes", (event,data) => {
78
77
  if ( data.msg == "autoimport" ) {
79
- RED.clipboard.import();
80
-
81
78
  setTimeout(() => {
82
- $('#red-ui-clipboard-dialog-import-text').val(
83
- data.payload
84
- ).trigger("paste");
85
- }, 300);
79
+ RED.clipboard.import();
80
+
81
+ setTimeout(() => {
82
+ $('#red-ui-clipboard-dialog-import-text').val(
83
+ data.payload
84
+ ).trigger("paste");
85
+ }, 300);
86
+ },400)
86
87
  }
87
88
  });
88
89
 
89
90
  function doSubmission(node) {
90
91
 
91
92
  var data = {};
92
- Object.keys(node._def.defaults).forEach( (nam) => {
93
- data[nam] = node[nam]
94
- })
95
- data["name"] = node.nodename;
96
- data["__task"] = "generate_from_templates";
97
-
93
+
94
+ /* the data has not been stored on the node when this is called,
95
+ need to retrieve everything from the various fields...
96
+ */
97
+ data["summary"] = node.editorSummary.getValue();
98
+ data["description"] = node.editorDesc.getValue();
99
+ data["hasbutton"] = $('#node-input-hasbutton').is(":checked");
100
+ data["hasinput"] = $('#node-input-hasinput').is(":checked");
101
+ data["color"] = $('#node-input-colour').val();
102
+ data["icon"] = $('#red-ui-editor-node-icon').val();
103
+ data["name"] = $('#node-input-nodename').val();
104
+ data["outputcount"] = $('#node-input-outputcount').val();
105
+ data["category"] = $('#node-input-category').val();
106
+
107
+ data["__task"] = "generate_from_templates";
108
+
98
109
  $.ajax({
99
110
  url: "NodeFactory/" + node.id,
100
111
  type: "POST",
@@ -105,22 +116,19 @@
105
116
  }),
106
117
 
107
118
  success: function (resp) {
119
+ $('#node-dialog-ok').trigger('click');
120
+
108
121
  RED.notify("Data sent", {
109
122
  type: "warning",
110
- id: "FlowHubPush",
111
123
  timeout: 2000
112
124
  });
113
125
  },
114
126
 
115
127
  error: function (jqXHR, textStatus, errorThrown) {
116
128
  if (jqXHR.status == 404) {
117
- RED.notify(node._("common.notification.error", {
118
- message: node._("common.notification.errors.not-deployed")
119
- }), "error");
129
+ RED.notify("Node has not yet been deployed, please deploy.", "error");
120
130
  } else if (jqXHR.status == 405) {
121
- RED.notify(node._("common.notification.not_allowed", {
122
- message: node._("inject.errors.not_allowed")
123
- }), "error");
131
+ RED.notify("Not Allowed.", "error");
124
132
  } else if (jqXHR.status == 500) {
125
133
  RED.notify(node._("common.notification.error", {
126
134
  message: node._("inject.errors.failed")
@@ -150,7 +158,6 @@
150
158
  hasbutton: { value: false },
151
159
  hasinput: { value: true },
152
160
  outputcount: { value: 1 },
153
- autoimport: { value: true },
154
161
  category: { value: "" },
155
162
  summary: { value: ""},
156
163
  description: { value: ""},
@@ -178,6 +185,11 @@
178
185
 
179
186
  sltObj.val(this.outputcount || "1");
180
187
 
188
+ $('#node-input-generate-tmplnodes-but').on('click', (e) => {
189
+ e.preventDefault()
190
+ doSubmission(that)
191
+ });
192
+
181
193
  var colorPalette = [
182
194
  "#DDAA99",
183
195
  "#3FADB5", "#87A980", "#A6BBCF",
@@ -290,22 +302,7 @@
290
302
 
291
303
  oneditresize: function (size) {
292
304
  },
293
-
294
- button: {
295
- enabled: function () {
296
- return !this.changed
297
- },
298
-
299
- onclick: function () {
300
- if (this.changed) {
301
- return RED.notify(RED._("notification.warning", {
302
- message: RED._("notification.warnings.undeployedChanges")
303
- }), "warning");
304
- }
305
-
306
- doSubmission(this)
307
- }
308
- },
309
305
  });
310
306
  })();
307
+
311
308
  </script>
@@ -213,18 +213,16 @@ module.exports = function (RED) {
213
213
 
214
214
  send({ payload: nodeImpStr })
215
215
 
216
- if (cfg.autoimport) {
217
- RED.comms.publish(
218
- "nodedev:perform-autoimport-nodes",
219
- RED.util.encodeObject({
220
- msg: "autoimport",
221
- payload: nodeImpStr,
222
- topic: msg.topic,
223
- nodeid: node.id,
224
- _msg: msg
225
- })
226
- );
227
- }
216
+ RED.comms.publish(
217
+ "nodedev:perform-autoimport-nodes",
218
+ RED.util.encodeObject({
219
+ msg: "autoimport",
220
+ payload: nodeImpStr,
221
+ topic: msg.topic,
222
+ nodeid: node.id,
223
+ _msg: msg
224
+ })
225
+ );
228
226
 
229
227
  done()
230
228
  }).catch((err) => {
@@ -267,6 +265,7 @@ module.exports = function (RED) {
267
265
  "jpeg": "base64",
268
266
  "bin": "base64",
269
267
  "bmp": "base64",
268
+ "gif": "base64",
270
269
  }[ext.toLowerCase()] || "text";
271
270
  };
272
271
 
@@ -315,18 +314,16 @@ module.exports = function (RED) {
315
314
  msg.payload = JSON.stringify(allFiles);
316
315
  send(msg)
317
316
 
318
- if (cfg.autoimport) {
319
- RED.comms.publish(
320
- "nodedev:perform-autoimport-nodes",
321
- RED.util.encodeObject({
322
- msg: "autoimport",
323
- payload: msg.payload,
324
- topic: msg.topic,
325
- nodeid: node.id,
326
- _msg: msg
327
- })
328
- );
329
- }
317
+ RED.comms.publish(
318
+ "nodedev:perform-autoimport-nodes",
319
+ RED.util.encodeObject({
320
+ msg: "autoimport",
321
+ payload: msg.payload,
322
+ topic: msg.topic,
323
+ nodeid: node.id,
324
+ _msg: msg
325
+ })
326
+ );
330
327
 
331
328
  done()
332
329
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name" : "@gregoriusrippenstein/node-red-contrib-nodedev",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "dependencies": {
5
5
  "pako": "latest",
6
6
  "tar-stream": "latest",