Skip to content

Commit

Permalink
Update the URL of the asset page when the period is selected using th…
Browse files Browse the repository at this point in the history
…e datepicker.

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
  • Loading branch information
victorgarcia98 committed Apr 24, 2024
1 parent 031d6d6 commit 75ef83d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions flexmeasures/ui/templates/crud/asset.html
Expand Up @@ -166,6 +166,23 @@ <h3>Edit {{ asset.name }}</h3>
dif + pad(Math.floor(Math.abs(tzo) / 60)) +
':' + pad(Math.abs(tzo) % 60);
}

$(window).ready(() => {
picker.on('selected', (startDate, endDate) => {
startDate = encodeURIComponent(toIsoString(startDate.toJSDate()));
// add 1 day to end date as datepicker does not include the end date day
endDate = endDate.toJSDate();
endDate.setDate(endDate.getDate() + 1);
endDate = encodeURIComponent(toIsoString(endDate));
var base_url = window.location.href.split("?")[0];
var new_url = `${base_url}?start_time=${startDate}&end_time=${endDate}`;

// change current url without reloading the page
window.history.pushState({}, null, new_url);
});

});

function copyUrl(event) {
event.preventDefault();

Expand Down

0 comments on commit 75ef83d

Please sign in to comment.