|
1 | 1 | <!-- |
2 | | - Copyright 2014 IBM Corp. |
| 2 | + Copyright 2014,2016 IBM Corp. |
3 | 3 |
|
4 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | you may not use this file except in compliance with the License. |
|
17 | 17 | <script type="text/x-red" data-template-name="cloudant"> |
18 | 18 | <div class="form-row"> |
19 | 19 | <label for="node-config-input-host"><i class="fa fa-bookmark"></i> Host</label> |
20 | | - <input class="input-append-left" type="text" id="node-config-input-host" |
21 | | - placeholder="[username].cloudant.com"> |
| 20 | + <input class="input-append-left" type="text" id="node-config-input-host" placeholder="[username].cloudant.com or http://your-server.com"> |
22 | 21 | </div> |
23 | | - |
24 | 22 | <div class="form-row"> |
25 | 23 | <label for="node-config-input-username"><i class="fa fa-user"></i> Username</label> |
26 | 24 | <input type="text" id="node-config-input-username"> |
27 | 25 | </div> |
28 | | - |
29 | 26 | <div class="form-row"> |
30 | 27 | <label for="node-config-input-pass"><i class="fa fa-lock"></i> Password</label> |
31 | 28 | <input type="password" id="node-config-input-pass"> |
32 | 29 | </div> |
33 | | - |
34 | 30 | <div class="form-row"> |
35 | 31 | <label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label> |
36 | 32 | <input type="text" id="node-config-input-name" placeholder="Name"> |
|
42 | 38 | category: "config", |
43 | 39 | color: "rgb(114, 199, 231)", |
44 | 40 | defaults: { |
45 | | - host: { value: "", required: true }, |
46 | | - name: { value: "" }, |
47 | | - //user -> credentials |
48 | | - //pass -> credentials |
| 41 | + host: {value:"", required:true}, |
| 42 | + name: {value:""} |
| 43 | + }, |
| 44 | + credentials: { |
| 45 | + username: {type:"text"}, |
| 46 | + pass: {type:"password"} |
49 | 47 | }, |
50 | 48 | label: function() { |
51 | 49 | return this.name || this.host; |
52 | | - }, |
53 | | - oneditprepare: function() { |
54 | | - $.getJSON("cloudant/"+this.id, function(data) { |
55 | | - if (data.username) { |
56 | | - $("#node-config-input-username").val(data.username); |
57 | | - } |
58 | | - if (data.hasPassword) { |
59 | | - $("#node-config-input-pass").val("__PWRD__"); |
60 | | - } else { |
61 | | - $("#node-config-input-pass").val(""); |
62 | | - } |
63 | | - }); |
64 | | - }, |
65 | | - oneditsave: function() { |
66 | | - var newUser = $("#node-config-input-username").val(); |
67 | | - var newPass = $("#node-config-input-pass").val(); |
68 | | - var credentials = {}; |
69 | | - credentials.username = newUser; |
70 | | - if (newPass != "__PWRD__") { |
71 | | - credentials.password = newPass; |
72 | | - } |
73 | | - $.ajax({ |
74 | | - url: "cloudant/"+this.id, |
75 | | - type: "POST", |
76 | | - data: credentials, |
77 | | - success: function(result) {} |
78 | | - }); |
79 | | - }, |
80 | | - ondelete: function() { |
81 | | - $.ajax({ |
82 | | - url: "cloudant/"+this.id, |
83 | | - type: "DELETE", |
84 | | - success: function(result) {} |
85 | | - }); |
86 | 50 | } |
87 | 51 | }); |
88 | 52 | </script> |
89 | 53 |
|
90 | 54 | <script type="text/x-red" data-template-name="cloudant out"> |
91 | 55 | <div class="form-row"> |
92 | 56 | <label for="node-input-service"><i class="fa fa-folder-close"></i> Service</label> |
93 | | - <select id="node-input-service"> |
94 | | - <option value="" disabled></option> |
95 | | - <option value="_ext_"> External service</option> |
| 57 | + <select id="node-input-service" style="width:68%;"> |
| 58 | + <!-- <option value="" disabled></option> --> |
| 59 | + <option value="_ext_"> External cloudant or couchdb service</option> |
96 | 60 | </select> |
97 | 61 | </div> |
98 | | - |
99 | 62 | <div class="form-row hide" id="node-input-external-details"> |
100 | | - <label for="node-input-cloudant"><i class=" fa fa-bookmark"></i> Server</label> |
| 63 | + <label for="node-input-cloudant"><i class="fa fa-bookmark"></i> Server</label> |
101 | 64 | <input type="text" id="node-input-cloudant"> |
102 | 65 | </div> |
103 | | - |
104 | 66 | <div class="form-row"> |
105 | 67 | <label for="node-input-database"><i class="fa fa-briefcase"></i> Database</label> |
106 | | - <input type="text" id="node-input-database" placeholder="database"> |
| 68 | + <input type="text" id="node-input-database" placeholder="database" style="width:65%;"> |
107 | 69 | </div> |
108 | | - |
109 | 70 | </div> |
110 | 71 | <div class="form-row"> |
111 | 72 | <label for="node-input-operation"><i class="fa fa-wrench"></i> Operation</label> |
112 | | - <select type="text" id="node-input-operation" |
113 | | - style="display: inline-block; vertical-align: top;"> |
| 73 | + <select type="text" id="node-input-operation" style="width:68%;"> |
114 | 74 | <option value="insert">insert</option> |
115 | 75 | <option value="delete">remove</option> |
116 | 76 | </select> |
117 | 77 | </div> |
118 | | - |
119 | 78 | <div class="form-row node-input-payonly"> |
120 | 79 | <label> </label> |
121 | 80 | <input type="checkbox" id="node-input-payonly" placeholder="Only" |
122 | 81 | style="display: inline-block; width: auto; vertical-align: top;"> |
123 | | - <label for="node-input-payonly" style="width: 70%;">Only store msg.payload object?</label> |
| 82 | + <label for="node-input-payonly" style="width:65%;">Only store msg.payload object?</label> |
124 | 83 | </div> |
125 | | - |
126 | 84 | <div class="form-row"> |
127 | 85 | <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> |
128 | | - <input type="text" id="node-input-name" placeholder="Name"> |
| 86 | + <input type="text" id="node-input-name" placeholder="Name" style="width:65%;"> |
129 | 87 | </div> |
130 | | - |
131 | 88 | <script> |
132 | 89 | $("#node-input-operation").change(function() { |
133 | 90 | var id = $("#node-input-operation option:selected").val(); |
|
140 | 97 | <script type="text/x-red" data-template-name="cloudant in"> |
141 | 98 | <div class="form-row"> |
142 | 99 | <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> |
| 100 | + <select id="node-input-service" style="width:68%;"> |
| 101 | + <!-- <option value="" disabled></option> --> |
| 102 | + <option value="_ext_"> External cloudant or couchdb service</option> |
146 | 103 | </select> |
147 | 104 | </div> |
148 | | - |
149 | 105 | <div class="form-row hide" id="node-input-external-details"> |
150 | | - <label for="node-input-cloudant"><i class=" fa fa-bookmark"></i> Server</label> |
| 106 | + <label for="node-input-cloudant"><i class="fa fa-bookmark"></i> Server</label> |
151 | 107 | <input type="text" id="node-input-cloudant"> |
152 | 108 | </div> |
153 | | - |
154 | 109 | <div class="form-row"> |
155 | 110 | <label for="node-input-database"><i class="fa fa-briefcase"></i> Database</label> |
156 | | - <input type="text" id="node-input-database" placeholder="database"> |
| 111 | + <input type="text" id="node-input-database" placeholder="database" style="width:65%;"> |
157 | 112 | </div> |
158 | | - |
159 | 113 | <div class="form-row"> |
160 | 114 | <label for="node-input-search"><i class="fa fa-search"></i> Search by</label> |
161 | | - <select id="node-input-search"> |
| 115 | + <select id="node-input-search" style="width:68%;"> |
162 | 116 | <option value="_id_">_id</option> |
163 | 117 | <option value="_idx_">search index</option> |
164 | 118 | <option value="_all_">all documents</option> |
165 | 119 | </select> |
166 | 120 | </div> |
167 | | - |
168 | 121 | <div id="node-search-index-form" class="form-row"> |
169 | 122 | <label> </label> |
170 | | - <input type="text" id="node-input-design" style="width: 30%" placeholder="design document"> |
| 123 | + <input type="text" id="node-input-design" style="width:30%" placeholder="design document"> |
171 | 124 | / |
172 | | - <input type="text" id="node-input-index" style="width: 30%" placeholder="index name"> |
| 125 | + <input type="text" id="node-input-index" style="width:30%" placeholder="index name"> |
173 | 126 | </div> |
174 | | - |
175 | 127 | <div class="form-row"> |
176 | 128 | <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> |
177 | | - <input type="text" id="node-input-name" placeholder="Name"> |
| 129 | + <input type="text" id="node-input-name" placeholder="Name" style="width:65%;"> |
178 | 130 | </div> |
179 | 131 | </script> |
180 | 132 |
|
|
183 | 135 | category: "storage-output", |
184 | 136 | color: "rgb(114, 199, 231)", |
185 | 137 | defaults: { |
186 | | - service: { value: "", required: true }, |
187 | | - cloudant: { type: "cloudant", validate: validateServer}, |
188 | 138 | name: { value: "" }, |
189 | | - database: { value: "", required: true, validate: validateDatabase }, |
190 | | - payonly: { value: false }, |
191 | | - operation: { value: "insert" } |
| 139 | + cloudant: { type:"cloudant", validate:validateServer}, |
| 140 | + database: { value:"", required:true, validate:validateDatabase }, |
| 141 | + service: { value:"", required:true }, |
| 142 | + payonly: { value:false }, |
| 143 | + operation: { value:"insert" } |
192 | 144 | }, |
193 | 145 | inputs: 1, |
194 | 146 | outputs: 0, |
|
205 | 157 | category: "storage-input", |
206 | 158 | color: "rgb(114, 199, 231)", |
207 | 159 | defaults: { |
208 | | - service : { value: "", required: true }, |
209 | | - cloudant: { type: "cloudant", validate: validateServer }, |
210 | | - name : { value: "" }, |
211 | | - database: { value: "", required: true, validate: validateDatabase }, |
212 | | - search : { value: "_id_", required: true }, |
213 | | - design : { value: "" }, |
214 | | - index : { value: "" } |
| 160 | + name : { value:"" }, |
| 161 | + cloudant: { type:"cloudant", validate:validateServer }, |
| 162 | + database: { value:"", required:true, validate:validateDatabase }, |
| 163 | + service : { value:"", required:true }, |
| 164 | + search : { value:"_id_", required:true }, |
| 165 | + design : { value:"" }, |
| 166 | + index : { value:"" } |
215 | 167 | }, |
216 | 168 | inputs : 1, |
217 | 169 | outputs: 1, |
|
225 | 177 |
|
226 | 178 | function oneditprepare() { |
227 | 179 | var node = this; |
228 | | - |
229 | 180 | var serviceSelect = $('#node-input-service'); |
230 | 181 | var searchBySelect = $('#node-input-search'); |
231 | 182 | var searchForm = $('#node-search-index-form'); |
|
236 | 187 |
|
237 | 188 | for (var i=0; i < data.length; i++) { |
238 | 189 | var selected = node.service == data[i].name; |
239 | | - opts.push( |
240 | | - '<option value="' + data[i].name + '"' + (selected ? " selected":"") + '>' + |
241 | | - data[i].name + |
242 | | - '</option>' |
243 | | - ); |
| 190 | + opts.push('<option value="' + data[i].name + '"' + (selected ? " selected":"") + '>' + data[i].name + '</option>'); |
244 | 191 | } |
245 | 192 |
|
246 | 193 | if (opts.length == 0) { |
|
289 | 236 |
|
290 | 237 | // https://wiki.apache.org/couchdb/HTTP_database_API#Naming_and_Addressing |
291 | 238 | function validateDatabase(v) { |
292 | | - return (v.indexOf('_') !== 0) && |
293 | | - (v.search(/[A-Z\s\\/]/g) < 0) |
| 239 | + return (v.indexOf('_') !== 0) && (v.search(/[A-Z\s\\/]/g) < 0) |
294 | 240 | } |
295 | 241 | </script> |
296 | 242 |
|
|
0 commit comments