From 0a334345e9530dd217cf74a414afe43322181fe0 Mon Sep 17 00:00:00 2001 From: Ebus-at-dockstar Date: Fri, 8 Mar 2013 18:51:40 +0100 Subject: ui: root/diskfree sensors. --- ebus/webhdf/static/src/ebus.js | 59 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 11 deletions(-) (limited to 'ebus/webhdf/static/src') diff --git a/ebus/webhdf/static/src/ebus.js b/ebus/webhdf/static/src/ebus.js index 5c4fa16..5256288 100644 --- a/ebus/webhdf/static/src/ebus.js +++ b/ebus/webhdf/static/src/ebus.js @@ -19,15 +19,44 @@ $(document).ready(function(){ var plotOverview = null; var plotDetail = null; var indexFound = null; - var sensorConfigList = [{"sensorname":"heizkreisregler9.solarDaten.tempKollektor","show":true, "color":"#f30000"}, - {"sensorname":"heizkreisregler10.betriebsdatenRegler1.kesselTemperatur","show":true, "color":"#283074"}, - {"sensorname":"heizkreisregler9.solarDaten.tempWarmwasserSolar","show":false, "color":"#f0ff4c"}, - {"sensorname":"feuerungsautomat1.betriebsdatenRegler1.aussenTemperatur","show":false, "color":"#84b500"}, - // {"sensorname":"de.wettermichel.temperature","show":true, "color":"#24f590"}, - {"sensorname":"heizkreisregler10.betriebsdatenRegler1.boilerTemperatur","show":true, "color":"#48b4ff"}]; + var sensorConfigList = [ + {"sensorname":"heizkreisregler9.solarDaten.tempKollektor", + "description":"Kollektortemperatur", + "show":true, + "color":"#f30000"}, + {"sensorname":"heizkreisregler10.betriebsdatenRegler1.kesselTemperatur", + "description":"Kessel Temperatur", + "show":true, + "color":"#283074"}, + {"sensorname":"heizkreisregler9.solarDaten.tempWarmwasserSolar", + "description":"Warmwasser Solar", + "show":false, + "color":"#f0ff4c"}, + {"sensorname":"feuerungsautomat1.betriebsdatenRegler1.aussenTemperatur", + "description":"Aussentemperatur", + "show":false, + "color":"#84b500"}, + {"sensorname":"dockstar.load5", + "description":"System Load (5m, *10)", + "show":false, + "color":"blue", + "mapFunc":function(d){return [d[0],d[1]*10]}}, + {"sensorname":"dockstar.diskfree.rootfs", + "description":"Rootfs free percent", + "show":false, + "color":"red"}, + {"sensorname":"heizkreisregler10.betriebsdatenRegler1.boilerTemperatur", + "description":"Boilertemperatur", + "show":true, + "color":"#48b4ff"}, + {"sensorname":"feuerungsautomat1.betriebsdatenRegler1.kesselTemperatur", + "description":"Kesseltemperatur", + "show":false, + "color":"blue"} + ]; var pickSensorConfig = function(sensorname) { - var SensorConfigFound; + var sensorConfigFound; $.each(sensorConfigList, function(i,sensorConfig) { if (sensorConfig.sensorname == sensorname) { sensorConfigFound = sensorConfig; @@ -83,8 +112,12 @@ $(document).ready(function(){ response.data = response.data.map(function(d) { return [ tzFix(d[0]*1000), d[1] ]; }); + if (sensorConfig.mapFunc) { + response.data = response.data.map( sensorConfig.mapFunc ) + } datasetDetail.push({'data':response['data'], - 'label':sensorConfig.sensorname, + 'userData':sensorConfig.sensorname, + 'label':sensorConfig.description, 'color':sensorConfig.color}); replot(); } else { @@ -95,7 +128,7 @@ $(document).ready(function(){ var unplotSensorDetail = function(sensorname) { $.each(datasetDetail, function(i, sensor) { - if (sensor.label == sensorname) { + if (sensor.userData == sensorname) { datasetDetail.splice(i,1); replot(); return false; @@ -110,6 +143,9 @@ $(document).ready(function(){ response.data = response.data.map(function(d) { return [ tzFix(d[0]*1000), d[1] ]; }); + if (sensorConfig.mapFunc) { + response.data = response.data.map( sensorConfig.mapFunc) + } datasetOverview.push({'data':response['data'], 'label':sensorConfig.sensorname, 'color':sensorConfig.color}); @@ -144,7 +180,7 @@ $(document).ready(function(){ } sensors = []; for (elem in datasetOverview) { - sensor = datasetDetail[elem]["label"]; + sensor = datasetDetail[elem]["userData"]; sensors.push(sensor); } datasetDetail =[]; @@ -160,7 +196,7 @@ $(document).ready(function(){ var pickerCheckbox = $("").attr("type","checkbox") .appendTo(pickerDiv); - $(pickerDiv).append(sensorConfig.sensorname); + pickerDiv.append($("").text( sensorConfig.description + " (" + sensorConfig.sensorname + ")") ); if (sensorConfig.show) { //Plot plotSensor(sensorConfig); @@ -173,6 +209,7 @@ $(document).ready(function(){ $('.picker input').click( function() { var sensorname = $(this).parent().attr("id").replace("pick_","").replace(/_/g,"."); if ($(this).is(":checked")) { + console.log(sensorname); plotSensor(pickSensorConfig(sensorname)); } else { unplotSensor(sensorname); -- cgit v1.2.1