Commit 986c3ad7 by Czémán Arnold

dashboard: small improvements on destktop notifications

parent 9012bf31
...@@ -203,18 +203,19 @@ function generateMessageFromLastActivity(){ ...@@ -203,18 +203,19 @@ function generateMessageFromLastActivity(){
var ac = $('div.activity').first(); var ac = $('div.activity').first();
var error = ac.children(".timeline-icon-failed").length; var error = ac.children(".timeline-icon-failed").length;
var sign = (error === 1) ? "❌ " : "✓ "; var sign = (error === 1) ? "❌ " : "✓ ";
var msg = ac.children("strong").text().trim(); var msg = ac.children("strong").text().replace(/\s\s+/g, " ");
return sign + msg; return sign + msg;
} }
function sendNotification(message) { function sendNotification(message) {
var options = { icon: "/static/dashboard/img/favicon.png"};
if (Notification.permission === "granted") { if (Notification.permission === "granted") {
var notification = new Notification(message); var notification = new Notification(message, options);
} }
else if (Notification.permission !== 'denied') { else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) { Notification.requestPermission(function (permission) {
if (permission === "granted") { if (permission === "granted") {
var notification = new Notification(message); var notification = new Notification(message, options);
} }
}); });
} }
......
...@@ -14,7 +14,4 @@ ...@@ -14,7 +14,4 @@
({% trans "username" %}: {{ user.username }}) ({% trans "username" %}: {{ user.username }})
{% endif %} {% endif %}
{% endif %} {% endif %}
<span id="user-options" data-desktop_notifications="{{ user.profile.desktop_notifications }}"><span>
{% endif %} {% endif %}
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
{% block navbar %} {% block navbar %}
{% if request.user.is_authenticated and request.user.pk and not request.token_user %} {% if request.user.is_authenticated and request.user.pk and not request.token_user %}
<span id="user-options" data-desktop_notifications="{{ request.user.profile.desktop_notifications }}"><span>
<ul class="nav navbar-nav navbar-right" id="dashboard-menu"> <ul class="nav navbar-nav navbar-right" id="dashboard-menu">
{% if request.user.is_superuser %} {% if request.user.is_superuser %}
{% if ADMIN_ENABLED %} {% if ADMIN_ENABLED %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment