Skip to content

Commit 05f6a44

Browse files
committed
Merge branch 'develop'
* develop: update package.json add updates from Dave
2 parents 6ac68c0 + 54cda07 commit 05f6a44

File tree

4 files changed

+115
-193
lines changed

4 files changed

+115
-193
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.DS_Store
2+
node_modules

77-cloudant-cf.html

Lines changed: 39 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
Copyright 2014 IBM Corp.
2+
Copyright 2014,2016 IBM Corp.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -17,20 +17,16 @@
1717
<script type="text/x-red" data-template-name="cloudant">
1818
<div class="form-row">
1919
<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">
2221
</div>
23-
2422
<div class="form-row">
2523
<label for="node-config-input-username"><i class="fa fa-user"></i> Username</label>
2624
<input type="text" id="node-config-input-username">
2725
</div>
28-
2926
<div class="form-row">
3027
<label for="node-config-input-pass"><i class="fa fa-lock"></i> Password</label>
3128
<input type="password" id="node-config-input-pass">
3229
</div>
33-
3430
<div class="form-row">
3531
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
3632
<input type="text" id="node-config-input-name" placeholder="Name">
@@ -42,92 +38,53 @@
4238
category: "config",
4339
color: "rgb(114, 199, 231)",
4440
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"}
4947
},
5048
label: function() {
5149
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-
});
8650
}
8751
});
8852
</script>
8953

9054
<script type="text/x-red" data-template-name="cloudant out">
9155
<div class="form-row">
9256
<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>
9660
</select>
9761
</div>
98-
9962
<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>
10164
<input type="text" id="node-input-cloudant">
10265
</div>
103-
10466
<div class="form-row">
10567
<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%;">
10769
</div>
108-
10970
</div>
11071
<div class="form-row">
11172
<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%;">
11474
<option value="insert">insert</option>
11575
<option value="delete">remove</option>
11676
</select>
11777
</div>
118-
11978
<div class="form-row node-input-payonly">
12079
<label>&nbsp;</label>
12180
<input type="checkbox" id="node-input-payonly" placeholder="Only"
12281
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>
12483
</div>
125-
12684
<div class="form-row">
12785
<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%;">
12987
</div>
130-
13188
<script>
13289
$("#node-input-operation").change(function() {
13390
var id = $("#node-input-operation option:selected").val();
@@ -140,41 +97,36 @@
14097
<script type="text/x-red" data-template-name="cloudant in">
14198
<div class="form-row">
14299
<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>
146103
</select>
147104
</div>
148-
149105
<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>
151107
<input type="text" id="node-input-cloudant">
152108
</div>
153-
154109
<div class="form-row">
155110
<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%;">
157112
</div>
158-
159113
<div class="form-row">
160114
<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%;">
162116
<option value="_id_">_id</option>
163117
<option value="_idx_">search index</option>
164118
<option value="_all_">all documents</option>
165119
</select>
166120
</div>
167-
168121
<div id="node-search-index-form" class="form-row">
169122
<label>&nbsp;</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">
171124
/
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">
173126
</div>
174-
175127
<div class="form-row">
176128
<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%;">
178130
</div>
179131
</script>
180132

@@ -183,12 +135,12 @@
183135
category: "storage-output",
184136
color: "rgb(114, 199, 231)",
185137
defaults: {
186-
service: { value: "", required: true },
187-
cloudant: { type: "cloudant", validate: validateServer},
188138
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" }
192144
},
193145
inputs: 1,
194146
outputs: 0,
@@ -205,13 +157,13 @@
205157
category: "storage-input",
206158
color: "rgb(114, 199, 231)",
207159
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:"" }
215167
},
216168
inputs : 1,
217169
outputs: 1,
@@ -225,7 +177,6 @@
225177

226178
function oneditprepare() {
227179
var node = this;
228-
229180
var serviceSelect = $('#node-input-service');
230181
var searchBySelect = $('#node-input-search');
231182
var searchForm = $('#node-search-index-form');
@@ -236,11 +187,7 @@
236187

237188
for (var i=0; i < data.length; i++) {
238189
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>');
244191
}
245192

246193
if (opts.length == 0) {
@@ -289,8 +236,7 @@
289236

290237
// https://wiki.apache.org/couchdb/HTTP_database_API#Naming_and_Addressing
291238
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)
294240
}
295241
</script>
296242

0 commit comments

Comments
 (0)