notifications: Add datetime to each notification

- Notifications are displayed in a user-friendly "time ago" format.

- Use last_update_time instead of created_time

Sunil:

- Some notifications don't have app name and app icon. Styling for those
notification was different due to the last update time. Revert back to
positioning for it. Use CSS float for it.

- Use localized, locale specific date/time format for the tooltip.

Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Joseph Nuthalapati 2025-07-08 14:41:45 +05:30 committed by Sunil Mohan Adapa
parent efbf2a80f5
commit bbeced68f7
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 32 additions and 18 deletions

View File

@ -12,25 +12,33 @@
<ul>
{% for note in notifications %}
<li class="notification notification-{{ note.severity }}">
{% if note.data.app_name %}
<div class="app-name">
{% if note.data.app_icon %}
<div class="app-icon fa {{ note.data.app_icon }}"></div>
{% elif note.data.app_icon_filename %}
{% if note.app_id %}
<img src="{% static note.app_id %}/icons/{{ note.data.app_icon_filename }}.svg"
alt="{{ note.data.app_name }}"
class="notification-icon" />
{% else %}
<img src="{% static 'theme/icons/' %}{{ note.data.app_icon_filename }}.svg"
alt="{{ note.data.app_name }}"
class="notification-icon" />
{% endif %}
{% endif %}
<div class="notification-header">
<span class="notification-time"
title="{{ note.last_update_time|date:'DATETIME_FORMAT' }}">
{% blocktrans trimmed with time_since=note.last_update_time|timesince %}
{{ time_since }} ago
{% endblocktrans %}
</span>
{{ note.data.app_name }}
</div>
{% endif %}
{% if note.data.app_name %}
<div class="app-name">
{% if note.data.app_icon %}
<div class="app-icon fa {{ note.data.app_icon }}"></div>
{% elif note.data.app_icon_filename %}
{% if note.app_id %}
<img src="{% static note.app_id %}/icons/{{ note.data.app_icon_filename }}.svg"
alt="{{ note.data.app_name }}"
class="notification-icon" />
{% else %}
<img src="{% static 'theme/icons/' %}{{ note.data.app_icon_filename }}.svg"
alt="{{ note.data.app_name }}"
class="notification-icon" />
{% endif %}
{% endif %}
{{ note.data.app_name }}
</div>
{% endif %}
</div>
{% if note.body %}
{{ note.body.content.decode|safe }}

View File

@ -1020,6 +1020,12 @@ section.app-description {
border-top: 1px solid var(--bs-border-color-translucent);
}
.notification-time {
float: right;
font-size: 0.8rem;
color: var(--bs-secondary-color);
}
.notification-title {
font-weight: bold;
}