luci-app-statistics: regenerate graphs on window resize

Currently graphs are redrawn only based on the refresh interval
(never or every 5/30/60 seconds).
Since the image size is calculated based on the window size,
redraw graphs (once) also after resizing the window.
This also captures window resize due to orientation change
(e.g., for mobile).
Since multiple resize events are fired when dragging the window
border, there is a 250ms delay for debouncing.

Signed-off-by: Rani Hod <rani.hod@gmail.com>
Tested-by: Paul Donald <newtwen@gmail.com>
This commit is contained in:
Rani Hod 2023-10-02 18:01:54 +03:00 committed by Paul Donald
parent 1e84a03932
commit 8fcd52f513

View file

@ -244,6 +244,10 @@ return view.extend({
requestAnimationFrame(L.bind(this.updateGraphs, this, hostSel, spanSel, timeSel, graphDiv));
var resizeTimeout;
var rgCallback = L.bind(this.refreshGraphs, this, hostSel, spanSel, timeSel, graphDiv);
addEventListener('resize', function() { clearTimeout(resizeTimeout); resizeTimeout = setTimeout(rgCallback, 250); });
return view;
},