From d584533f12ef1c8c0420d9e4b975cf6597a80300 Mon Sep 17 00:00:00 2001 From: LucaDev Date: Sat, 27 Aug 2016 18:50:47 +0200 Subject: [PATCH] added notifications on alarm --- web/dashboard.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/web/dashboard.js b/web/dashboard.js index 67fb00b8..c3625955 100644 --- a/web/dashboard.js +++ b/web/dashboard.js @@ -5601,6 +5601,15 @@ update_forever: function() { NETDATA.alarms.get('active', function(data) { if(data !== null) { + if("Notification" in window && NETDATA.alarms.current != null) { + if(Object.keys(NETDATA.alarms.current.alarms).length < Object.keys(data.alarms).length) { + if (Notification.permission === 'granted') { + new Notification('Netdata Alarm!', {body: 'Your Server needs attention!', + icon: 'images/seo-performance-128.png'}); + } + } + } + NETDATA.alarms.current = data; if (typeof NETDATA.alarms.callback === 'function') { @@ -5633,6 +5642,9 @@ init: function() { NETDATA.alarms.update_forever(); + if ("Notification" in window && Notification.permission !== 'granted') { + Notification.requestPermission(); + } } }; -- 2.39.2