Add "Delete data" action to sensor page with filtered DELETE endpoint#2095
Add "Delete data" action to sensor page with filtered DELETE endpoint#2095
Conversation
Documentation build overview
Show files changed (17 files in total): 📝 16 modified | ➕ 0 added | ➖ 1 deleted
|
…ta panel Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/9d622b0b-5a18-4b92-b717-4c2562cb1471 Co-authored-by: joshuaunity <45713692+joshuaunity@users.noreply.github.com>
joshuaunity
left a comment
There was a problem hiding this comment.
This works as expected, I've gone through the code and i also think the approach used is on point.
Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
…ta endpoint Signed-off-by: joshuaunity <oghenerobojosh01@gmail.com>
Hi @nhoening, this code is needed, as it's being used to populate the dropdown of data sources for the form. |
As I said earlier, the statistics panel on this page already makes this call, I believe.
@copilot investigate re-using the source information from the statistics panel for this button. |
…API call Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/75aee554-6324-41c5-9846-a3999b948f3a Co-authored-by: nhoening <1042336+nhoening@users.noreply.github.com>
... Done in e2b9bc5. The separate |
@joshuaunity did you test manually also? |
It was in a separate file... I see. |
yes i did, but ill pull this upate and test again |
|
Something I noticed, when all sources are deleted, it reflects immediately on the graph, but it takes some time before it reflects on the page itself. That is, the statistics and the dropdown still show the data source. But there doesn't seem to be any drawback or issues caused by this. |
…asts and fixes the runtime error
|
@Flix6x i have tested again adn it works fine. it took a while, but i also fixed a bug relating to the toast, which i noticed on this PR. |
|
@copilot please initalize the datepicker for the delete-data dialogue to the start and end time shown in the graph |
…time range Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/88194780-0b56-4e59-8c91-0fd6d22a6c8d Co-authored-by: nhoening <1042336+nhoening@users.noreply.github.com>
Done in 6be0e99. Two things now happen automatically:
|
|
@copilot also, add a "select all data" link on the left of the Delete button, which will set the start and end time to the first and last event time, respectively. These datetimes can be found in the statistics table. |
…o first/last event times Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/7e25443c-25c7-46a0-b425-f54023c7091c Co-authored-by: nhoening <1042336+nhoening@users.noreply.github.com>
Done in fdaa8c5. A "Select all data" link now appears on the left of the Delete button. It is initially hidden and is revealed once the stats data has loaded. When clicked, it sets the "From" input to the earliest "First event start" and the "Until" input to the latest "Last event end" across all sources, using the data already fetched by Implementation:
|
|
@copilot good. but actually, the last recorded event time is the beginning of the event, so for the end time (when the "Select all data" link is clicked, we should add the sensor resolution. Also, the statistics table should be updated upon sensor data deletion. |
…ts after deletion Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/48518fa7-f5ad-4c7b-951e-b71437604fad Co-authored-by: nhoening <1042336+nhoening@users.noreply.github.com>
Done in d58c513. Two changes made:
|
|
@copilot the code looks okay but both additions from d58c513 are not working properly yet.
Finally, |
…ename syncDeleteInputsWithRange Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/275aec67-9859-4358-8d2a-30f88b6a8ca3 Co-authored-by: nhoening <1042336+nhoening@users.noreply.github.com>
Fixed in 9857109. Three issues addressed:
|
|
@copilot the endpoint called by |
Agent-Logs-Url: https://github.com/FlexMeasures/flexmeasures/sessions/b4e73567-719a-4811-8db0-bebd948003fb Co-authored-by: nhoening <1042336+nhoening@users.noreply.github.com>
Fixed in 344f5ed. The |

Adds a "Delete data" panel to the sensor page sidebar, backed by a filtered DELETE endpoint, allowing users to delete sensor data by source, start time, and/or end time.
Changes Made
DELETE /api/v3_0/sensors/<id>/datato accept optionalsource,start, anduntilbody parameters for scoped deletion.loadSensorStats()to avoid a duplicate/statsAPI call.graphDateRangeChangedcustom event dispatched fromgraphs.html.Cache-Control: no-store: TheGET /api/v3_0/sensors/<id>/statsendpoint now sendsCache-Control: no-storeso browsers never cache stats responses, ensuring the refreshed stats after deletion always reflect the current state.deleteData: Input values are read at click time and passed as arguments todeleteData(sourceValue, startValue, untilValue), ensuring the confirmation message and the DELETE request use the same values.btn-closeclick listener intoasts.htmlthat caused aTypeError: Cannot read properties of null (reading 'classList')error.