|
| 1 | +<!-- |
| 2 | + Copyright 2016 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="watson-discovery"> |
| 18 | + <div id="credentials-check" class="form-row"> |
| 19 | + <div class="form-tips"> |
| 20 | + <i class="fa fa-question-circle"></i><b> Please wait: </b> Checking for bound service credentials... |
| 21 | + </div> |
| 22 | + </div> |
| 23 | + <div class="form-row"> |
| 24 | + <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> |
| 25 | + <input type="text" id="node-input-name" placeholder="Name"> |
| 26 | + </div> |
| 27 | + <div class="form-row credentials" style="display: none;"> |
| 28 | + <label for="node-input-username"><i class="fa fa-user"></i> Username</label> |
| 29 | + <input type="text" id="node-input-username" placeholder="Username"> |
| 30 | + </div> |
| 31 | + <div class="form-row credentials" style="display: none;"> |
| 32 | + <label for="node-input-password"><i class="fa fa-key"></i> Password</label> |
| 33 | + <input type="password" id="node-input-password" placeholder="Password"> |
| 34 | + </div> |
| 35 | + <div class="form-row"> |
| 36 | + <label for="node-input-environmentname"><i class="fa fa-tag"></i> Environment Name</label> |
| 37 | + <input type="text" id="node-input-envrionmentname" placeholder=""> |
| 38 | + </div> |
| 39 | +</script> |
| 40 | + |
| 41 | +<script type="text/x-red" data-help-name="watson-discovery"> |
| 42 | + <p>This is the Node for the V1 Experimental Watson Discovery service.</p> |
| 43 | + <p>This version of the Node will only list the envrionments created for |
| 44 | + the service. |
| 45 | + </p> |
| 46 | + <p>The node does not need any input. If the envrionment name field is left blank |
| 47 | + it will list all envrionments created for the instance of the Discovery service. |
| 48 | + If the envrionment name is specified, then only the details for |
| 49 | + the Discovery envrionment with the specified name will be returned. |
| 50 | + </p> |
| 51 | + <p>The environment being requested can be overridden by specifying the search name |
| 52 | + in <code>msg.discoveryparams.envrionmentname</code> |
| 53 | + </p> |
| 54 | + |
| 55 | + <p>Node output : </p> |
| 56 | + <ul> |
| 57 | + <li><code>msg.envrionments</code> : A list of the envrionments created under |
| 58 | + the Discovery service instance.</li> |
| 59 | + </ul> |
| 60 | + <p>For more information about the Discovery service, |
| 61 | + read the service <a href="https://www.ibm.com/watson/developercloud/doc/discovery/">documentation</a>.</p> |
| 62 | +</script> |
| 63 | + |
| 64 | +<script type="text/javascript"> |
| 65 | + (function() { |
| 66 | + RED.nodes.registerType('watson-discovery', { |
| 67 | + category: 'IBM Watson', |
| 68 | + defaults: { |
| 69 | + name: {value: ""}, |
| 70 | + envrionmentname: {value: ""} |
| 71 | + }, |
| 72 | + credentials: { |
| 73 | + username: {type:"text"}, |
| 74 | + password: {type:"password"} |
| 75 | + }, |
| 76 | + color: "rgb(84,149,230)", |
| 77 | + inputs: 1, |
| 78 | + outputs: 1, |
| 79 | + icon: "discovery.png", |
| 80 | + paletteLabel: "discovery", |
| 81 | + label: function() { |
| 82 | + return this.name || "discovery"; |
| 83 | + }, |
| 84 | + labelStyle: function() { |
| 85 | + return this.name ? "node_label_italic" : ""; |
| 86 | + }, |
| 87 | + oneditprepare: function() { |
| 88 | + $.getJSON('watson-discovery/vcap/') |
| 89 | + .done(function (service) { |
| 90 | + $('.credentials').toggle(!service); |
| 91 | + }) |
| 92 | + .fail(function () { |
| 93 | + $('.credentials').show(); |
| 94 | + }).always(function () { |
| 95 | + $('#credentials-check').hide(); |
| 96 | + }) |
| 97 | + } |
| 98 | + }); |
| 99 | + })(); |
| 100 | +</script> |
0 commit comments