@gregoriusrippenstein/node-red-contrib-nodedev 0.2.6 → 0.2.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.
@@ -235,9 +235,9 @@
235
235
  <div id="noderedinstall-options">
236
236
  <div class="form-row">
237
237
  <label for="node-input-randompackagename" style="min-width: 180px;">
238
- <span>Randomise Package Name?</span>
238
+ <span>Randomise Package Version?</span>
239
239
  </label>
240
- <input type="checkbox" id="node-input-randompackagename" style="display:inline-block; width:15px; vertical-align:baseline;">
240
+ <input type="checkbox" id="node-input-randompackagename" style="margin-left: 10px; display:inline-block; width:15px; vertical-align:baseline;">
241
241
  </div>
242
242
  </div>
243
243
 
@@ -13,7 +13,11 @@ module.exports = function (RED) {
13
13
  msg.commit_message = msg.githubmessage;
14
14
 
15
15
  if (msg.randompackagename) {
16
- msg.pname += Math.random().toString().substring(2)
16
+ msg.pversion = (
17
+ Math.random().toString().substring(2).substring(2, 3) + "." +
18
+ Math.random().toString().substring(2).substring(2, 3) + "." +
19
+ Math.random().toString().substring(2).substring(2, 5).replace(/^0/, '1')
20
+ )
17
21
  }
18
22
 
19
23
  if (msg.randompackagename && (msg.gitcommit || msg.npmpublish || msg.npmunpublish) ) {
@@ -28,6 +28,11 @@
28
28
  <span>Has button?</span>
29
29
  </label>
30
30
  <input type="checkbox" id="node-input-hasbutton" style="display:inline-block; width:15px; vertical-align:baseline;">
31
+
32
+ <label for="node-input-minify">
33
+ <span>Minify by default?</span>
34
+ </label>
35
+ <input type="checkbox" id="node-input-minify" style="margin-left: 10px; display:inline-block; width:15px; vertical-align:baseline;">
31
36
  </div>
32
37
 
33
38
  <div class="form-row">
@@ -146,6 +151,7 @@
146
151
  data["category"] = $('#node-input-category').val();
147
152
 
148
153
  data["hasbutton"] = $('#node-input-hasbutton').is(":checked");
154
+ data["minify"] = $('#node-input-minify').is(":checked");
149
155
  data["hasinput"] = $('#node-input-hasinput').is(":checked");
150
156
  data["bak2frtcomm"] = $('#node-input-bak2frtcomm').is(":checked");
151
157
  data["frt2bakcomm"] = $('#node-input-frt2bakcomm').is(":checked");
@@ -204,6 +210,7 @@
204
210
  nodename: { value: "", required: true },
205
211
  color: { value: "#e5e4ef" },
206
212
  hasbutton: { value: false },
213
+ minify: { value: false },
207
214
  hasinput: { value: true },
208
215
  outputcount: { value: 1 },
209
216
  category: { value: "" },
@@ -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: [[secondId]]
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: 100,
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: 150,
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: 200,
315
+ y: 250,
296
316
  wires: [[]]
297
317
  }
298
318
  ]
@@ -1,5 +1,5 @@
1
1
  {
2
- "{{ node.name }}": {
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
- "hello": "world"
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,140 +1,5 @@
1
1
  <script type="text/javascript">
2
- (function(){
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
- },
64
-
65
- {{#node.hasinput}}
66
- inputs: 1,
67
- {{/node.hasinput}}
68
- {{^node.hasinput}}
69
- inputs: 0,
70
- {{/node.hasinput}}
71
-
72
- outputs: {{ node.outputcount }},
73
-
74
- label: function() {
75
- return (this.name || this._def.paletteLabel);
76
- },
77
-
78
- labelStyle: function() {
79
- return this.name?"node_label_italic":"";
80
- },
81
-
82
- onpaletteadd: function() {
83
- {{#node.bak2frtcomm}}
84
- this.messageFromBackendHandler = (topic,dataobj) => {
85
- console.log( "here goes the code for handling a message from the backend", topic, dataobj);
86
-
87
- RED.notify(RED._("{{ node.name}}.label.commfrombackend"), {
88
- type: "success",
89
- id: "{{node.name}}",
90
- timeout: 2000
91
- });
92
- };
93
- RED.comms.subscribe('{{node.name}}:message-from-backend',this.messageFromBackendHandler);
94
- {{/node.bak2frtcomm}}
95
- },
96
-
97
- oneditprepare: function() {
98
- },
99
-
100
- oneditcancel: function() {
101
- },
102
-
103
- oneditsave: function() {
104
- },
105
-
106
- onpaletteremove: function() {
107
- {{#node.bak2frtcomm}}
108
- RED.comms.unsubscribe('{{node.name}}:message-from-backend',this.messageFromBackendHandler);
109
- {{/node.bak2frtcomm}}
110
- },
111
-
112
-
113
- {{#node.hasbutton}}
114
- button: {
115
- enabled: function() {
116
- return !this.changed
117
- },
118
-
119
- onclick: function () {
120
- if (this.changed) {
121
- return RED.notify(RED._("notification.warning", {
122
- message: RED._("notification.warnings.undeployedChanges")
123
- }), "warning");
124
- }
125
-
126
- {{ #node.frt2bakcomm }}
127
- var that = this;
128
- sendToBackend(that, {"payload": RED._("{{ node.name}}.label.buttonpressed")})
129
- {{ /node.frt2bakcomm }}
130
-
131
- /* here goes the button code to be executed on click */
132
- }
133
- },
134
- {{/node.hasbutton}}
135
-
136
- });
137
- })();
2
+ {{ __.ocb3 }} {{ node.name }}TmplJs {{ __.ccb3 }}
138
3
  </script>
139
4
 
140
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
+ })();
@@ -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.name}}.label.msgfrombackend"),
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: "status set" });
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.name }}.label.submissionfailed") + ": " + err.toString(), { error: err })
69
+ node.error("{{ node.name }}: " + RED._("{{ node.namelwr }}.label.submissionfailed") + ": " + err.toString(), { error: err })
70
70
  }
71
71
  } else {
72
72
  res.sendStatus(404);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name" : "@gregoriusrippenstein/node-red-contrib-nodedev",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "dependencies": {
5
5
  "pako": "^2.1.0",
6
6
  "tar-stream": "^3.1.6",