[CCSDK-28] populated the seed code for dgbuilder
[ccsdk/distribution.git] / dgbuilder / core_nodes / storage / 65-redisout.html
1 <!--
2   Copyright 2013 IBM Corp.
3
4   Licensed under the Apache License, Version 2.0 (the "License");
5   you may not use this file except in compliance with the License.
6   You may obtain a copy of the License at
7
8   http://www.apache.org/licenses/LICENSE-2.0
9
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15 -->
16
17 <script type="text/x-red" data-template-name="redis out">
18     <div class="form-row node-input-hostname">
19         <label for="node-input-hostname"><i class="fa fa-bookmark"></i> Host</label>
20         <input class="input-append-left" type="text" id="node-input-hostname" placeholder="127.0.0.1" style="width: 40%;" ><button id="node-input-hostname-lookup" class="btn input-append-right"><span class="caret"></span></button>
21         <label for="node-input-port" style="margin-left: 10px; width: 35px; "> Port</label>
22         <input type="text" id="node-input-port" placeholder="6379" style="width:45px">
23     </div>
24     <div class="form-row">
25         <label for="node-input-key"><i class="fa fa-key"></i> Key</label>
26         <input type="text" id="node-input-key" placeholder="Redis Key">
27     </div>
28     <div class="form-row">
29         <label for="node-input-type"><i class="fa fa-th"></i> Type</label>
30         <select type="text" id="node-input-structtype" style="width: 150px;">
31         <option value="string">String</option>
32         <option value="hash">Hash</option>
33         <option value="set">Set</option>
34         <option value="list">List</option>
35         </select>
36     </div>
37     <div class="form-row">
38         <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
39         <input type="text" id="node-input-name" placeholder="Name">
40     </div>
41     <div class="form-tips">
42         If key is blank, the topic will be used as the key.<br>
43         If type is hash, payload should be field=value.
44     </div>
45 </script>
46
47 <script type="text/x-red" data-help-name="redis out">
48     <p>A Redis output node. Options include Hash, Set, List and String.</p>
49     <p>To run this you need a local Redis server running. For details see <a href="http://redis.io/" target="_new">the Redis site</a>.</p>
50 </script>
51
52 <script type="text/javascript">
53     RED.nodes.registerType('redis out',{
54         category: 'storage-output',
55         color:"#ffaaaa",
56         defaults: {
57             hostname: { value:"127.0.0.1",required:true},
58             port: { value: 6379,required:true},
59             name: {value:""},
60             key: {value:""},
61             structtype: {value:"",required:true}
62         },
63         inputs:1,
64         outputs:0,
65         icon: "redis.png",
66         align: "right",
67         label: function() {
68             return this.name||this.key+" ("+this.structtype+")";
69         },
70         oneditprepare: function() {
71             var availableServers = [];
72             var matchedServers = {};
73             RED.nodes.eachNode(function(node) {
74                 if (node.type == "redis out" && node.hostname && node.port && !matchedServers[node.hostname+":"+node.port]) {
75                     var label = node.hostname+":"+node.port;
76                     matchedServers[label] = true;
77                     availableServers.push({
78                         label:label,
79                         value:node.hostname,
80                         port:node.port
81                     });
82                 }
83             });
84             $( "#node-input-hostname" ).autocomplete({
85                 minLength: 0,
86                 source: availableServers,
87                 select: function( event, ui ) {
88                     $("#node-input-port").val(ui.item.port);
89                 }
90             });
91             var tt = this;
92             tt._acOpen = false;
93             $( "#node-input-hostname" ).on( "autocompleteclose", function( event, ui ) { tt._acOpen = false;} );
94             $( "#node-input-hostname-lookup" ).click(function(e) {
95                 if (tt._acOpen) {
96                     $( "#node-input-hostname" ).autocomplete( "close");
97                 } else {
98                     $( "#node-input-hostname" ).autocomplete( "search", "" );
99                 }
100                 tt._acOpen = !tt._acOpen;
101                 e.preventDefault();
102             });
103         }
104     });
105 </script>