diff --git a/client/jsFiles/SEAWebClientGraphics.js b/client/jsFiles/SEAWebClientGraphics.js index c979eae..0e03473 100644 --- a/client/jsFiles/SEAWebClientGraphics.js +++ b/client/jsFiles/SEAWebClientGraphics.js @@ -323,14 +323,10 @@ let curvesSettingsPopup = undefined; function loadCurvesSettingsPopup(){ let graphsContainer = document.getElementsByClassName("graphs-container")[0]; - curvesSettingsPopup = new CurvesSettingsPopup(applySettingsCallback); + curvesSettingsPopup = new CurvesSettingsPopup(graphs.applySettingsCallback); graphsContainer.appendChild(curvesSettingsPopup); } -function applySettingsCallback(userConfiguration){ - console.log(JSON.stringify(userConfiguration)); -} - let graphs = (function (){ let dataset_to_graph_map = {}; // a dictionnary mapping a variable name to a two values array, containing its graph index and its position inside the graph let blocks, liveMode=true, top_vars=[], bottom_vars=[]; @@ -1213,6 +1209,24 @@ let graphs = (function (){ exportPopup.show(blocks,currentMinTime, currentMaxTime); } + function applySettingsCallback(userConfiguration){ + cursorLine(null); + + AJAX("http://" + hostPort + "/getvars?time=" + currentMinTime/1000 + "," + currentMaxTime/1000 + "&userconfiguration=" + JSON.stringify(userConfiguration) + "&id="+ clientID).getJSON().then(function(data){ + blocks = data.blocks; + document.getElementById("device").innerHTML = data.device + maxTime = currentMaxTime; + minTime = currentMinTime; + + globalIndicators.getIndicatorsMap()[datesKey].update(currentMinTime); + + ngraphs = 0; // forces all the graphs to reset + createGraphs(); + + if (liveMode && currentMaxTime < lastTime) setLiveMode(false); + }); + } + /** * Make sure that the updatAuto() function called in chartJS' onZoomComplete callback is delayed * This is needed for mobile phones, as this callback is triggered too often @@ -1257,7 +1271,8 @@ let graphs = (function (){ initGraphs: initGraphs, onZoomCompleteCallback:onZoomCompleteCallback, - displayExportPopup:displayExportPopup + displayExportPopup:displayExportPopup, + applySettingsCallback:applySettingsCallback } })(); diff --git a/influxgraph.py b/influxgraph.py index 5ddc3e7..54e522f 100644 --- a/influxgraph.py +++ b/influxgraph.py @@ -113,7 +113,7 @@ class InfluxGraph: time = [float(t) for t in time.split(',')] return dict(type='time', time= self.get_abs_time(time)) - def w_getvars(self, time): + def w_getvars(self, time, userconfiguration = None): """ Gets the curve names available at a given point in time. Called when the route /getvars is reached. @@ -130,8 +130,10 @@ class InfluxGraph: time = [float(t) for t in time.split(',')] start_time = int(self.get_abs_time(time)[0]) end_time = int(self.get_abs_time(time)[-1]) + + if not userconfiguration == None : userconfiguration = json.loads(userconfiguration) - blocks = self.influx_data_getter.get_available_variables_at_time([start_time, end_time], self.chart_configs) + blocks = self.influx_data_getter.get_available_variables_at_time([start_time, end_time], self.chart_configs, userconfiguration) device_name = self.influx_data_getter.get_device_name(end_time) # updates the self.variables attribute to keep track of the available variables self.variables = {variable["name"]:variable["label"] for block in blocks for variable in block["curves"]}