added timeout on updateAuto (zoomComplete) to prevent request stacking on mobile phones
This commit is contained in:
@ -292,6 +292,7 @@ let graphs = (function (){
|
|||||||
|
|
||||||
let created = false;
|
let created = false;
|
||||||
let activateUpdateTimeout = undefined;
|
let activateUpdateTimeout = undefined;
|
||||||
|
let updateAutoTimeout = undefined;
|
||||||
|
|
||||||
let container = document.createElement('div');
|
let container = document.createElement('div');
|
||||||
container.classList.add("graphs-container");
|
container.classList.add("graphs-container");
|
||||||
@ -1258,6 +1259,19 @@ let graphs = (function (){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onZoomCompleteCallback(){
|
||||||
|
if (updateAutoTimeout === undefined){
|
||||||
|
updateAutoTimeout = setTimeout(function() {
|
||||||
|
updateAuto();
|
||||||
|
updateAutoTimeout = undefined;
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
clearTimeout(updateAutoTimeout);
|
||||||
|
updateAutoTimeout = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
addDataset: addDataset,
|
addDataset: addDataset,
|
||||||
//toggleAxesType: toggleAxesType,
|
//toggleAxesType: toggleAxesType,
|
||||||
@ -1291,6 +1305,7 @@ let graphs = (function (){
|
|||||||
shiftNewer: shiftNewer,
|
shiftNewer: shiftNewer,
|
||||||
jumpToDate: jumpToDate,
|
jumpToDate: jumpToDate,
|
||||||
initGraphs: initGraphs,
|
initGraphs: initGraphs,
|
||||||
|
onZoomCompleteCallback:onZoomCompleteCallback,
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@ -1431,7 +1446,7 @@ function Graph(gindex, container, x_label, y_label, tag, scaleType = "linear"){
|
|||||||
sensitivity: 1,
|
sensitivity: 1,
|
||||||
onZoom: function({chart}) { graphs.zoomCallback(chart.graph);},
|
onZoom: function({chart}) { graphs.zoomCallback(chart.graph);},
|
||||||
//onZoomComplete: function({chart}){graphs.checkReload(chart.graph);redraw()},
|
//onZoomComplete: function({chart}){graphs.checkReload(chart.graph);redraw()},
|
||||||
onZoomComplete: function({chart}){graphs.updateAuto();},
|
onZoomComplete: function({chart}){graphs.onZoomCompleteCallback()},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -121,6 +121,7 @@ class InfluxDataGetter:
|
|||||||
variable_name_for_query = variable_name_for_query[:-len(".target")]
|
variable_name_for_query = variable_name_for_query[:-len(".target")]
|
||||||
is_target = True
|
is_target = True
|
||||||
start_time = int(lastvalues[variable_name_for_query][0]) if variable_name_for_query in lastvalues.keys() else None
|
start_time = int(lastvalues[variable_name_for_query][0]) if variable_name_for_query in lastvalues.keys() else None
|
||||||
|
start_time = start_time if start_time != None and start_time <= end_time else None # to prevent self.lastvalues being changed by w_graph between entrance of graphpoll and poll_last_values
|
||||||
points = self._get_last_values(variable_name_for_query, is_target,start_time, end_time)
|
points = self._get_last_values(variable_name_for_query, is_target,start_time, end_time)
|
||||||
if len(points) > 0 :
|
if len(points) > 0 :
|
||||||
res[variable] = points
|
res[variable] = points
|
||||||
|
Reference in New Issue
Block a user