Allow switching between relative and absolute timestamps#1322
Allow switching between relative and absolute timestamps#1322BastianLedererIcinga wants to merge 44 commits intomainfrom
Conversation
6f5fc61 to
72f5b88
Compare
nilmerg
left a comment
There was a problem hiding this comment.
Please also prevent text selection in case the time tags are interactive, that's common practice for such widgets.
And I had a bug I did't track down yet: After some time or interactions, switching between relative/absolute didn't work anymore. The toggle updated accordingly, but neither pressing the toggle nor the time tags did update the time. A refresh fixes it. But I didn't look at the JS in detail yet, maybe I can easily spot the problem once I do this, so please focus on the other comments first.
I came across a bug that might have been what you describe. This bug never occurs when the backend creates absolute time, because the A reload would fix this while the toggle is set to absolute time, if set to relative it would briefly appear to fix the problem since the newly generated timestamps have the correct content, but switching timestamp mode will lead to the same problem as before. |
nilmerg
left a comment
There was a problem hiding this comment.
again, php only, css + js after my break :)
| el.removeAttribute('data-absolute-time'); | ||
| el.setAttribute('data-relative-time', 'ago'); |
There was a problem hiding this comment.
Seems to be obsolete (by now) please remove. The lines below as well.
There was a problem hiding this comment.
Scratch that, but please make sure this works how Icinga/ipl-web#350 expects it to.
|
I have only tested the new changes with local modifications to Feel free to tell me whenever you are fine with a force push and I will resolve the conflicts. |
sukhwinder33445
left a comment
There was a problem hiding this comment.
I have noticed the following issues:
- The searchbar is not working properly.
- The refresh button does not preserve the
load moreparams.
This is just a quick overview. I’ll take a closer look at it tomorrow.
To allow users to switch between relative and absolute timestamps a new checkbox-control to switch between the two modes is added.
Add a property to EventRenderer and NotificationRenderer that allows to choose whether to use relative or absolute timestamps. assembleExtendedInfo() adds the timestamps of the chosen format.
The given timestamp mode is passed to the Renderer. A sperator is added between entries of different days, to achieve this the last timestamp is added to the LoadMoreURL.
createTimeStampControl() checks url, session and preferences for the preffered timestampMode stores it in a property and creates a TimestampToggle for the selected mode.
Changed controllers use the new TimestampToggle control And the adjusted LoadMoreObjectList
The js switches the timestamps between relative and absolute when the dedicated control or a timestamp itself is clicked. The backend is notified of the changed mode.
timestampAction saves the new preference in the session and to the user's preferences
When saving a changed viewmode all other icingadb prefernces were previously deleted. Since this affects the new timestamp preference prefernces with different names than 'view_modes' will be kept as they are.
Add a sample of a relative timestamps to the timestamp-toggle element. This The digits in this sample are then replaced with the current minutes and seconds when switching to relative time in the frontend.
When inside a dashboad controls are not added so the timestamps themselves also should no longer be highlated and clicking them has no effect.
instead of relying on css classes for selecting the time elements use data-attributes.
Previously when reloading the page the latest-entry parameter would cause problems when adding the day-separatos. Now it is reset alongside the query offset.
Previously Url::setParams() was used to set the name and host.name, since the funtion overwrites all parameters the sort parameter was not included in the loadMoreUrl. Url::setParam() only sets/overwrites the given parameter, the sort parameter is no longer affected and load-more works as expected.
When the icinga.config.timezone is changed the timezone in the dateFromatter must be updated to generate correct relative timestamps.
Use the content of a `TimeAgo` widget for the relative sample to ensure the format used matches the one ipl-web expects. Setting a non english locale for `TimestampToggle::dateFormatter` does not work it can be hardcoded to `en-US` sicne its output is never displayed.
It also replaces the `Controller::useRelativeTimestamps` property
Add missing docstring Use arrays when setting several css classes Remve unused id
Rename from `LoadMoreObjectList` to `HistoryObjectList` Add missing docstring Register events in `init()`
add missing docstrings and use the `Time` widget for absolute time
Ensure the separator is added in the correct position for any timezone and the format adjusts to the configured Locale
06bf3f1 to
91d7c75
Compare
It is not supported by php 8.2
I checked again and unfortunately this is a bug in the main branch, so it must be fixed in a separate PR. |
resolves #1065
For the views:
A new control is added that allows to switch between relative and absolute timestamps.

The mode can also be switched by clicking one of timestamps.
Whenever the mode is changed it is added to the url and saved in the user's session and preferences.
For timestamps that are older than one hour absolute time is always displayed, since that aligns with the previous behavior.

Absolute timestamps now always show the time of day, to display the dates a seperate line is added.
To ensure this line is also added when loading more entries the timestamp of the latest entry is added to the
load-moreurl.The relative timestamps rely on the new implementation in Icinga/ipl-web#350.
Additionally a bug in the Service History is fixed.
The sort parameter was not included in the
loadMoreUrl, so descending order was always used when adding new elements.