|
88 | 88 | </script>
|
89 | 89 |
|
90 | 90 | <script type="text/x-red" data-template-name="cloudant out">
|
91 |
| - |
92 | 91 | <div class="form-row">
|
93 | 92 | <label for="node-input-service"><i class="fa fa-folder-close"></i> Service</label>
|
94 | 93 | <select id="node-input-service">
|
|
136 | 135 | else $(".node-input-payonly").show();
|
137 | 136 | });
|
138 | 137 | </script>
|
| 138 | +</script> |
| 139 | + |
| 140 | +<script type="text/x-red" data-template-name="cloudant in"> |
| 141 | + <div class="form-row"> |
| 142 | + <label for="node-input-service"><i class="fa fa-folder-close"></i> Service</label> |
| 143 | + <select id="node-input-service"> |
| 144 | + <option value="" disabled></option> |
| 145 | + <option value="_ext_"> External service</option> |
| 146 | + </select> |
| 147 | + </div> |
| 148 | + |
| 149 | + <div class="form-row hide" id="node-input-external-details"> |
| 150 | + <label for="node-input-cloudant"><i class=" fa fa-bookmark"></i> Server</label> |
| 151 | + <input type="text" id="node-input-cloudant"> |
| 152 | + </div> |
| 153 | + |
| 154 | + <div class="form-row"> |
| 155 | + <label for="node-input-database"><i class="fa fa-briefcase"></i> Database</label> |
| 156 | + <input type="text" id="node-input-database" placeholder="database"> |
| 157 | + </div> |
| 158 | + |
| 159 | + <div class="form-row"> |
| 160 | + <label for="node-input-design-doc"><i class="fa fa-search"></i> Search Idx.</label> |
| 161 | + <input type="text" id="node-input-design" style="width: 30%" placeholder="design document"> |
| 162 | + / |
| 163 | + <input type="text" id="node-input-index" style="width: 30%" placeholder="index name"> |
| 164 | + </div> |
| 165 | + |
| 166 | + <div class="form-row"> |
| 167 | + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> |
| 168 | + <input type="text" id="node-input-name" placeholder="Name"> |
| 169 | + </div> |
139 | 170 |
|
| 171 | + <script> |
| 172 | + $("#node-input-operation").change(function() { |
| 173 | + var id = $("#node-input-operation option:selected").val(); |
| 174 | + if (id == "delete") $(".node-input-payonly").hide(); |
| 175 | + else $(".node-input-payonly").show(); |
| 176 | + }); |
| 177 | + </script> |
| 178 | +</script> |
| 179 | + |
| 180 | +<script type="text/javascript"> |
| 181 | + RED.nodes.registerType("cloudant out", { |
| 182 | + category: "storage-output", |
| 183 | + color: "rgb(114, 199, 231)", |
| 184 | + defaults: { |
| 185 | + service: { value: "", required: true }, |
| 186 | + cloudant: { type: "cloudant", validate: validateServer}, |
| 187 | + name: { value: "" }, |
| 188 | + database: { value: "", required: true }, |
| 189 | + payonly: { value: false }, |
| 190 | + operation: { value: "insert" } |
| 191 | + }, |
| 192 | + inputs: 1, |
| 193 | + outputs: 0, |
| 194 | + icon: "cloudant.png", |
| 195 | + align: "right", |
| 196 | + label: label, |
| 197 | + labelStyle: function() { |
| 198 | + return this.name?"node_label_italic":""; |
| 199 | + }, |
| 200 | + oneditprepare: oneditprepare |
| 201 | + }); |
| 202 | + |
| 203 | + RED.nodes.registerType("cloudant in", { |
| 204 | + category: "storage-input", |
| 205 | + color: "rgb(114, 199, 231)", |
| 206 | + defaults: { |
| 207 | + service : { value: "", required: true }, |
| 208 | + cloudant: { type: "cloudant", validate: validateServer }, |
| 209 | + name : { value: "" }, |
| 210 | + database: { value: "", required: true }, |
| 211 | + design : { value: "", required: true }, |
| 212 | + index : { value: "", required: true } |
| 213 | + }, |
| 214 | + inputs : 1, |
| 215 | + outputs: 1, |
| 216 | + icon : "cloudant.png", |
| 217 | + label : label, |
| 218 | + labelStyle: function() { |
| 219 | + return this.name?"node_label_italic":""; |
| 220 | + }, |
| 221 | + oneditprepare: oneditprepare |
| 222 | + }); |
| 223 | + |
| 224 | + function oneditprepare() { |
| 225 | + var select = $('#node-input-service'); |
| 226 | + var node = this; |
| 227 | + |
| 228 | + $.getJSON('cloudant/vcap/',function(data) { |
| 229 | + var last = select.children().last(); |
| 230 | + var opts = []; |
| 231 | + |
| 232 | + for (var i=0; i < data.length; i++) { |
| 233 | + var selected = node.service == data[i].name; |
| 234 | + opts.push( |
| 235 | + '<option value="' + data[i].name + '"' + (selected ? " selected":"") + '>' + |
| 236 | + data[i].name + |
| 237 | + '</option>' |
| 238 | + ); |
| 239 | + } |
| 240 | + |
| 241 | + if (opts.length == 0) { |
| 242 | + node.service = "_ext_"; |
| 243 | + select.find("option").filter(function() { |
| 244 | + return $(this).val() == node.service; |
| 245 | + }).attr('selected', true); |
| 246 | + } else { |
| 247 | + last.before(opts.join("")); |
| 248 | + } |
| 249 | + |
| 250 | + select.change(); |
| 251 | + }); |
| 252 | + |
| 253 | + select.change(function() { |
| 254 | + var service = select.val(); |
| 255 | + if (service == "_ext_") { |
| 256 | + $("#node-input-external-details").show(); |
| 257 | + } else { |
| 258 | + $("#node-input-external-details").hide(); |
| 259 | + } |
| 260 | + }); |
| 261 | + } |
| 262 | + |
| 263 | + function label() { |
| 264 | + return this.name || this.database || "cloudant"; |
| 265 | + } |
| 266 | + |
| 267 | + function validateServer(v) { |
| 268 | + return this.service != "_ext_" || v != "_ADD_"; |
| 269 | + } |
140 | 270 | </script>
|
141 | 271 |
|
142 | 272 | <script type="text/x-red" data-help-name="cloudant out">
|
|
160 | 290 | </p>
|
161 | 291 | </script>
|
162 | 292 |
|
163 |
| -<script type="text/javascript"> //js functions |
164 |
| - (function() { |
165 |
| - |
166 |
| - function oneditprepare() { |
167 |
| - var select = $('#node-input-service'); |
168 |
| - var node = this; |
169 |
| - |
170 |
| - $.getJSON('cloudant/vcap/',function(data) { |
171 |
| - var last = select.children().last(); |
172 |
| - var opts = []; |
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 |
| - ); |
181 |
| - } |
182 |
| - |
183 |
| - if (opts.length == 0) { |
184 |
| - node.service = "_ext_"; |
185 |
| - select.find("option").filter(function() { |
186 |
| - return $(this).val() == node.service; |
187 |
| - }).attr('selected', true); |
188 |
| - } else { |
189 |
| - last.before(opts.join("")); |
190 |
| - } |
191 |
| - |
192 |
| - select.change(); |
193 |
| - }); |
194 |
| - |
195 |
| - select.change(function() { |
196 |
| - var service = select.val(); |
197 |
| - if (service == "_ext_") { |
198 |
| - $("#node-input-external-details").show(); |
199 |
| - } else { |
200 |
| - $("#node-input-external-details").hide(); |
201 |
| - } |
202 |
| - }); |
203 |
| - } |
204 |
| - |
205 |
| - function label() { |
206 |
| - return this.name || this.database || "cloudant"; |
207 |
| - } |
208 |
| - |
209 |
| - function validateServer(v) { |
210 |
| - return this.service != "_ext_" || v != "_ADD_"; |
211 |
| - } |
212 |
| - |
213 |
| - RED.nodes.registerType("cloudant out", { |
214 |
| - category: "storage-output", |
215 |
| - color: "rgb(114, 199, 231)", |
216 |
| - defaults: { |
217 |
| - service: { value: "", required: true }, |
218 |
| - cloudant: { type: "cloudant", validate: validateServer}, |
219 |
| - name: { value: "" }, |
220 |
| - database: { value: "", required: true }, |
221 |
| - payonly: { value: false }, |
222 |
| - operation: { value: "insert" } |
223 |
| - }, |
224 |
| - inputs: 1, |
225 |
| - outputs: 0, |
226 |
| - icon: "cloudant.png", |
227 |
| - align: "right", |
228 |
| - label: label, |
229 |
| - labelStyle: function() { |
230 |
| - return this.name?"node_label_italic":""; |
231 |
| - }, |
232 |
| - oneditprepare: oneditprepare |
233 |
| - }); |
234 |
| - })(); |
| 293 | +<script type="text/x-red" data-help-name="cloudant in"> |
| 294 | + <p> |
| 295 | + A node for searching a Cloudant database using a Search Index. |
| 296 | + </p> |
| 297 | + <p> |
| 298 | + Query is performed on existing <b>Search Indexes</b> stored on the desired |
| 299 | + database. The query argument should be passed on the <code>msg.payload</code> |
| 300 | + following the <code>indexName:value</code> pattern. |
| 301 | + </p> |
235 | 302 | </script>
|
0 commit comments