isaozler / grafana-shift-selector

The shift selector allows you to adjust the time range of your grafana dashboard to one specific shift or a range of shifts.
Apache License 2.0
8 stars 6 forks source link

Shift selector with shift that should go into the next day defaults to the day before. #36

Open Naruske opened 7 months ago

Naruske commented 7 months ago

For example:

I have data from 2024-04-14 00:00:00 to 2024-04-16 12:00:00

2 shift selectors, 05:00:00-17:00:00 and 17:00:00-05:00:00

On day 2024-04-15 I select shift 05-17 and it gives me the data from 2024-04-15 05:00:00 - 17:00:00 When I select shift 17-05 it automatically adjusts the timerange to 2024-04-14 05:00:00 to 2024-04-15 17:00:00 when it should show me 2024-04-15 17:00:00 to 2024-04-16 05:00:00

{ "static": { "shifts": [ { "group": "Group 2", "group_uuid": "group_uuid_2", "uuid": "shift_uuid_1", "label": "Ochtend", "startTime": "05:00:00", "endTime": "17:00:00", "order": 1 }, { "group": "Group 2", "group_uuid": "group_uuid_2", "uuid": "shift_uuid_2", "label": "Avond", "startTime": "17:00:00", "endTime": "05:00:00", "order": 2 } ] } }

Naruske commented 7 months ago

This problem is apparently not consistent. I've had occasions where the button does show me the shift in the future (which obviously has no data yet). And I think it all depends as to default timeframe is saved to the dashboard.

If I can get the date on the shiftselector to be the day beforehand upon default loading I change the date to today, the buttons work as expected.

If I save the timeframe to the dashboard, so upon opening dashboard, date on shiftselector is today, the shiftselector for 17:00:00 to 05:00:00 does not show the future shift.