|
32 | 32 | <label for="node-input-password"><i class="fa fa-key"></i> Password</label>
|
33 | 33 | <input type="password" id="node-input-password" placeholder="Password">
|
34 | 34 | </div>
|
| 35 | + |
| 36 | + <div class="form-row"> |
| 37 | + <label for="node-input-discovery-method"><i class="fa fa-book"></i> Method: </label> |
| 38 | + <select type="text" id="node-input-discovery-method" style="display: inline-block; width: 70%;"> |
| 39 | + <option value="listEnvrionments">List existing envionments</option> |
| 40 | + <option value="getEnvironmentDetails">Retrieve environment details</option> |
| 41 | + <option value="listCollections">List existing collections</option> |
| 42 | + <option value="getCollectionDetails">Retrieve collection details</option> |
| 43 | + </select> |
| 44 | + </div> |
| 45 | + |
35 | 46 | <div class="form-row">
|
36 | 47 | <label for="node-input-environmentname"><i class="fa fa-tag"></i> Environment Name</label>
|
37 |
| - <input type="text" id="node-input-envrionmentname" placeholder=""> |
| 48 | + <input type="text" id="node-input-environmentname" placeholder=""> |
| 49 | + </div> |
| 50 | + <div class="form-row"> |
| 51 | + <label for="node-input-environment_id"><i class="fa fa-tag"></i> Environment ID</label> |
| 52 | + <input type="text" id="node-input-environment_id" placeholder=""> |
38 | 53 | </div>
|
| 54 | + <div class="form-row"> |
| 55 | + <label for="node-input-collection_id"><i class="fa fa-tag"></i> Collection ID</label> |
| 56 | + <input type="text" id="node-input-collection_id" placeholder=""> |
| 57 | + </div> |
| 58 | + |
39 | 59 | </script>
|
40 | 60 |
|
41 | 61 | <script type="text/x-red" data-help-name="watson-discovery">
|
42 | 62 | <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 |
| 63 | + <p>This Experimental node has now been deprecated.</p> |
| 64 | + <p>The following methods are available:</p> |
| 65 | + <ul> |
| 66 | + <li> |
| 67 | + <p><b>List Existing Envrionments</b><p> |
| 68 | + <p>The node does not need any input. If the envrionment name field is left blank |
47 | 69 | it will list all envrionments created for the instance of the Discovery service.
|
48 | 70 | If the envrionment name is specified, then only the details for
|
49 | 71 | 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> |
| 72 | + </p> |
| 73 | + <p>The environment being requested can be overridden by specifying the search name |
| 74 | + in <code>msg.discoveryparams.environmentname</code> |
| 75 | + </p> |
| 76 | + <p>Node output : </p> |
| 77 | + <ul> |
| 78 | + <li><code>msg.environments</code> : A list of the envrionments created under |
| 79 | + the Discovery service instance.</li> |
| 80 | + </ul> |
| 81 | + </li> |
| 82 | + <br/> |
| 83 | + <li> |
| 84 | + <p><b>Get Envrionment Details</b><p> |
| 85 | + <p>The node needs an Environment ID as input. |
| 86 | + </p> |
| 87 | + <p>The environment being requested can be overridden by specifying the search id |
| 88 | + in <code>msg.discoveryparams.environment_id</code> |
| 89 | + </p> |
| 90 | + <p>Node output : </p> |
| 91 | + <ul> |
| 92 | + <li><code>msg.environment_details</code> : Details of the requested environment.</li> |
| 93 | + </ul> |
| 94 | + </li> |
| 95 | + <br/> |
| 96 | + <li> |
| 97 | + <p><b>List Existing Collections</b><p> |
| 98 | + <p>The node needs an Environment ID as input.</p> |
| 99 | + <p>The Environment ID for the collection list being requested can be overridden by specifying the search id |
| 100 | + in <code>msg.discoveryparams.environment_id</code> |
| 101 | + </p> |
| 102 | + <p>Node output : </p> |
| 103 | + <ul> |
| 104 | + <li><code>msg.collections</code> : A list of the collections created under |
| 105 | + the environment in the Discovery service instance.</li> |
| 106 | + </ul> |
| 107 | + </li> |
| 108 | + <br/> |
| 109 | + <li> |
| 110 | + <p><b>Get Collections Details</b><p> |
| 111 | + <p>The node needs an Environment ID and Collection ID as input. |
| 112 | + </p> |
| 113 | + <p>The collection being requested can be overridden by specifying the |
| 114 | + search ids in |
| 115 | + <code>msg.discoveryparams.environment_id/code> |
| 116 | + and <code>msg.discoveryparams.collection_id/code> |
| 117 | + </p> |
| 118 | + <p>Node output : </p> |
| 119 | + <ul> |
| 120 | + <li><code>msg.collection_details</code> : Details of the requested collection.</li> |
| 121 | + </ul> |
| 122 | + </li> |
| 123 | + <br/> |
59 | 124 | </ul>
|
60 | 125 | <p>For more information about the Discovery service,
|
61 | 126 | read the service <a href="https://www.ibm.com/watson/developercloud/doc/discovery/">documentation</a>.</p>
|
| 127 | + |
62 | 128 | </script>
|
63 | 129 |
|
64 | 130 | <script type="text/javascript">
|
| 131 | + |
| 132 | + // Need to simulate a namespace, so that some of the variables don't leak across nodes |
| 133 | + function DiscoveryExperimental () {} |
| 134 | + |
| 135 | + // This is the namespace for this version of this Node. |
| 136 | + var disExp = new DiscoveryExperimental(); |
| 137 | + |
| 138 | + //disExp.abc = 'abc'; |
| 139 | + disExp.hideAll = function() { |
| 140 | + $('#node-input-environmentname').parent().hide(); |
| 141 | + $('#node-input-environment_id').parent().hide(); |
| 142 | + $('#node-input-collection_id').parent().hide(); |
| 143 | + }; |
| 144 | + |
| 145 | + disExp.processSelectedMethod = function(method) { |
| 146 | + disExp.hideAll(); |
| 147 | + switch (method) { |
| 148 | + case 'listEnvrionments': |
| 149 | + $('#node-input-environmentname').parent().show(); |
| 150 | + break; |
| 151 | + case 'getEnvironmentDetails': |
| 152 | + case 'listCollections': |
| 153 | + $('#node-input-environment_id').parent().show(); |
| 154 | + break; |
| 155 | + case 'getCollectionDetails': |
| 156 | + $('#node-input-environment_id').parent().show(); |
| 157 | + $('#node-input-collection_id').parent().show(); |
| 158 | + break; |
| 159 | + } |
| 160 | + } |
| 161 | + |
| 162 | + disExp.UIListeners = function () { |
| 163 | + $('#node-input-discovery-method').change(function(val){ |
| 164 | + var method = $('#node-input-discovery-method').val(); |
| 165 | + disExp.processSelectedMethod(method); |
| 166 | + }); |
| 167 | + } |
| 168 | + |
| 169 | + disExp.checkForPrepare = function () { |
| 170 | + disExp.hideAll(); |
| 171 | + disExp.UIListeners(); |
| 172 | + }; |
| 173 | + |
| 174 | + // This is the on edit prepare function, which will be invoked everytime the dialog is shown. |
| 175 | + function oneditprepare() { |
| 176 | + disExp.checkForPrepare(); |
| 177 | + $.getJSON('watson-discovery/vcap/') |
| 178 | + .done(function (service) { |
| 179 | + $('.credentials').toggle(!service); |
| 180 | + }) |
| 181 | + .fail(function () { |
| 182 | + $('.credentials').show(); |
| 183 | + }).always(function () { |
| 184 | + $('#credentials-check').hide(); |
| 185 | + }) |
| 186 | + } |
| 187 | + |
65 | 188 | (function() {
|
66 | 189 | RED.nodes.registerType('watson-discovery', {
|
67 |
| - category: 'IBM Watson', |
| 190 | + category: 'Watson Deprecated', |
68 | 191 | defaults: {
|
69 | 192 | name: {value: ""},
|
70 |
| - envrionmentname: {value: ""} |
| 193 | + environmentname: {value: ""}, |
| 194 | + environment_id: {value: ""}, |
| 195 | + collection_id: {value: ""}, |
| 196 | + "discovery-method": {value:"listEnvrionments"} |
71 | 197 | },
|
72 | 198 | credentials: {
|
73 | 199 | username: {type:"text"},
|
|
84 | 210 | labelStyle: function() {
|
85 | 211 | return this.name ? "node_label_italic" : "";
|
86 | 212 | },
|
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 |
| - } |
| 213 | + oneditprepare: oneditprepare |
98 | 214 | });
|
99 | 215 | })();
|
100 | 216 | </script>
|
0 commit comments