-
Notifications
You must be signed in to change notification settings - Fork 6
/
objstore.html
379 lines (356 loc) · 15.2 KB
/
objstore.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
<!--
Copyright 2016 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: Olaf Hahn
-->
<!-- Object Storage Get Node -->
<script type="text/x-red" data-template-name="os-get">
<div class="form-row">
<label for="node-input-osconfig"><i class="fa fa-tasks"></i> Object Storage Service</label>
<input type="text" id="node-input-osconfig">
</div>
<div id="objectname" class="form-row">
<label for="node-input-objectname"><i class="fa fa-fileo"></i> Object Name</label>
<input type="text" id="node-input-objectname" placeholder="Name of the Object in the Store">
</div>
<div class="form-row">
<label for="node-input-container"><i class="fa fa-folder-open-o"></i> Container</label>
<input type="text" id="node-input-container" placeholder="Container">
</div>
<div id="mode" class="form-row">
<label for="node-input-mode"><i class="fa fa-fileo"></i> Mode</label>
<select id="node-input-mode">
<option value="0">Filebased</option>
<option value="1">Buffer</option>
</select>
</div>
<div id="filename" class="form-row">
<label for="node-input-filename"><i class="fa fa-fileo"></i> Filename</label>
<input type="text" id="node-input-filename" placeholder="Filename with extension">
</div>
<div id="filepath" class="form-row">
<label for="node-input-filepath"><i class="fa fa-fileo"></i> Filepath</label>
<input type="text" id="node-input-filepath" placeholder="Path to File">
</div>
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<!-- Next, some simple help text is provided for the node. -->
<script type="text/x-red" data-help-name="os-get">
<p>This <b>Object Storage Get Node</b> gets the image from the Object Storage Service on Bluemix. </p>
<p>Provide in <b>msg.objectname</b> the name of the stored object in the Object Storage Service and in <b>msg.container</b> the container it resides in.</p>
<p>The <b>msg.mode</b> indicates to store the image in the <b>msg.payload</b> (mode=0) or into the given filename and path (mode=1). </p>
<p>You can override the node-defaults by giving <b>msg.filename</b> and <b>msg.filepath</b> with the necessary informations.</p>
<p>The node returns <b>msg.payload</b> and the <b>msg.objectname</b> name of the object. </p>
</script>
<script type="text/javascript">
RED.nodes.registerType('os-get',{
category: 'storage',
defaults: {
name: {value:""},
container: {value:"", required:true},
objectname: {value:"", required:true},
filepath: {value:"", required:false},
filename: {value:"", required:false},
mode: {value:"0", required:true},
osconfig: {value:"", type:"os-config", required:true}
},
inputs:1,
outputs:1,
icon: "cloud1_20x20.png",
color: "#A6BBCF",
oneditprepare: function() {
$("#node-input-mode").change(function() {
var choose = $("#node-input-mode").val();
console.log(choose);
if (choose == "0") {
$("#filename").show();
$("#filepath").show();
} else {
$("#filename").hide();
$("#filepath").hide();
}
});
},
label: function() {
return this.name || "object storage get";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>
<!-- Object Storage Get Node -->
<!-- Object Storage Put Node -->
<script type="text/x-red" data-template-name="os-put">
<div class="form-row">
<label for="node-input-osconfig"><i class="fa fa-tasks"></i> Object Storage Service</label>
<input type="text" id="node-input-osconfig">
</div>
<div id="mode" class="form-row">
<label for="node-input-mode"><i class="fa fa-fileo"></i> Mode</label>
<select id="node-input-mode">
<option value="0">Filebased</option>
<option value="1">Buffer</option>
</select>
</div>
<div id="formattype" class="form-row">
<label for="node-input-formattype"><i class="fa fa-fileo"></i> Type</label>
<select id="node-input-formattype">
<option value="0">Image</option>
<option value="1">Audio</option>
</select>
</div>
<div id="filename" class="form-row">
<label for="node-input-filename"><i class="fa fa-fileo"></i> Filename</label>
<input type="text" id="node-input-filename" placeholder="Filename with extension">
</div>
<div id="filepath" class="form-row">
<label for="node-input-filepath"><i class="fa fa-fileo"></i> Filepath</label>
<input type="text" id="node-input-filepath" placeholder="Path to File">
</div>
<div id="imageformat" class="form-row node-input-imageformat">
<label for="node-input-imageformat"><i class="fa fa-file-image-o"></i> </label>
<select id="node-input-imageformat">
<option value="jpeg">JPEG</option>
<option value="png">PNG</option>
<option value="gif">GIF</option>
<option value="bmp">BMP</option>
<option value="yuv">YUV</option>
<option value="rgb">RGB</option>
<option value="rgba">RGBA</option>
<option value="bgr">BGR</option>
<option value="bgra">BGRA</option>
</select>
</div>
<div id="audioformat" class="form-row node-input-audioformat">
<label for="node-input-audioformat"><i class="fa fa-file-image-o"></i> </label>
<select id="node-input-audioformat">
<option value="wav">WAV</option>
<option value="ogg">OGG</option>
<option value="mpeg">MP3</option>
</select>
</div>
<div id="objectmode" class="form-row">
<label for="node-input-objectmode"><i class="fa fa-fileo"></i> Object Name Mode</label>
<select id="node-input-objectmode">
<option value="0">Take Filename</option>
<option value="1">Generate New</option>
<option value="2">Specify</option>
</select>
</div>
<div id="objectname" class="form-row">
<label for="node-input-objectname"><i class="fa fa-fileo"></i> Object Name</label>
<input type="text" id="node-input-objectname" placeholder="Name of the Object in the Store">
</div>
<div class="form-row">
<label for="node-input-container"><i class="fa fa-folder-open-o"></i> Container</label>
<input type="text" id="node-input-container" placeholder="Container">
</div>
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<!-- Next, some simple help text is provided for the node. -->
<script type="text/x-red" data-help-name="os-put">
<p>This <b>Object Storage Put Node</b> sends the image to the Object Storage Service on Bluemix. </p>
<p>The <b>msg.mode</b> indicates if the <b>msg.payload</b> contains the raw image or only the trigger for the image </p>
<p>You can override the node-defaults by giving <b>msg.filename</b>, <b>msg.filepath</b> and <b>msg.fileformat</b> with the necessary informations.</p>
<p>The node returns <b>msg.payload</b> with the link to the Object. </p>
</script>
<script type="text/javascript">
RED.nodes.registerType('os-put',{
category: 'storage',
defaults: {
name: {value:""},
container: {value:"", required:true},
objectname: {value:"", required:false},
objectmode: {value:"0", required:true},
imageformat: {value:"jpeg", required:false},
audioformat: {value:"wav", required:false},
filepath: {value:"", required:false},
filename: {value:"", required:false},
formattype: {value:"0", required:true},
mode: {value:"0", required:true},
osconfig: {value:"", type:"os-config", required:true}
},
inputs:1,
outputs:1,
icon: "cloud1_20x20.png",
color: "#A6BBCF",
oneditprepare: function() {
$("#node-input-mode").change(function() {
var choose = $("#node-input-mode").val();
console.log(choose);
if (choose == "0") {
$("#filename").show();
$("#filepath").show();
} else {
$("#filename").hide();
$("#filepath").hide();
}
});
$("#node-input-formattype").change(function() {
var choose = $("#node-input-formattype").val();
console.log(choose);
if (choose == "0") {
$("#imageformat").show();
$("#audioformat").hide();
} else {
$("#imageformat").hide();
$("#audioformat").show();
}
});
$("#node-input-objectmode").change(function() {
var choose = $("#node-input-objectmode").val();
console.log(choose);
if (choose == "2") {
$("#objectname").show();
} else {
$("#objectname").hide();
}
});
},
label: function() {
return this.name || "object storage put";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>
<!-- Object Storage Put Node -->
<!-- Object Storage Del Node -->
<script type="text/x-red" data-template-name="os-del">
<div class="form-row">
<label for="node-input-osconfig"><i class="fa fa-tasks"></i> Object Storage Service</label>
<input type="text" id="node-input-osconfig">
</div>
<div id="objectname" class="form-row">
<label for="node-input-objectname"><i class="fa fa-fileo"></i> Object Name</label>
<input type="text" id="node-input-objectname" placeholder="Name of the Object in the Store">
</div>
<div class="form-row">
<label for="node-input-container"><i class="fa fa-folder-open-o"></i> Container</label>
<input type="text" id="node-input-container" placeholder="Container">
</div>
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<!-- Next, some simple help text is provided for the node. -->
<script type="text/x-red" data-help-name="os-del">
<p>This <b>Object Storage Del Node</b> deletes the image from the Object Storage Service on Bluemix. </p>
<p>Provide in <b>msg.objectname</b> the name of the stored object in the Object Storage Service. </p>
</script>
<script type="text/javascript">
RED.nodes.registerType('os-del',{
category: 'storage',
defaults: {
name: {value:""},
container: {value:"", required:true},
objectname: {value:"", required:true},
osconfig: {value:"", type:"os-config", required:true}
},
inputs:1,
outputs:0,
icon: "cloud1_20x20.png",
color: "#A6BBCF",
label: function() {
return this.name || "object storage del";
},
labelStyle: function() {
return this.name?"node_label_italic":"";
}
});
</script>
<!-- Object Storage Del Node -->
<!-- Object Storage Config Node -->
<script type="text/x-red" data-template-name="os-config">
<div class="form-row">
<label for="node-config-input-cfgtype"><i class="fa fa-globe"></i> Configuration Information</label>
<select id="node-config-input-cfgtype">
<option value="api">API Based</option>
<option value="bluemix">Bluemix Service</option>
</select>
</div>
<div id="region" class="form-row">
<label for="node-config-input-region"><i class="fa fa-globe"></i> Region</label>
<select id="node-config-input-region">
<option value="dallas">Dallas</option>
<option value="london">London</option>
</select>
</div>
<div id="projectId" class="form-row">
<label for="node-config-input-projectId"><i class="fa fa-users"></i> Tendant Id</label>
<input type="text" id="node-config-input-projectId" placeholder="ProjectId">
</div>
<div id="userId" class="form-row">
<label for="node-config-input-userId"><i class="fa fa-user-secret"></i> User Id</label>
<input type="text" id="node-config-input-userId" placeholder="UserId">
</div>
<div id="userName" class="form-row">
<label for="node-config-input-userName"><i class="fa fa-user-secret"></i> User Name</label>
<input type="text" id="node-config-input-userName" placeholder="UserName">
</div>
<div id="password" class="form-row">
<label for="node-config-input-password"><i class="fa fa-key"></i> Password</label>
<input type="text" id="node-config-input-password" placeholder="Password">
</div>
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Name">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('os-config',{
category: 'config',
defaults: {
cfgtype: {value:"api",required:true},
region: {value:"dallas",required:true},
projectId: {value:"",required:true},
userId: {value:"",required:true},
userName: {value:"",required:true},
password: {value:"",required:true},
name: {value:"",required:true}
},
oneditprepare: function() {
$("#node-config-input-cfgtype").change(function() {
var choose = $("#node-config-input-cfgtype").val();
console.log(choose);
if (choose == "api") {
$("#region").show();
$("#projectId").show();
$("#userId").show();
$("#userName").show();
$("#password").show();
} else {
$("#region").hide();
$("#projectId").hide();
$("#userId").hide();
$("#userName").hide();
$("#password").hide();
}
});
},
label: function() {
return this.region + ":" + (this.name || "object storage config");
}
});
</script>
<!-- Object Storage Config Node -->