Skip to content

Commit

Permalink
Regression: analytics selections malfunctioning (#117)
Browse files Browse the repository at this point in the history
Fixed regression and started more targeted loading of javascript functions from our own js modules.


* Create draft PR for #116

* Fix bug due to redefining older javascript content as a js module.

* Changelog entry

* More targeted loading of js functions from module

Co-authored-by: Flix6x <Flix6x@users.noreply.github.com>
Co-authored-by: F.N. Claessen <felix@seita.nl>
Co-authored-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
  • Loading branch information
4 people committed May 7, 2021
1 parent 97d55b9 commit 93ca7d5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 23 deletions.
1 change: 1 addition & 0 deletions documentation/changelog.rst
Expand Up @@ -26,6 +26,7 @@ v0.4.1 | May XX, 2021
Bugfixes
-----------
* Fix regression when editing assets in the UI [see `PR #122 <http://www.github.com/SeitaBV/flexmeasures/pull/122>`_]
* Fixed a regression that stopped asset, market and sensor selection from working [see `PR #117 <http://www.github.com/SeitaBV/flexmeasures/pull/117>`_]
* Prevent logging out user when clearing the session [see `PR #112 <http://www.github.com/SeitaBV/flexmeasures/pull/112>`_]
* Prevent user type data source to be created without setting a user [see `PR #111 <https://github.com/SeitaBV/flexmeasures/pull/111>`_]

Expand Down
19 changes: 19 additions & 0 deletions flexmeasures/ui/static/js/daterange-utils.js
@@ -0,0 +1,19 @@
// Date range utils
export function subtract(oldDate, nDays) {
var newDate = new Date(oldDate)
newDate.setDate(newDate.getDate() - nDays);
return newDate;
}
export function thisMonth(oldDate) {
var d1 = new Date(oldDate)
d1.setDate(1);
var d2 = new Date(d1.getFullYear(), d1.getMonth() + 1, 0);
return [d1, d2];
};
export function lastNMonths(oldDate, nMonths) {
var d0 = new Date(oldDate)
var d1 = new Date(d0.getFullYear(), d0.getMonth() - nMonths + 2, 0);
d1.setDate(1);
var d2 = new Date(d0.getFullYear(), d0.getMonth() + 1, 0);
return [d1, d2];
};
21 changes: 0 additions & 21 deletions flexmeasures/ui/static/js/flexmeasures.js
Expand Up @@ -310,24 +310,3 @@ function submit_market() {
function submit_sensor_type() {
$("#sensor_type-form").attr("action", empty_location).submit();
}


// Date range utils
export function subtract(oldDate, nDays) {
var newDate = new Date(oldDate)
newDate.setDate(newDate.getDate() - nDays);
return newDate;
}
export function thisMonth(oldDate) {
var d1 = new Date(oldDate)
d1.setDate(1);
var d2 = new Date(d1.getFullYear(), d1.getMonth() + 1, 0);
return [d1, d2];
};
export function lastNMonths(oldDate, nMonths) {
var d0 = new Date(oldDate)
var d1 = new Date(d0.getFullYear(), d0.getMonth() - nMonths + 2, 0);
d1.setDate(1);
var d2 = new Date(d0.getFullYear(), d0.getMonth() + 1, 0);
return [d1, d2];
};
2 changes: 1 addition & 1 deletion flexmeasures/ui/templates/base.html
Expand Up @@ -209,7 +209,7 @@
<script src="https://cdn.jsdelivr.net/npm/ion-rangeslider@2.3.1/js/ion.rangeSlider.min.js"></script>

<!-- Custom scripts -->
<script type="module" src="{{ url_for('flexmeasures_ui.static', filename='js/flexmeasures.js') }}"></script>
<script src="{{ url_for('flexmeasures_ui.static', filename='js/flexmeasures.js') }}"></script>
{% if show_datepicker %}
<script src="{{ url_for('flexmeasures_ui.static', filename='js/daterangepicker-init.js') }}"></script>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion flexmeasures/ui/templates/views/sensors.html
Expand Up @@ -25,7 +25,7 @@
<!-- Render Charts -->
<script type="module" type="text/javascript">

import { subtract, thisMonth, lastNMonths } from "{{ url_for('flexmeasures_ui.static', filename='js/flexmeasures.js') }}";
import { subtract, thisMonth, lastNMonths } from "{{ url_for('flexmeasures_ui.static', filename='js/daterange-utils.js') }}";

let vegaView;

Expand Down

0 comments on commit 93ca7d5

Please sign in to comment.