UNPKG

node-red-contrib-snap4city-user

Version:

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

133 lines (122 loc) 5.34 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/javascript"> RED.nodes.registerType('save-my-kpidata-values', { category: 'S4CKPIData', color: '#b0dfe3', defaults: { name: { value: "" }, kpiId: { value: "" }, selectedKPIDataId: { value: "" }, authentication: { type: "snap4city-authentication", required: false } }, outputs: 1, inputs: 1, icon: "white-globe.png", label: function () { return this.name || "save-my-kpidata-values"; }, oneditprepare: function () { $("#node-input-currentNodeId").val(this.id); initChangeAuthenticationKPIData(); $("#node-input-authentication").change(function () { initChangeAuthenticationKPIData(); }); }, oneditsave: function () { $("#node-input-selectedKPIDataId").val($("#node-input-kpiId").val()); $("#node-input-name").val("Save on " + $("#node-input-kpiId").val().split("-")[1]); } }); </script> <script type="text/x-red" data-template-name="save-my-kpidata-values"> <input type="hidden" id="node-input-name"> <input type="hidden" id="node-input-currentNodeId"> <input type="hidden" id="node-input-selectedKPIDataId"> <div class="form-row" id="rowAuthentication"> <label for="node-input-authentication">Authentication</label> <input type="text" id="node-input-authentication"> </div> <div class="form-row" id="selectKpiDataContainer"> <label for="node-input-kpiId"> <i class="fa fa-dashboard"></i>Select KPI</label> <select id="node-input-kpiId" style="width: 55%;"> </select> </div> <div class="form-tips" id="tipAuthentication" style="max-width: none"> You must have an account with Snap4city to use this node. You can register for one <a href="https://www.snap4city.org" target="_blank">here</a>. </div> <div class="form-tips" id="tipAuthenticationWrong" style="display:none; max-width: none"> Maybe the authentication data are wrong. Check them and redeploy the node. </div> <div class="form-tips" id="tipAuthenticationRedeploy" style="display:none; max-width: none"> Deploy the node to retrieve the updated list of dashboards. </div> <div class="form-tips" id="tipAuthenticationDeployFirstTime" style="display:none; max-width: none"> Insert the authentication data and deploy the node to retrieve the updated list of dashboards. </div> </script> <script type="text/x-red" data-help-name="save-my-kpidata-values"> <p>It allows to save the personal data inserted in My Personal KPI Data.</p> <h3>Inputs</h3> A JSON with these parameters: <dl class="message-properties"> <dt>id <span class="property-type">number</span> </dt> <dd> the id of the kpi data (you MUST have the ownership of the kpi data)</dd> <dt>value <span class="property-type">depends on kpi</span> </dt> <dd> value to save in selected kpi data</dd> <dt>latitude <span class="property-type">float</span> </dt> <dd> (optional) if you want to add gps metadata to the value</dd> <dt>longitude <span class="property-type">float</span> </dt> <dd> (optional) if you want to add gps metadata to the value</dd> <dt>datatime <span class="property-type">date</span> </dt> <dd> (optional) if you want to insert the data of the value in the format yyyy-MM-ddTHH:mmX (where X is the timezone) or timestamp</dd> </dl> <p>An example of the JSON array filled with correct data:</p> <pre> { "id": 17849, "datatime": "2020-04-14T16:30Z", "latitude": 43.11, "longitude": 11.34, "value": 5 } </pre> <h3>Outputs</h3> <dl class="message-properties"> <dd> Returns an array containing the data that have been saved in the search period</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>