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"}} {{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 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 class="legend_container">
<div id="smoother" title="Smoothing"></div> <div id="smoother" title="Smoothing"></div>
<div id="legend"></div> <div id="legend"></div>
</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 class="custom_x_axis">Time</div>
</div> </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 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 class="legend_container">
<div id="smoother" title="Smoothing"></div> <div id="smoother" title="Smoothing"></div>
<div id="legend2"></div> <div id="legend2"></div>
</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 class="custom_x_axis">Time</div>
</div> </div>
</div> </div>

@ -35,16 +35,16 @@ function onRequest(context) {
if (tokenPair) { if (tokenPair) {
token = tokenPair.accessToken; 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; + "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; + "deviceId=" + device.deviceIdentifier + "&deviceType=" + device.type+ "&websocketToken=" + token;
var websocketToken= {'name':'websocket-token','value': token, 'path':'/', "maxAge":18000}; var websocketToken= {'name':'websocket-token','value': token, 'path':'/', "maxAge":18000};
response.addCookie(websocketToken); response.addCookie(websocketToken);
} }
return { return {
"device": device, "device": device,
"websocketEndpoint1": websocketEndpoint1, "websocketEndpointTemperature": websocketEndpointTemperature,
"websocketEndpoint2": websocketEndpoint2 "websocketEndpointCoffeeLevel": websocketEndpointCoffeeLevel
}; };
} }

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

Loading…
Cancel
Save