diff options
Diffstat (limited to 'datastore-leveldb/wwwroot_ebus/src')
-rw-r--r-- | datastore-leveldb/wwwroot_ebus/src/ebus.js | 64 |
1 files changed, 35 insertions, 29 deletions
diff --git a/datastore-leveldb/wwwroot_ebus/src/ebus.js b/datastore-leveldb/wwwroot_ebus/src/ebus.js index fae08cd..eb0cb2d 100644 --- a/datastore-leveldb/wwwroot_ebus/src/ebus.js +++ b/datastore-leveldb/wwwroot_ebus/src/ebus.js @@ -27,7 +27,7 @@ $(document).ready(function(){ var indexFound = null; var defaultSensorConfigList = [ { - "name":"heizkreisregler10.betriebsdatenRegler1.kesselTemperatur", + "id":"heizkreisregler10.betriebsdatenRegler1.kesselTemperatur", "description":"Kessel Temperatur", "values":Math.ceil(jQuery("#ebusgraph").width()/6), "lines":{fill: true, lineWidth: 1, fillColor: "rgba(80,40,100, 0.05)"}, @@ -35,7 +35,7 @@ $(document).ready(function(){ "color":"rgb(80,40,100)" }, { - "name":"heizkreisregler9.solarDaten.tempKollektor", + "id":"heizkreisregler9.solarDaten.tempKollektor", "description":"Kollektortemperatur", "lines":{fill: true, fillColor: "rgba(255, 0, 0, 0.4)"}, "values":Math.ceil(jQuery("#ebusgraph").width()/1), @@ -43,7 +43,7 @@ $(document).ready(function(){ "color":"#f30000" }, { - "name":"heizkreisregler9.solarDaten.tempWarmwasserSolar", + "id":"heizkreisregler9.solarDaten.tempWarmwasserSolar", "description":"Warmwasser Solar", "lines":{fill: true, fillColor: "rgba(252,133,30,0.1)"}, "values":Math.ceil(jQuery("#ebusgraph").width()/8), @@ -51,14 +51,14 @@ $(document).ready(function(){ "color":"rgba(252,133,34,0.5)" }, { - "name":"heizkreisregler10.betriebsdatenRegler1.boilerTemperatur", + "id":"heizkreisregler10.betriebsdatenRegler1.boilerTemperatur", "description":"Boilertemperatur", "values":Math.ceil(jQuery("#ebusgraph").width()/8), "show":false, "color":"#48b4ff" }, { - "name":"de.wettermichel.temperature", + "id":"de.wettermichel.temperature", "description":"Temperatur (Celsius) (wettermichel)", "show":false, "values":Math.ceil(jQuery("#ebusgraph").width()/4), @@ -66,7 +66,7 @@ $(document).ready(function(){ "color":"#84b500" }, { - "name":"dockstar.load5", + "id":"dockstar.load5", "description":"System Load (5m, *10)", "lines":{lineWidth:1}, "show":false, @@ -74,7 +74,7 @@ $(document).ready(function(){ "mapFunc":function(d){return [d[0],d[1]*10]} }, { - "name":"dockstar.internet.latency_ns", + "id":"dockstar.internet.latency_ns", "description":"Internet latency in ms", "lines":{lineWidth:1}, "show":false, @@ -84,10 +84,10 @@ $(document).ready(function(){ ]; var sensorConfigList = JSON.parse(window.localStorage.getItem("ebusConfig")) || defaultSensorConfigList; -var pickSensorConfig = function(sensorname) { +var pickSensorConfig = function(sensorid) { var sensorConfigFound; $.each(sensorConfigList, function(i,sensorConfig) { - if (sensorConfig["name"] == sensorname) { + if (sensorConfig["id"] == sensorid) { sensorConfigFound = sensorConfig; return false; } @@ -113,20 +113,26 @@ var redrawLegend = function() { var checkbox = jQuery("<input>").attr("type","checkbox").appendTo(colorBoxBox); checkbox.attr("checked", config.show); checkbox.css({opacity:0.6}); - checkbox.data("name", config.name); + checkbox.data("id", config.id); checkbox.click(function() { - var config = pickSensorConfig($(this).data("name")); + var config = pickSensorConfig($(this).data("id")); config.show = $(this).prop("checked"); if (config.show) { plotSensor(config); } else { - unplotSensor(config.name); + unplotSensor(config.id); } }); var label = jQuery("<td>").addClass("legendLabel").appendTo(row); jQuery("<span>").text(sensorConfigList[i].description).appendTo(label); - + jQuery("<button>").css({padding:0,border:"1px solid gray",width:20,height:20}).text("X").appendTo(label).click(function(){ + var configId = jQuery(this).data("configId"); + sensorConfigList = jQuery(sensorConfigList).filter(function(i,config) { + return config.id != configId; + }).toArray(); + init(); + }).data("configId", config.id); table.append(row); } $("#legend").append($("<button>").text("Reset").click(function(){ @@ -142,10 +148,10 @@ var redrawLegend = function() { } }); $("#legend").append($("<button>").text("Add").click(function(){ - var name = select.val(); - var namePath = name.split("."); - var desc = window.prompt("Beschreibung des Datensatzes", namePath[namePath.length-1]); - var config = { "name":name, + var id = select.val(); + var idPath = id.split("."); + var desc = window.prompt("Beschreibung des Datensatzes: "+id, idPath[idPath.length-1]); + var config = { "id":id, "description": desc, "show":true, "lines": {fill: false, lineWidth:1}, @@ -169,15 +175,15 @@ var plotSensor = function(sensorConfig) { plotSensorDetail(sensorConfig); plotSensorOverview(sensorConfig); }; -var unplotSensor = function(sensorname) { +var unplotSensor = function(sensorid) { window.localStorage.setItem("ebusConfig", JSON.stringify(sensorConfigList)); - unplotSensorDetail(sensorname); - unplotSensorOverview(sensorname); + unplotSensorDetail(sensorid); + unplotSensorOverview(sensorid); }; var plotSensorDetail = function(sensorConfig) { jQuery("#ebusgraph").animate({opacity:0.2}, 200); var values = sensorConfig.values || plotDetail.width(); - $.getJSON("/api/range/"+escape(sensorConfig["name"])+"/"+from+"/"+to+"/" + values, + $.getJSON("/api/range/"+escape(sensorConfig["id"])+"/"+from+"/"+to+"/" + values, function(response) { if (!response.error) { response.data = response.data.map(function(d) { @@ -187,7 +193,7 @@ var plotSensorDetail = function(sensorConfig) { response.data = response.data.map( sensorConfig.mapFunc ) } datasetDetail.push({"data":response["data"], - "userData":sensorConfig["name"], + "userData":sensorConfig["id"], "lines":sensorConfig.lines || {}, "label":sensorConfig.description, "color":sensorConfig.color}); @@ -203,9 +209,9 @@ var plotSensorDetail = function(sensorConfig) { }); }; -var unplotSensorDetail = function(sensorname) { +var unplotSensorDetail = function(sensorid) { $.each(datasetDetail, function(i, sensor) { - if (sensor["userData"] == sensorname) { + if (sensor["userData"] == sensorid) { datasetDetail.splice(i,1); replot(); return false; @@ -215,7 +221,7 @@ var unplotSensorDetail = function(sensorname) { var plotSensorOverview = function(sensorConfig) { var values = sensorConfig.values || plotOverview.width(); - $.getJSON("api/range/"+escape(sensorConfig["name"])+"/"+fromOverview+"/"+toOverview+ "/" + values, + $.getJSON("api/range/"+escape(sensorConfig["id"])+"/"+fromOverview+"/"+toOverview+ "/" + values, function(response) { if (!response.error) { response.data = response.data.map(function(d) { @@ -225,8 +231,8 @@ var plotSensorOverview = function(sensorConfig) { response.data = response.data.map( sensorConfig.mapFunc) } datasetOverview.push({"data":response["data"], - "userData":sensorConfig["name"], - "label":sensorConfig["name"], + "userData":sensorConfig["id"], + "label":sensorConfig["id"], "color":sensorConfig.color}); replotOverview(); } else { @@ -235,9 +241,9 @@ var plotSensorOverview = function(sensorConfig) { }); }; -var unplotSensorOverview = function(sensorname) { +var unplotSensorOverview = function(sensorid) { $.each(datasetOverview, function(i, sensor) { - if (sensor["userData"] == sensorname) { + if (sensor["userData"] == sensorid) { datasetOverview.splice(i,1); replotOverview(); return false; |