@cryptotaxi247 / netdata-1 / commits / 68b187adb

allow filtering web notification recipients on custom dashboards

Costa Tsaousis (ktsaou) committed Dec 24, 2017 at 01:43 UTC 68b187adb1e5fda1e05b78181134c9f2c4e27e9f
2 files changed +21 -3
web/dashboard.js
+20 -1
@@ -49,6 +49,8 @@
49 * (default: netdataServer) */
50 /*global netdataSnapshotData *//* object, a netdata snapshot loaded
51 * (default: null) */
52 +/*global netdataAlarmsRecipients *//* array, an array of alarm recipients to show notifications for
53 + * (default: null) */
54
55 // ----------------------------------------------------------------------------
56 // global namespace
@@ -7916,6 +7918,7 @@ var NETDATA = window.NETDATA || {};
7918 server: null, // the server to connect to for fetching alarms
7919 current: null, // the list of raised alarms - updated in the background
7920 callback: null, // a callback function to call every time the list of raised alarms is refreshed
7921 + recipients: null, // the list (array) of recipients to show alarms for, or null
7922
7923 notify: function(entry) {
7924 // console.log('alarm ' + entry.unique_id);
@@ -7995,6 +7998,20 @@ var NETDATA = window.NETDATA || {};
7998 return;
7999 }
8000
8001 + // filter recipients
8002 + if(show === true && NETDATA.alarms.recipients !== null) {
8003 + show = false;
8004 + var r = ' ' + entry.recipient + ' ';
8005 + var len = NETDATA.alarms.recipients.length;
8006 + while(len--) {
8007 + if(r.indexOf(' ' + NETDATA.alarms.recipients[len] + ' ') >= 0) {
8008 + console.log('found');
8009 + show = true;
8010 + break;
8011 + }
8012 + }
8013 + }
8014 +
8015 /*
8016 // cleanup old notifications with the same alarm_id as this one
8017 // FIXME: it does not seem to work on any web browser!
@@ -8015,7 +8032,6 @@ var NETDATA = window.NETDATA || {};
8032 */
8033
8034 if(show === true) {
8018 -
8035 setTimeout(function() {
8036 // show this notification
8037 // console.log('new notification: ' + title);
@@ -8213,6 +8229,9 @@ var NETDATA = window.NETDATA || {};
8229 if(NETDATA.alarms.onclick === null)
8230 NETDATA.alarms.onclick = NETDATA.alarms.scrollToAlarm;
8231
8232 + if(typeof netdataAlarmsRecipients !== 'undefined' && Array.isArray(netdataAlarmsRecipients))
8233 + NETDATA.alarms.recipients = netdataAlarmsRecipients;
8234 +
8235 if(netdataShowAlarms === true) {
8236 NETDATA.alarms.update_forever();
8237
web/index.html
+1 -2
@@ -2059,7 +2059,6 @@
2059 function loadClipboard(callback) {
2060 if(clipboardLoaded === false) {
2061 clipboardLoaded = true;
2062 - console.log('loading clipboard');
2062 loadJs('lib/clipboard-polyfill-be05dad.js', callback);
2063 }
2064 else callback();
@@ -5623,6 +5622,6 @@
5622 </div>
5623 </div>
5624 <div id="hiddenDownloadLinks" style="display: none;" hidden></div>
5626 - <script type="text/javascript" src="dashboard.js?v20171208-5"></script>
5625 + <script type="text/javascript" src="dashboard.js?v20171224-1"></script>
5626 </body>
5627 </html>