summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorthiagoftsm <thiagoftsm@gmail.com>2019-09-17 08:44:14 +0000
committerChris Akritidis <43294513+cakrit@users.noreply.github.com>2019-09-17 10:44:14 +0200
commit7485fed6ba94ccd6c6382944bd5bf917db0fae49 (patch)
treef04d59c357d4c30a924fec66ec0aa0d4d779b39b /web
parentfab0d4bdba30a4a37c2cc9d910bf9e9075c2afb3 (diff)
Center the chart on timeframe when an alarm is raised (#6391)
##### Summary When an alarm happens, we were sending notification for our users, but the notifications were missing an important information that allows to centralize the Chart to demonstrate to our users. ##### Component Name UI ##### Additional Information Closes #5810
Diffstat (limited to 'web')
-rw-r--r--web/gui/goto-host-from-alarm.html2
-rw-r--r--web/gui/main.css4
-rw-r--r--web/gui/main.js49
3 files changed, 51 insertions, 4 deletions
diff --git a/web/gui/goto-host-from-alarm.html b/web/gui/goto-host-from-alarm.html
index ec53df0844..7d12f84804 100644
--- a/web/gui/goto-host-from-alarm.html
+++ b/web/gui/goto-host-from-alarm.html
@@ -69,6 +69,7 @@ var urlOptions = {
alarm_unique_id: 0,
alarm_id: 0,
alarm_event_id: 0,
+ alarm_when: 0,
hasProperty: function(property) {
return typeof this[property] !== 'undefined';
}
@@ -101,6 +102,7 @@ function netdataURL(url) {
+ ';alarm_unique_id=' + urlOptions.alarm_unique_id.toString()
+ ';alarm_id=' + urlOptions.alarm_id.toString()
+ ';alarm_event_id=' + urlOptions.alarm_event_id.toString()
+ + ';alarm_when=' + urlOptions.alarm_when.toString()
;
}
diff --git a/web/gui/main.css b/web/gui/main.css
index b6ba959107..870a1fdd42 100644
--- a/web/gui/main.css
+++ b/web/gui/main.css
@@ -383,6 +383,10 @@ body.modal-open {
/* -------------------------------------------------------------------------- */
+#alarms_log_table tbody tr {
+ cursor: pointer;
+}
+
#my-netdata-dropdown-content {
width: 500px;
}
diff --git a/web/gui/main.js b/web/gui/main.js
index 71af6b59d3..fa7b4bedc7 100644
--- a/web/gui/main.js
+++ b/web/gui/main.js
@@ -71,6 +71,7 @@ var urlOptions = {
alarm_unique_id: 0,
alarm_id: 0,
alarm_event_id: 0,
+ alarm_when: 0,
hasProperty: function (property) {
// console.log('checking property ' + property + ' of type ' + typeof(this[property]));
@@ -139,7 +140,7 @@ var urlOptions = {
}
}
- var numeric = ['after', 'before', 'highlight_after', 'highlight_before'];
+ var numeric = ['after', 'before', 'highlight_after', 'highlight_before', 'alarm_when'];
len = numeric.length;
while (len--) {
if (typeof urlOptions[numeric[len]] === 'string') {
@@ -153,6 +154,22 @@ var urlOptions = {
}
}
+ if (urlOptions.alarm_when) {
+ // if alarm_when exists, create after/before params
+ // -/+ 2 minutes from the alarm, and reload the page
+ const alarmTime = new Date(urlOptions.alarm_when * 1000).valueOf();
+ const timeMarginMs = 120000; // 2 mins
+
+ const after = alarmTime - timeMarginMs;
+ const before = alarmTime + timeMarginMs;
+ const newHash = document.location.hash.replace(
+ /;alarm_when=[0-9]*/i,
+ ";after=" + after + ";before=" + before,
+ );
+ history.replaceState(null, '', newHash);
+ location.reload();
+ }
+
if (urlOptions.server !== null && urlOptions.server !== '') {
netdataServerStatic = document.location.origin.toString() + document.location.pathname.toString();
netdataServer = urlOptions.server;
@@ -2094,7 +2111,7 @@ function alarmsUpdateModal() {
var badge_url = NETDATA.alarms.server + '/api/v1/badge.svg?chart=' + alarm.chart + '&alarm=' + alarm.name + '&refresh=auto';
var action_buttons = '<br/>&nbsp;<br/>role: <b>' + alarm.recipient + '</b><br/>&nbsp;<br/>'
- + '<div class="action-button ripple" title="click to scroll the dashboard to the chart of this alarm" data-toggle="tooltip" data-placement="bottom" onClick="scrollToChartAfterHidingModal(\'' + alarm.chart + '\'); $(\'#alarmsModal\').modal(\'hide\'); return false;"><i class="fab fa-periscope"></i></div>'
+ + '<div class="action-button ripple" title="click to scroll the dashboard to the chart of this alarm" data-toggle="tooltip" data-placement="bottom" onClick="scrollToChartAfterHidingModal(\'' + alarm.chart + '\', ' + alarm.last_status_change * 1000 + ', \'' + alarm.status + '\'); $(\'#alarmsModal\').modal(\'hide\'); return false;"><i class="fab fa-periscope"></i></div>'
+ '<div class="action-button ripple" title="click to copy to the clipboard the URL of this badge" data-toggle="tooltip" data-placement="bottom" onClick="clipboardCopy(\'' + badge_url + '\'); return false;"><i class="far fa-copy"></i></div>'
+ '<div class="action-button ripple" title="click to copy to the clipboard an auto-refreshing <code>embed</code> html element for this badge" data-toggle="tooltip" data-placement="bottom" onClick="clipboardCopyBadgeEmbed(\'' + badge_url + '\'); return false;"><i class="fas fa-copy"></i></div>';
@@ -2335,6 +2352,18 @@ function alarmsUpdateModal() {
exportOptions: {
fileName: 'netdata_alarm_log'
},
+ onClickRow: function (row, $element,field) {
+ void (field);
+ void ($element);
+ let main_url;
+ let common_url = "&host=" + encodeURIComponent(row['hostname']) + "&chart=" + encodeURIComponent(row['chart']) + "&family=" + encodeURIComponent(row['family']) + "&alarm=" + encodeURIComponent(row['name']) + "&alarm_unique_id=" + row['unique_id'] + "&alarm_id=" + row['alarm_id'] + "&alarm_event_id=" + row['alarm_event_id'] + "&alarm_when=" + row['when'];
+ if (NETDATA.registry.isUsingGlobalRegistry() && NETDATA.registry.machine_guid != null) {
+ main_url = "https://netdata.cloud/alarms/redirect?agentID=" + NETDATA.registry.machine_guid + common_url;
+ } else {
+ main_url = NETDATA.registry.server + "/goto-host-from-alarm.html?" + common_url ;
+ }
+ window.open(main_url,"_blank");
+ },
rowStyle: function (row, index) {
void (index);
@@ -3965,9 +3994,21 @@ function scrollDashboardTo() {
var modalHiddenCallback = null;
-function scrollToChartAfterHidingModal(chart) {
+function scrollToChartAfterHidingModal(chart, alarmDate, alarmStatus) {
modalHiddenCallback = function () {
- NETDATA.alarms.scrollToChart(chart);
+ NETDATA.alarms.scrollToChart(chart, alarmDate);
+
+ if (['WARNING', 'CRITICAL'].includes(alarmStatus)) {
+ const currentChartState = NETDATA.options.targets.find(
+ (chartState) => chartState.id === chart,
+ )
+ const twoMinutes = 2 * 60 * 1000
+ NETDATA.globalPanAndZoom.setMaster(
+ currentChartState,
+ alarmDate - twoMinutes,
+ alarmDate + twoMinutes,
+ )
+ }
};
}