UNPKG

node-red-node-watson

Version:
129 lines (111 loc) 4.85 kB
<!-- Copyright 2016, 2022 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. --> <script type="text/x-red" data-template-name="watson-discovery-v1-document-loader"> <div id="credentials-check" class="form-row"> <div class="form-tips"> <i class="fa fa-question-circle"></i><b> Please wait: </b> Checking for bound service credentials... </div> </div> <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> <div class="form-row credentials" style="display: none;"> <label for="node-input-apikey"><i class="fa fa-key"></i> API Key</label> <input type="password" id="node-input-apikey" placeholder="API Key"></input> </div> <div class="form-row credentials"> <label for="node-input-service-endpoint"><i class="fa fa-tag"></i> Service Endpoint</label> <input type="text" id="node-input-service-endpoint" placeholder="https://gateway.watsonplatform.net/discovery/api"> </div> <div class="form-row"> <label for="node-input-environmentId"><i class="fa fa-tag"></i> Environment ID</label> <input type="text" id="node-input-environmentId" placeholder=""> </div> <div class="form-row"> <label for="node-input-collectionId"><i class="fa fa-tag"></i> Collection ID</label> <input type="text" id="node-input-collectionId" placeholder=""> </div> <div class="form-row"> <label for="node-input-filename"><i class="fa fa-tag"></i> Filename</label> <input type="text" id="node-input-filename" placeholder=""> </div> </script> <script type="text/x-red" data-help-name="watson-discovery-v1-document-loader"> <p>This is the document loader Node for the V1 Watson Discovery service.</p> <p>The node needs an Environment ID and Collection ID as input. </p> <p>If a filename is not provided then one is automatically generated</p> <p>The collection being written to can be overridden by specifying the search ids in <code>msg.discoveryparams.environmentId</code> , <code>msg.discoveryparams.collectionId</code> and <code>msg.discoveryparams.filename</code> </p> <p>The document to be added should be passed in as a data buffer in <code>msg.payload</code> </p> <p>For more information about the Discovery service, read the service <a href="https://console.bluemix.net/docs/services/discovery/index.html">documentation</a>.</p> </script> <script type="text/javascript"> // Need to simulate a namespace, so that some of the variables don't leak across nodes function DiscoveryDocLoaderV1 () {} // This is the namespace for this version of this Node. var disdocV1 = new DiscoveryDocLoaderV1(); disdocV1.UIListeners = function () { } disdocV1.checkForPrepare = function () { disdocV1.UIListeners(); }; // This is the on edit prepare function, which will be invoked everytime the dialog is shown. function oneditprepare() { disdocV1.checkForPrepare(); $.getJSON('watson-discovery-docs/vcap/') .done(function (service) { $('.credentials').toggle(!service); }) .fail(function () { $('.credentials').show(); }).always(function () { $('#credentials-check').hide(); }) } (function() { RED.nodes.registerType('watson-discovery-v1-document-loader', { category: 'IBM Watson', defaults: { name: {value: ''}, environmentId: {value: ''}, collectionId: {value: ''}, filename: {value: ''}, 'service-endpoint' :{value: ''} }, credentials: { apikey: {type:'password'} }, color: 'rgb(230,140,10)', inputs: 1, outputs: 1, icon: 'discovery.png', paletteLabel: 'discovery document loader', label: function() { return this.name || 'discovery document loader'; }, labelStyle: function() { return this.name ? 'node_label_italic' : ''; }, oneditprepare: oneditprepare }); })(); </script>