this.autoRefresh();
})
}
- else {
- console.log('auto-refresher nothing to do');
- }
+ //else {
+ // console.log('auto-refresher nothing to do');
+ //}
// run the next refresh iteration
setTimeout(NETDATA.chartRefresher,
// Registry of netdata hosts
NETDATA.alarms = {
+ server: null,
current: null,
callback: null,
get: function(what, callback) {
$.ajax({
- url: NETDATA.serverDefault + '/api/v1/alarms?' + what.toString(),
+ url: NETDATA.alarms.server + '/api/v1/alarms?' + what.toString(),
async: true,
cache: false,
xhrFields: { withCredentials: true } // required for the cookie
callback(data);
})
.fail(function() {
- NETDATA.error(415, host);
+ NETDATA.error(415, NETDATA.alarms.server);
if(typeof callback === 'function')
callback(null);
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') {
get_log: function(callback) {
$.ajax({
- url: NETDATA.serverDefault + '/api/v1/alarm_log',
+ url: NETDATA.alarms.server + '/api/v1/alarm_log',
async: true,
cache: false,
xhrFields: { withCredentials: true } // required for the cookie
callback(data);
})
.fail(function() {
- NETDATA.error(416, host);
+ NETDATA.error(416, NETDATA.alarms.server);
if(typeof callback === 'function')
callback(null);
},
init: function() {
+ var host = NETDATA.serverDefault;
+ while(host.slice(-1) === '/')
+ host = host.substring(0, host.length - 1);
+ NETDATA.alarms.server = host;
+
NETDATA.alarms.update_forever();
+ if ('Notification' in window && Notification.permission === 'default') {
+ Notification.requestPermission();
+ }
}
};