UNPKG

node-red-contrib-snap4city-user

Version:

Nodes for Snap4city project, targeted to standard user (no developer)

190 lines (177 loc) 8.85 kB
<!--/* NODE-RED-CONTRIB-SNAP4CITY-USER Copyright (C) 2018 DISIT Lab http://www.disit.org - University of Florence This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */--> <script type="text/x-red" data-template-name="service-info"> <div class="form-row" id="rowAuthentication"> <label for="node-input-authentication">Authentication</label> <input type="text" id="node-input-authentication"> </div> <div class="form-tips" id="tipAuthentication" style="margin-bottom: 10px;"> If you have private data and you want to access them, you must have to insert you account data. You can register for one account <a href="https://www.snap4city.org" target="_blank">here</a>. </div> <div class="form-row"> <label for="node-input-typeQuery">Type Query:</label> <select id="node-input-typeQuery"> <option value="point-of-interest" selected>point-of-interest</option> <option value="entity">entity</option> </select> </div> <div class="form-row"> <label for="node-input-name">Name</label> <input type="text" autocomplete="off" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-serviceuri">ServiceUri</label> <input type="text" autocomplete="off" id="node-input-serviceuri" placeholder="http://"> </div> <div class="form-row"> <label for="node-input-filter">Filter</label> <input type="text" autocomplete="off" id="node-input-filter" placeholder="Filter"> </div> <div class="form-row"> <label for="node-input-values">Values</label> <input type="text" autocomplete="off" id="node-input-values" placeholder="Values"> </div> <div class="form-row"> <label for="node-input-sortOnValue">SortOnValue</label> <input type="text" autocomplete="off" id="node-input-sortOnValue" placeholder="SortOnValue"> </div> <div class="form-row"> <label for="node-input-lang">Language</label> <select id="node-input-lang"> <option value="en">English</option> <option value="fr">French</option> <option value="de">German</option> <option value="it">Italian</option> <option value="es">Spanish</option> </select> </div> </script> <script type="text/x-red" data-help-name="service-info"> <p>It allows to retrieve information about a service using its serviceUri.</p> <h3>Inputs</h3> A JSON with these parameters: <dl class="message-properties"> <dt>typeQuery <span class="property-type">string</span> </dt> <dd>If "point-of-interest" is selected, the node performs the standard serviceUri search. If "entity" is selected, the node adds value filters to the serviceUri search.</dd> <dt>serviceuri <span class="property-type">string</span> </dt> <dd> serviceUri (http://...) of the service</dd> <dt>filter <span class="property-type">string</span> </dt> <dd>Only for the type "entity", a list of conditions (separated with ;) on value names matching a constant value. The matching operator can be: <ul> <li><em>value name</em>:<em>string value</em> (e.g status:Active), search for devices having the dynamic string attribute "value name" with a specific value, the match is case sensitive</li> <li><em>value name</em>=<em>numeric value</em> (e.g. temperature=18), search for devices having the dynamic numeric attribute "value name" with a specific numeric value.</li> <li><em>value name</em>&gt;<em>numeric value</em> (e.g. temperature&gt;20), search for devices having a dynamic numeric attribute greater than a specific value.</li> <li><em>value name</em>&gt;=<em>numeric value</em> (e.g. temperature&gt;20), search for devices having a dynamic numeric attribute greater or equal than a specific value.</li> <li><em>value name</em>&lt;<em>numeric value</em> (e.g. temperature&lt;20), search for devices having a dynamic numeric attribute less than a specific value.</li> <li><em>value name</em>&lt;=<em>numeric value</em> (e.g. temperature&lt;=20), search for devices having a dynamic numeric attribute less or equal than a specific value.</li> </ul> If multiple conditions are present they are considered in AND.</dd> <dt>values <span class="property-type">string</span> </dt> <dd>Only for the type "entity", if filter is not empty, list of value names (separated by ;) to be returned for each result. If omitted all values are returned.</dd> <dt>sortOnValue <span class="property-type">string</span> </dt> <dd>Only for the type "entity", if filter is not empty, the value name to sort the result. It can be like "value name:asc|desc:type" (e.g. temperature:desc:short), order direction is "asc" if omitted, type can be string, date, long or short.</dd> <dt>lang <span class="property-type">string</span> </dt> <dd> ISO 2 chars language code (e.g. “it”, “en”, “fr”, “de”, “es”) to be used for returned descriptions if available in multiple languages. Currently for languages other than “it” and “en” it returns “en” descriptions. (if parameter is missing “en” is assumed)</dd> </dl> <h3>Outputs</h3> <dl class="message-properties"> <dd> The It provides a GeoJSON description of the service with the main properties (name, address, city, type, etc.) and possibly some time varying properties for some kinds of services (traffic sensors, car park sensors, etc.)</dd> </dl> <h3>Details</h3> <p>The node can receive a JSON with the parameters described in the Inputs section and with them generate the output JSON. If the values are not present in the input JSON, these are read by those in the configuration. If they are not present in either part, an error is generated for the necessary parameters.</p> </script> <script type="text/javascript"> RED.nodes.registerType('service-info', { category: 'S4CUtility', color: '#E9967A', defaults: { name: { value: "" }, authentication: { type: "snap4city-authentication", required: false }, serviceuri: { value: "", required: false }, filter: { value: "", required: false }, values: { value: "", required: false }, sortOnValue: { value: "", required: false }, lang: { value: "", required: false }, fromtime: { value: "1-day", required: false }, typeQuery: { value: "point-of-interest", required: false } }, outputs: 1, inputs: 1, icon: "white-globe.png", label: function () { return this.name || "service-info"; }, oneditprepare: function () { changeSelection(); } }); var changeSelection = function () { $("#node-input-typeQuery").change(function () { var newValue = $(this).val(); if (newValue === "entity") { $("#node-input-filter").prop("disabled", false); $("#node-input-values").prop("disabled", false); $("#node-input-sortOnValue").prop("disabled", false); } else if (newValue === "point-of-interest") { $("#node-input-filter").prop("disabled", true); $("#node-input-values").prop("disabled", true); $("#node-input-sortOnValue").prop("disabled", true); } }).change(); }; </script>