added notifications on alarm
LucaDev committed
Aug 27, 2016 at 18:50 UTC
d584533f12ef1c8c0420d9e4b975cf6597a80300
1 file changed
+12
web/dashboard.js
+12
@@ -5601,6 +5601,15 @@
5601
update_forever: function() {
5602
NETDATA.alarms.get('active', function(data) {
5603
if(data !== null) {
5604
+ if("Notification" in window && NETDATA.alarms.current != null) {
5605
+ if(Object.keys(NETDATA.alarms.current.alarms).length < Object.keys(data.alarms).length) {
5606
+ if (Notification.permission === 'granted') {
5607
+ new Notification('Netdata Alarm!', {body: 'Your Server needs attention!',
5608
+ icon: 'images/seo-performance-128.png'});
5609
+ }
5610
+ }
5611
+ }
5612
+
5613
NETDATA.alarms.current = data;
5614
5615
if (typeof NETDATA.alarms.callback === 'function') {
@@ -5633,6 +5642,9 @@
5642
5643
init: function() {
5644
NETDATA.alarms.update_forever();
5645
+ if ("Notification" in window && Notification.permission !== 'granted') {
5646
+ Notification.requestPermission();
5647
+ }
5648
}
5649
};
5650