diff --git a/documentation/changelog.rst b/documentation/changelog.rst index 0f1f68760..b463663b4 100644 --- a/documentation/changelog.rst +++ b/documentation/changelog.rst @@ -10,6 +10,7 @@ v0.13.0 | February XX, 2023 New features ------------- +* Keyboard control over replay [see `PR #562 `_] * The ``FLEXMEASURES_MAX_PLANNING_HORIZON`` config setting can also be set as an integer number of planning steps rather than just as a fixed duration, which makes it possible to schedule further ahead in coarser time steps [see `PR #583 `_] Bugfixes diff --git a/flexmeasures/ui/static/js/replay-utils.js b/flexmeasures/ui/static/js/replay-utils.js index 34b3f266f..2ab52e3c9 100644 --- a/flexmeasures/ui/static/js/replay-utils.js +++ b/flexmeasures/ui/static/js/replay-utils.js @@ -42,3 +42,22 @@ export function updateBeliefs(oldBeliefs, newBeliefs) { // Define the step duration for the replay (value in ms) export var beliefTimedelta = 3600000 + + +/** + * Timer that can be canceled using the optional AbortSignal. + * Adapted from https://www.bennadel.com/blog/4195-using-abortcontroller-to-debounce-settimeout-calls-in-javascript.htm + * MIT License: https://www.bennadel.com/blog/license.htm + */ +export function setAbortableTimeout(callback, delayInMilliseconds, signal) { + signal?.addEventListener( "abort", handleAbort ); + var internalTimer = setTimeout(internalCallback, delayInMilliseconds); + + function internalCallback() { + signal?.removeEventListener( "abort", handleAbort ); + callback(); + } + function handleAbort() { + clearTimeout( internalTimer ); + } +} diff --git a/flexmeasures/ui/templates/base.html b/flexmeasures/ui/templates/base.html index 2099f300f..6807f2647 100644 --- a/flexmeasures/ui/templates/base.html +++ b/flexmeasures/ui/templates/base.html @@ -231,7 +231,7 @@ {% endblock sensorChartSetup %} diff --git a/flexmeasures/ui/templates/crud/asset.html b/flexmeasures/ui/templates/crud/asset.html index 9203a6ad6..a128a07c0 100644 --- a/flexmeasures/ui/templates/crud/asset.html +++ b/flexmeasures/ui/templates/crud/asset.html @@ -158,7 +158,7 @@

All sensors for {{ asset.name }}

-
+
diff --git a/flexmeasures/ui/templates/views/sensors.html b/flexmeasures/ui/templates/views/sensors.html index 7d9e6f785..a031ca4ef 100644 --- a/flexmeasures/ui/templates/views/sensors.html +++ b/flexmeasures/ui/templates/views/sensors.html @@ -26,7 +26,7 @@
-
+