|
21 | 21 | return ret; |
22 | 22 | } |
23 | 23 |
|
24 | | - function getName(nodeName){ |
25 | | - var ret; |
26 | | - switch (nodeName){ |
27 | | - case 'property in': |
28 | | - case 'property out': |
29 | | - ret='property'; |
30 | | - break; |
31 | | - case 'property in hist': |
32 | | - ret='historic'; |
33 | | - break; |
34 | | - case 'property in poll': |
35 | | - ret ='periodic'; |
36 | | - break; |
37 | | - case 'property in push': |
38 | | - ret = 'inject'; |
39 | | - break; |
40 | | - |
41 | | - } |
42 | | - return ret; |
43 | | - } |
44 | | - |
45 | | - function setupNode(nodeName, ins, outs) { |
| 24 | + function setupNode(nodeName, labelName, ins, outs) { |
46 | 25 | var defaults = getDefaults(nodeName); |
47 | | - var name = getName(nodeName); |
48 | 26 | RED.nodes.registerType(nodeName, { |
49 | 27 | category: 'Arduino IoT Cloud', |
50 | 28 | color: '#00979d', |
|
53 | 31 | outputs: outs, |
54 | 32 | icon: "arduino.png", |
55 | 33 | label: function () { |
56 | | - return this.name || name; |
| 34 | + return this.name || labelName; |
57 | 35 | }, |
58 | | - paletteLabel: name, |
| 36 | + paletteLabel: labelName, |
59 | 37 | oneditprepare: function () { |
60 | 38 | if (this.connection && this.connection !== "_ADD_") { |
61 | 39 | initThings(this.connection, this.thing); |
|
108 | 86 | } |
109 | 87 | }); |
110 | 88 | }, |
111 | | - oneditsave: function () { |
112 | | - console.log("thing_id: " + this.thing); |
113 | | - console.log("property_id: " + this.property); |
114 | | - } |
115 | 89 | }); |
116 | 90 | } |
117 | 91 |
|
118 | | - setupNode("property in", 0, 1); |
119 | | - setupNode("property out", 1, 0); |
120 | | - setupNode("property in hist", 1, 1);//historic |
121 | | - setupNode("property in poll", 0, 1);//periodic |
122 | | - setupNode("property in push", 1, 1);//inject |
| 92 | + setupNode("property in", "property", 0, 1); |
| 93 | + setupNode("property out", "property", 1, 0); |
| 94 | + setupNode("property in hist", "historic", 1, 1); |
| 95 | + setupNode("property in poll", "periodic", 0, 1); |
| 96 | + setupNode("property in push", "inject", 1, 1); |
123 | 97 | </script> |
124 | 98 |
|
125 | 99 |
|
|
0 commit comments