Skip to content

Commit 25f4a01

Browse files
committed
Merge branch '0.18' into projects
2 parents 1204cf1 + fd4fdb3 commit 25f4a01

146 files changed

Lines changed: 6557 additions & 1471 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ISSUE_TEMPLATE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Before you hit that Submit button....
2+
3+
This issue tracker is for problems with the Node-RED runtime, the editor or the core nodes.
4+
5+
If your issue is:
6+
- a general 'how-to' type question,
7+
- a feature request or suggestion for a change,
8+
- or problems with 3rd party (`node-red-contrib-`) nodes
9+
10+
please use the [mailing list](https://groups.google.com/forum/#!forum/node-red), [slack team](https://nodered.org/slack) or ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/node-red) and tag it `node-red`.
11+
12+
That way the whole Node-RED user community can help, rather than rely on the core development team.
13+
14+
## So you have a real issue to raise...
15+
16+
To help us understand the issue, please fill-in as much of the following information as you can:
17+
18+
### What are the steps to reproduce?
19+
20+
### What happens?
21+
22+
### What do you expect to happen?
23+
24+
### Please tell us about your environment:
25+
26+
- [ ] Node-RED version:
27+
- [ ] node.js version:
28+
- [ ] npm version:
29+
- [ ] Platform/OS:
30+
- [ ] Browser:

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Before you hit that Submit button....
2+
3+
Please read our [contribution guidelines](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md)
4+
before submitting a pull-request.
5+
6+
## Types of changes
7+
8+
What types of changes does your code introduce?
9+
_Put an `x` in the boxes that apply_
10+
11+
- [ ] Bugfix (non-breaking change which fixes an issue)
12+
- [ ] New feature (non-breaking change which adds functionality)
13+
14+
If you want to raise a pull-request with a new feature, or a refactoring
15+
of existing code, it **may well get rejected** if it hasn't been discussed on
16+
the [mailing list](https://groups.google.com/forum/#!forum/node-red) or
17+
[slack team](https://nodered.org/slack) first.
18+
19+
20+
## Proposed changes
21+
22+
Describe the nature of this change. What problem does it address?
23+
24+
## Checklist
25+
_Put an `x` in the boxes that apply_
26+
27+
- [ ] I have read the [contribution guidelines](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md)
28+
- [ ] For non-bugfix PRs, I have discussed this change on the mailing list/slack team.
29+
- [ ] I have run `grunt` to verify the unit tests pass
30+
- [ ] I have added suitable unit tests to cover the new/changed functionality

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ addons:
1111
- gcc-4.8
1212
node_js:
1313
- "8"
14-
- "7"
1514
- "6"
1615
- "4"
1716
script:

Gruntfile.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ module.exports = function(grunt) {
4141
core: { src: ["test/_spec.js","test/red/**/*_spec.js"]},
4242
nodes: { src: ["test/nodes/**/*_spec.js"]}
4343
},
44+
webdriver: {
45+
all: {
46+
configFile: 'test/editor/wdio.conf.js'
47+
}
48+
},
4449
mocha_istanbul: {
4550
options: {
4651
globals: ['expect'],
@@ -419,6 +424,7 @@ module.exports = function(grunt) {
419424
grunt.loadNpmTasks('grunt-chmod');
420425
grunt.loadNpmTasks('grunt-jsonlint');
421426
grunt.loadNpmTasks('grunt-mocha-istanbul');
427+
grunt.loadNpmTasks('grunt-webdriver');
422428

423429
grunt.registerMultiTask('attachCopyright', function() {
424430
var files = this.data.src;
@@ -478,6 +484,10 @@ module.exports = function(grunt) {
478484
'Runs code style check on editor code',
479485
['jshint:editor']);
480486

487+
grunt.registerTask('test-ui',
488+
'Builds editor content then runs unit tests on editor ui',
489+
['build','jshint:editor','webdriver:all']);
490+
481491
grunt.registerTask('test-nodes',
482492
'Runs unit tests on core nodes',
483493
['build','mocha_istanbul:nodes']);

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A visual tool for wiring the Internet of Things.
1414
Check out http://nodered.org/docs/getting-started/ for full instructions on getting
1515
started.
1616

17-
1. `sudo npm install -g node-red`
17+
1. `sudo npm install -g --unsafe-perm node-red`
1818
2. `node-red`
1919
3. Open <http://localhost:1880>
2020

editor/icons/sort.png

793 Bytes
Loading

editor/js/comms.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,31 @@ RED.comms = (function() {
6464
}
6565
}
6666
ws.onmessage = function(event) {
67-
var msg = JSON.parse(event.data);
68-
if (pendingAuth && msg.auth) {
69-
if (msg.auth === "ok") {
70-
pendingAuth = false;
71-
completeConnection();
72-
} else if (msg.auth === "fail") {
73-
// anything else is an error...
74-
active = false;
75-
RED.user.login({updateMenu:true},function() {
76-
connectWS();
77-
})
67+
var message = JSON.parse(event.data);
68+
for (var m = 0; m < message.length; m++) {
69+
var msg = message[m];
70+
if (pendingAuth && msg.auth) {
71+
if (msg.auth === "ok") {
72+
pendingAuth = false;
73+
completeConnection();
74+
} else if (msg.auth === "fail") {
75+
// anything else is an error...
76+
active = false;
77+
RED.user.login({updateMenu:true},function() {
78+
connectWS();
79+
})
80+
}
7881
}
79-
} else if (msg.topic) {
80-
for (var t in subscriptions) {
81-
if (subscriptions.hasOwnProperty(t)) {
82-
var re = new RegExp("^"+t.replace(/([\[\]\?\(\)\\\\$\^\*\.|])/g,"\\$1").replace(/\+/g,"[^/]+").replace(/\/#$/,"(\/.*)?")+"$");
83-
if (re.test(msg.topic)) {
84-
var subscribers = subscriptions[t];
85-
if (subscribers) {
86-
for (var i=0;i<subscribers.length;i++) {
87-
subscribers[i](msg.topic,msg.data);
82+
else if (msg.topic) {
83+
for (var t in subscriptions) {
84+
if (subscriptions.hasOwnProperty(t)) {
85+
var re = new RegExp("^"+t.replace(/([\[\]\?\(\)\\\\$\^\*\.|])/g,"\\$1").replace(/\+/g,"[^/]+").replace(/\/#$/,"(\/.*)?")+"$");
86+
if (re.test(msg.topic)) {
87+
var subscribers = subscriptions[t];
88+
if (subscribers) {
89+
for (var i=0;i<subscribers.length;i++) {
90+
subscribers[i](msg.topic,msg.data);
91+
}
8892
}
8993
}
9094
}

editor/js/main.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,25 @@
2424
url: 'nodes',
2525
success: function(data) {
2626
RED.nodes.setNodeList(data);
27-
RED.i18n.loadNodeCatalogs(loadNodes);
27+
RED.i18n.loadNodeCatalogs(function() {
28+
loadIconList(loadNodes);
29+
});
30+
}
31+
});
32+
}
33+
34+
function loadIconList(done) {
35+
$.ajax({
36+
headers: {
37+
"Accept":"application/json"
38+
},
39+
cache: false,
40+
url: 'icons',
41+
success: function(data) {
42+
RED.nodes.setIconSets(data);
43+
if (done) {
44+
done();
45+
}
2846
}
2947
});
3048
}
@@ -95,6 +113,7 @@
95113
});
96114
return;
97115
}
116+
98117
if (msg.text) {
99118
var text = RED._(msg.text,{default:msg.text});
100119
var options = {
@@ -192,6 +211,7 @@
192211
typeList = "<ul><li>"+addedTypes.join("</li><li>")+"</li></ul>";
193212
RED.notify(RED._("palette.event.nodeAdded", {count:addedTypes.length})+typeList,"success");
194213
}
214+
loadIconList();
195215
} else if (topic == "notification/node/removed") {
196216
for (i=0;i<msg.length;i++) {
197217
m = msg[i];
@@ -201,6 +221,7 @@
201221
RED.notify(RED._("palette.event.nodeRemoved", {count:m.types.length})+typeList,"success");
202222
}
203223
}
224+
loadIconList();
204225
} else if (topic == "notification/node/enabled") {
205226
if (msg.types) {
206227
info = RED.nodes.getNodeSet(msg.id);

editor/js/nodes.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ RED.nodes = (function() {
4040
var nodeSets = {};
4141
var typeToId = {};
4242
var nodeDefinitions = {};
43+
var iconSets = {};
4344

4445
nodeDefinitions['tab'] = {
4546
defaults: {
@@ -170,6 +171,12 @@ RED.nodes = (function() {
170171
},
171172
getNodeType: function(nt) {
172173
return nodeDefinitions[nt];
174+
},
175+
setIconSets: function(sets) {
176+
iconSets = sets;
177+
},
178+
getIconSets: function() {
179+
return iconSets;
173180
}
174181
};
175182
return exports;
@@ -485,6 +492,12 @@ RED.nodes = (function() {
485492
if (n.outputs > 0 && n.outputLabels && !/^\s*$/.test(n.outputLabels.join(""))) {
486493
node.outputLabels = n.outputLabels.slice();
487494
}
495+
if (!n._def.defaults.hasOwnProperty("icon") && n.icon) {
496+
var defIcon = RED.utils.getDefaultNodeIcon(n._def, n);
497+
if (n.icon !== defIcon.module+"/"+defIcon.file) {
498+
node.icon = n.icon;
499+
}
500+
}
488501
}
489502
return node;
490503
}
@@ -915,6 +928,7 @@ RED.nodes = (function() {
915928
wires:n.wires,
916929
inputLabels: n.inputLabels,
917930
outputLabels: n.outputLabels,
931+
icon: n.icon,
918932
changed:false,
919933
_config:{}
920934
};
@@ -1273,6 +1287,9 @@ RED.nodes = (function() {
12731287
enableNodeSet: registry.enableNodeSet,
12741288
disableNodeSet: registry.disableNodeSet,
12751289

1290+
setIconSets: registry.setIconSets,
1291+
getIconSets: registry.getIconSets,
1292+
12761293
registerType: registry.registerNodeType,
12771294
getType: registry.getNodeType,
12781295
convertNode: convertNode,

editor/js/ui/common/typedInput.js

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
this.uiSelect = this.elementDiv.wrap( "<div>" ).parent();
100100
var attrStyle = this.element.attr('style');
101101
var m;
102-
if ((m = /width\s*:\s*(\d+(%|px))/i.exec(attrStyle)) !== null) {
102+
if ((m = /width\s*:\s*(calc\s*\(.*\)|\d+(%|px))/i.exec(attrStyle)) !== null) {
103103
this.element.css('width','100%');
104104
this.uiSelect.width(m[1]);
105105
this.uiWidth = null;
@@ -354,10 +354,27 @@
354354
return this.element.val();
355355
} else {
356356
if (this.typeMap[this.propertyType].options) {
357-
if (this.typeMap[this.propertyType].options.indexOf(value) === -1) {
357+
var validValue = false;
358+
var label;
359+
for (var i=0;i<this.typeMap[this.propertyType].options.length;i++) {
360+
var op = this.typeMap[this.propertyType].options[i];
361+
if (typeof op === "string") {
362+
if (op === value) {
363+
label = value;
364+
validValue = true;
365+
break;
366+
}
367+
} else if (op.value === value) {
368+
label = op.label||op.value;
369+
validValue = true;
370+
break;
371+
}
372+
}
373+
if (!validValue) {
358374
value = "";
375+
label = "";
359376
}
360-
this.optionSelectLabel.text(value);
377+
this.optionSelectLabel.text(label);
361378
}
362379
this.element.val(value);
363380
this.element.trigger('change',this.type(),value);
@@ -394,11 +411,31 @@
394411
that.value(v);
395412
});
396413
var currentVal = this.element.val();
397-
if (opt.options.indexOf(currentVal) !== -1) {
398-
this.optionSelectLabel.text(currentVal);
399-
} else {
400-
this.value(opt.options[0]);
414+
var validValue = false;
415+
var op;
416+
for (var i=0;i<opt.options.length;i++) {
417+
op = opt.options[i];
418+
if (typeof op === "string") {
419+
if (op === currentVal) {
420+
this.optionSelectLabel.text(currentVal);
421+
validValue = true;
422+
break;
423+
}
424+
} else if (op.value === currentVal) {
425+
this.optionSelectLabel.text(op.label||op.value);
426+
validValue = true;
427+
break;
428+
}
429+
}
430+
if (!validValue) {
431+
op = opt.options[0];
432+
if (typeof op === "string") {
433+
this.value(op);
434+
} else {
435+
this.value(op.value);
436+
}
401437
}
438+
console.log(validValue);
402439
}
403440
} else {
404441
if (this.optionMenu) {

0 commit comments

Comments
 (0)