Adding coffee level graph to realtime-analytics view

application-manager-new
thisaripatabendi 8 years ago
parent 9b26660971
commit a5154cf269

@ -17,26 +17,26 @@
}}
{{unit "cdmf.unit.lib.rickshaw-graph"}}
<div id="div-chart" data-websocketurl="{{websocketEndpoint1}}" data-sensorType="temperature">
<div id="div-chartTemperature" data-websocketurl="{{websocketEndpointTemperature}}" data-sensorType="temperature">
<div class="chartWrapper" id="chartWrapper">
<div id="y_axis" class="custom_y_axis" style="margin-top: -20px;">Temperature</div>
<div id="y_axisTemperature" class="custom_y_axis" style="margin-top: -20px;">Temperature</div>
<div class="legend_container">
<div id="smoother" title="Smoothing"></div>
<div id="legend"></div>
</div>
<div id="chart" class="custom_rickshaw_graph"></div>
<div id="chartTemperature" class="custom_rickshaw_graph"></div>
<div class="custom_x_axis">Time</div>
</div>
</div>
<div id="div-chart2" data-websocketurl="{{websocketEndpoint2}}" data-sensorType="coffeelevel">
<div id="div-chartCoffeeLevel" data-websocketurl="{{websocketEndpointCoffeeLevel}}" data-sensorType="coffeelevel">
<div class="chartWrapper" id="chartWrapper">
<div id="y_axis2" class="custom_y_axis" style="margin-top: -20px;">Coffee Level</div>
<div id="y_axisCoffeeLevel" class="custom_y_axis" style="margin-top: -20px;">Coffee Level</div>
<div class="legend_container">
<div id="smoother" title="Smoothing"></div>
<div id="legend2"></div>
</div>
<div id="chart2" class="custom_rickshaw_graph"></div>
<div id="chartCoffeeLevel" class="custom_rickshaw_graph"></div>
<div class="custom_x_axis">Time</div>
</div>
</div>

@ -35,16 +35,16 @@ function onRequest(context) {
if (tokenPair) {
token = tokenPair.accessToken;
}
websocketEndpoint1 = websocketEndpoint + "/secured-websocket/org.wso2.iot.devices.temperature/1.0.0?"
websocketEndpointTemperature = websocketEndpoint + "/secured-websocket/org.wso2.iot.devices.temperature/1.0.0?"
+ "deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type+ "&websocketToken=" + token;
websocketEndpoint2 = websocketEndpoint + "/secured-websocket/org.wso2.iot.devices.coffeelevel/1.0.0?"
websocketEndpointCoffeeLevel = websocketEndpoint + "/secured-websocket/org.wso2.iot.devices.coffeelevel/1.0.0?"
+ "deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type+ "&websocketToken=" + token;
var websocketToken= {'name':'websocket-token','value': token, 'path':'/', "maxAge":18000};
response.addCookie(websocketToken);
}
return {
"device": device,
"websocketEndpoint1": websocketEndpoint1,
"websocketEndpoint2": websocketEndpoint2
"websocketEndpointTemperature": websocketEndpointTemperature,
"websocketEndpointCoffeeLevel": websocketEndpointCoffeeLevel
};
}

@ -16,25 +16,25 @@
* under the License.
*/
var wsConnection1;
var wsConnection2;
var graphForSensorType1;
var graphForSensorType2;
var chartDataSensorType1 = [];
var chartDataSensorType2 = [];
var wsConnectionTemperature;
var wsConnectionCoffeeLevel;
var graphForSensorTypeTemperature;
var graphForSensorTypeCoffeeLevel;
var chartDataSensorTypeTemperature = [];
var chartDataSensorTypeCoffeeLevel = [];
var palette = new Rickshaw.Color.Palette({scheme: "classic9"});
$(window).load(function () {
drawGraph(wsConnection1, "#div-chart", "y_axis", "chart", chartDataSensorType1
, graphForSensorType1);
drawGraph(wsConnection2, "#div-chart2", "y_axis2", "chart2", chartDataSensorType2
, graphForSensorType2);
drawGraph(wsConnectionTemperature, "#div-chartTemperature", "y_axisTemperature", "chartTemperature", chartDataSensorTypeTemperature
, graphForSensorTypeTemperature);
drawGraph(wsConnectionCoffeeLevel, "#div-chartCoffeeLevel", "y_axisCoffeeLevel", "chartCoffeeLevel", chartDataSensorTypeCoffeeLevel
, graphForSensorTypeCoffeeLevel);
});
window.onbeforeunload = function() {
disconnect(wsConnection1);
disconnect(wsConnection2);
disconnect(wsConnectionTemperature);
disconnect(wsConnectionCoffeeLevel);
};
function drawGraph(wsConnection, placeHolder, yAxis, chat, chartData, graph) {

Loading…
Cancel
Save