|
103 | 103 | </div>
|
104 | 104 |
|
105 | 105 | <div class="form-row">
|
106 |
| - <label for="node-input-db"><i class="fa fa-briefcase"></i> Database</label> |
107 |
| - <input type="text" id="node-input-db" placeholder="database"> |
| 106 | + <label for="node-input-database"><i class="fa fa-briefcase"></i> Database</label> |
| 107 | + <input type="text" id="node-input-database" placeholder="database"> |
108 | 108 | </div>
|
109 | 109 |
|
110 | 110 | </div>
|
|
166 | 166 | function oneditprepare() {
|
167 | 167 | var select = $('#node-input-service');
|
168 | 168 | var node = this;
|
169 |
| - $.getJSON('cloudantnode/vcap/',function(data) { |
| 169 | + |
| 170 | + $.getJSON('cloudant/vcap/',function(data) { |
170 | 171 | var last = select.children().last();
|
171 | 172 | var opts = [];
|
172 |
| - for (var i =0;i<data.length;i++) { |
173 |
| - opts.push('<option value="'+data[i].name+'"'+(node.service==data[i].name?" selected":"")+'>'+data[i].name+'</option>'); |
| 173 | + |
| 174 | + for (var i=0; i < data.length; i++) { |
| 175 | + var selected = node.service == data[i].name; |
| 176 | + opts.push( |
| 177 | + '<option value="' + data[i].name + '"' + (selected ? " selected":"") + '>' + |
| 178 | + data[i].name + |
| 179 | + '</option>' |
| 180 | + ); |
174 | 181 | }
|
| 182 | + |
175 | 183 | if (opts.length == 0) {
|
176 | 184 | node.service = "_ext_";
|
177 |
| - select.find("option").filter(function() {return $(this).val() == node.service;}).attr('selected',true); |
| 185 | + select.find("option").filter(function() { |
| 186 | + return $(this).val() == node.service; |
| 187 | + }).attr('selected', true); |
178 | 188 | } else {
|
179 | 189 | last.before(opts.join(""));
|
180 | 190 | }
|
| 191 | + |
181 | 192 | select.change();
|
182 | 193 | });
|
| 194 | + |
183 | 195 | select.change(function() {
|
184 | 196 | var service = select.val();
|
185 | 197 | if (service == "_ext_") {
|
|
191 | 203 | }
|
192 | 204 |
|
193 | 205 | function label() {
|
194 |
| - var cloudantNode = RED.nodes.node(this.cloudant); |
195 |
| - if (this.name) { |
196 |
| - return this.name; |
197 |
| - } |
198 |
| - if (this.service == "_ext_") { |
199 |
| - return (cloudantNode?cloudantNode.label()+" "+this.collection:"cloudant"); |
200 |
| - } |
201 |
| - return this.service||"cloudant"; |
| 206 | + return this.name || this.database || "cloudant"; |
202 | 207 | }
|
203 | 208 |
|
204 | 209 | function validateServer(v) {
|
205 |
| - return this.service != "_ext_" || v!="_ADD_"; |
| 210 | + return this.service != "_ext_" || v != "_ADD_"; |
206 | 211 | }
|
207 | 212 |
|
208 | 213 | RED.nodes.registerType("cloudant out", {
|
209 | 214 | category: "storage-output",
|
210 | 215 | color: "rgb(114, 199, 231)",
|
211 | 216 | defaults: {
|
212 | 217 | service: { value: "", required: true },
|
213 |
| - cloudant: { type:"cloudant",validate:validateServer}, //validate server |
| 218 | + cloudant: { type: "cloudant", validate: validateServer}, |
214 | 219 | name: { value: "" },
|
215 |
| - db: { value: "", required: true }, |
| 220 | + database: { value: "", required: true }, |
216 | 221 | payonly: { value: false },
|
217 | 222 | operation: { value: "insert" }
|
218 | 223 | },
|
219 | 224 | inputs: 1,
|
220 | 225 | outputs: 0,
|
221 | 226 | icon: "cloudant.png",
|
222 | 227 | align: "right",
|
223 |
| - label: label, //called |
| 228 | + label: label, |
224 | 229 | labelStyle: function() {
|
225 | 230 | return this.name?"node_label_italic":"";
|
226 | 231 | },
|
227 |
| - oneditprepare: oneditprepare //called |
| 232 | + oneditprepare: oneditprepare |
228 | 233 | });
|
229 | 234 | })();
|
230 |
| - |
231 | 235 | </script>
|
0 commit comments