node-red-contrib-snap4city-user
Version:
Nodes for Snap4city project, targeted to standard user (no developer)
113 lines (103 loc) • 4.82 kB
HTML
<!--/* 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('event-driven-my-kpi', {
category: 'S4CDashboard',
color: '#00a2d3',
defaults: {
name: {
value: ""
},
kpiId: {
value: ""
},
whenValueChange: {
value: false
},
selectedKPIDataId: {
value: ""
},
authentication: {
type: "snap4city-authentication",
required: false
}
},
outputs: 1,
inputs: 0,
icon: "link-out.png",
label: function () {
return this.name || "event-driven-my-kpi";
},
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("Value of my " + $("#node-input-kpiId").val().split("-")[1]);
}
});
</script>
<script type="text/x-red" data-template-name="event-driven-my-kpi">
<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>
<div class="form-row">
<label>Socket Mode</label>
<input type="checkbox" id="node-input-whenValueChange" style="display: inline-block; width: auto; vertical-align: top;">
<label style="width: 70%;">
<span>when value change</span>
</label>
</div>
</script>
<script type="text/x-red" data-help-name="event-driven-my-kpi">
<p>Shows an output message when the value of the KPI chosen in configuration is modified inside a dashboard, with a widget made in svg.</p>
<h3>Configuration</h3>
<dl class="message-properties">
<dt>when value change
<span class="property-type">checkbox</span>
</dt>
<dd>Selects the event to be observed on the selected KPI.
If this checkbox is selected then a message is output only if the KPI value is changed from the previous one.
If the checkbox is not selected then a message is output even if a value that is equal to the previous one but with a different timestamp is saved on the KPI. It decides the granularity of the incoming messages.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dd> KPI data that has been observed, in particular should change the lastDate and lastValue, for each message</dd>
</dl>
</script>