Notifications refresh v2 and session caching

This commit is contained in:
Erik Kalkoken
2021-01-16 00:09:49 +00:00
committed by Ariel Rin
parent aeeb35bc60
commit 4394d25961
27 changed files with 869 additions and 152 deletions

View File

@@ -1,6 +1,7 @@
{% load static %}
{% load i18n %}
{% load navactive %}
{% load auth_notifications %}
<!DOCTYPE html>
<html lang="en">
<head>
@@ -9,7 +10,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
{% include 'allianceauth/icons.html' %}
<title>{% block title %}{% block page_title %}{% endblock page_title %} - Alliance Auth{% endblock title %}</title>
@@ -27,7 +27,6 @@
<div id="wrapper" class="container">
<!-- Navigation -->
{% include 'allianceauth/top-menu.html' %}
<div class="row" id="site-body-wrapper">
{% include 'allianceauth/side-menu.html' %}
<div class="col-sm-10">
@@ -40,7 +39,6 @@
{% endif %}
{% endfor %}
{% endif %}
{% block content %}
{% endblock content %}
</div>
@@ -48,12 +46,20 @@
</div>
</div>
{% endif %}
<!-- share data with JS part -->
<div
id="dataExport"
data-notificationsListViewUrl="{% url 'notifications:list' %}"
data-notificationsRefreshTime="{% notifications_refresh_time %}"
data-userNotificationsCountViewUrl="{% url 'notifications:user_notifications_count' request.user.pk %}"
>
</div>
{% include 'bundles/bootstrap-js.html' %}
{% block extra_javascript %}
{% include 'bundles/jquery-visibility-js.html' %}
<script src="{% static 'js/refresh_notifications.js' %}"></script>
{% block extra_javascript %}
{% endblock extra_javascript %}
<script>
{% block extra_script %}
{% endblock extra_script %}

View File

@@ -0,0 +1,13 @@
{% load auth_notifications %}
{% with unread_count=request.user|user_unread_notification_count %}
{% if unread_count > 0 %}
<a href="{% url 'notifications:list' %}">Notifications
<span class="badge">{{ unread_count }}</span>
</a>
{% else %}
<a href="{% url 'notifications:list' %}">
<i class="far fa-bell"></i>
</a>
{% endif %}
{% endwith %}

View File

@@ -20,17 +20,11 @@
<li>
{% include 'allianceauth/night-toggle.html' %}
</li>
{% if notifications %}
<li class="{% navactive request 'notifications:' %}">
<a href="{% url 'notifications:list' %}">Notifications
<span class="badge">{{ notifications }}</span>
</a>
<li
class="{% navactive request 'notifications:' %}" id="menu_item_notifications"
>
{% include 'allianceauth/notifications_menu_item.html' %}
</li>
{% else %}
<li><a href="{% url 'notifications:list' %}">
<i class="far fa-bell"></i></a>
</li>
{% endif %}
{% if user.is_authenticated %}
{% if user.is_staff %}
<li><a href="{% url 'admin:index' %}">{% trans "Admin" %}</a></li>
@@ -64,3 +58,4 @@
</div>
</div>
</nav>

View File

@@ -0,0 +1,4 @@
{% load static %}
<!-- Start jQuery visibility js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-visibility/1.0.11/jquery-visibility.min.js"></script>
<!-- End jQuery visibility js -->