Secured future date input + min(end,now) for complete_to_end

This commit is contained in:
l_samenv
2024-08-14 10:33:50 +02:00
parent 5735fe9f01
commit f4cf8fd9a5
2 changed files with 7 additions and 1 deletions

View File

@ -12,6 +12,11 @@ class DatesPopup extends HTMLElement{
getDateTimeInput(){
let dateInputValue = this.getElementsByClassName("input-date")[0].valueAsDate;
let today = new Date();
if(dateInputValue > today){
dateInputValue = today;
alertify.warning("Date in the future : using today");
}
dateInputValue.setHours(0,0,0,0);
let formattedHour = this.getElementsByClassName("input-time")[0].value;
let timeMs = this.convertTimeStringToTimestamp(formattedHour);
@ -62,6 +67,7 @@ class DatesPopup extends HTMLElement{
this.hide();
this.getElementsByTagName("img")[0].onclick = () => {this.hide();};
this.getElementsByClassName("go-to-now-button")[0].onclick = () => {this.doGoToNowCallback();};
this.getElementsByClassName("input-date")[0].max = new Date().toISOString().split("T")[0]; // sets the max to today (set only at app start)
this.getElementsByClassName("jump-button-time")[0].onclick = () => {this.doJumpTimeCallback();};
this.getElementsByClassName("jump-button-all")[0].onclick = () => {this.doJumpAllCallback();};
}

View File

@ -119,7 +119,7 @@ class InfluxGraph:
result = self.influx_data_getter.get_curves_in_timerange(self.variables, self.time, interval)
self.strip_future(result)
self.complete_to_end(result, end)
self.complete_to_end(result, min(end, now))
self.time[0] = self.time[1]
# reduction not yet implemented
return dict(type='graph-draw', reduced=False, graph=result)