From cb888d11a6346778a4a7bfbffcc5ec55478814d6 Mon Sep 17 00:00:00 2001 From: Jacek Kolasa Date: Wed, 28 Aug 2019 18:58:04 +0300 Subject: History tips (#6711) * split sidebar note into multilines (just in code) * note in sidebar - grammatical fixes, added history tip * add history tip in dygraph chart, on the left side, when panned beyond its available past * bundled/compiled dashboard.js * invisible left side of history-tip was preventing further panning to the past, fix that * change history link from "https://docs.netdata.cloud/daemon/config/#global-section-options" to "https://docs.netdata.cloud/docs/configuration-guide/#increase-the-metrics-retention-period" --- web/gui/dashboard.css | 18 ++++++++++++++ web/gui/dashboard.js | 37 +++++++++++++++++++++++++++- web/gui/dashboard.slate.css | 18 ++++++++++++++ web/gui/main.js | 14 ++++++++++- web/gui/src/dashboard.js/charting/dygraph.js | 37 +++++++++++++++++++++++++++- 5 files changed, 121 insertions(+), 3 deletions(-) (limited to 'web') diff --git a/web/gui/dashboard.css b/web/gui/dashboard.css index 8062497d06..674131a1dc 100644 --- a/web/gui/dashboard.css +++ b/web/gui/dashboard.css @@ -737,3 +737,21 @@ body { .ps-container:hover > .ps-scrollbar-y-rail:hover > .ps-scrollbar-y { background-color: #999; /* scrollbar color on hover */ } + +.dygraph__history-tip { + position: absolute; + top: 50%; + transform: translateY(-50%); + display: none; /* overriden in js */ + margin-right: 25px; + direction: rtl; + overflow: hidden; + pointer-events: none; +} + +.dygraph__history-tip-content { + display: inline-block; + white-space: nowrap; + direction: ltr; + pointer-events: auto; +} diff --git a/web/gui/dashboard.js b/web/gui/dashboard.js index a32a29be73..0c379dc051 100644 --- a/web/gui/dashboard.js +++ b/web/gui/dashboard.js @@ -2281,8 +2281,28 @@ NETDATA.dygraphChartCreate = function (state, data) { NETDATA.globalSelectionSync.stop(); }, underlayCallback: function (canvas, area, g) { - // the chart is about to be drawn + + // update history_tip_element + if (state.tmp.dygraph_history_tip_element) { + const xHookRightSide = g.toDomXCoord(state.netdata_first); + if (xHookRightSide > area.x) { + state.tmp.dygraph_history_tip_element_displayed = true; + // group the styles for possible better performance + state.tmp.dygraph_history_tip_element.setAttribute( + 'style', + `display: block; left: ${area.x}px; right: calc(100% - ${xHookRightSide}px);` + ) + } else { + if (state.tmp.dygraph_history_tip_element_displayed) { + // additional check just for performance + // don't update the DOM when it's not needed + state.tmp.dygraph_history_tip_element.style.display = 'none'; + state.tmp.dygraph_history_tip_element_displayed = false; + } + } + } + // this function renders global highlighted time-frame if (NETDATA.globalChartUnderlay.isActive()) { @@ -2751,6 +2771,21 @@ NETDATA.dygraphChartCreate = function (state, data) { state.tmp.dygraph_instance = new Dygraph(state.element_chart, data.result.data, state.tmp.dygraph_options); + + state.tmp.dygraph_history_tip_element = document.createElement('div'); + state.tmp.dygraph_history_tip_element.innerHTML = ` + + Want to extend your history of real-time metrics? +
+ + Configure Netdata's history + or use the DB engine. +
+ `; + state.tmp.dygraph_history_tip_element.className = 'dygraph__history-tip'; + state.element_chart.appendChild(state.tmp.dygraph_history_tip_element); + + state.tmp.dygraph_force_zoom = false; state.tmp.dygraph_user_action = false; state.tmp.dygraph_last_rendered = Date.now(); diff --git a/web/gui/dashboard.slate.css b/web/gui/dashboard.slate.css index f1c9c4101c..af33825213 100644 --- a/web/gui/dashboard.slate.css +++ b/web/gui/dashboard.slate.css @@ -755,3 +755,21 @@ code { .ps-container:hover > .ps-scrollbar-y-rail:hover > .ps-scrollbar-y { background-color: #999; /* scrollbar color on hover */ } + +.dygraph__history-tip { + position: absolute; + top: 50%; + transform: translateY(-50%); + display: none; /* overriden in js */ + margin-right: 25px; + direction: rtl; + overflow: hidden; + pointer-events: none; +} + +.dygraph__history-tip-content { + display: inline-block; + white-space: nowrap; + direction: ltr; + pointer-events: auto; +} diff --git a/web/gui/main.js b/web/gui/main.js index 1214eba6fc..6aebb8ed36 100644 --- a/web/gui/main.js +++ b/web/gui/main.js @@ -1788,7 +1788,19 @@ function renderPage(menus, data) { sidebar += '
  • add more charts
  • '; sidebar += '
  • add more alarms
  • '; - sidebar += '
  • netdata on ' + data.hostname.toString() + ', collects every ' + ((data.update_every === 1) ? 'second' : data.update_every.toString() + ' seconds') + ' ' + data.dimensions_count.toLocaleString() + ' metrics, presented as ' + data.charts_count.toLocaleString() + ' charts and monitored by ' + data.alarms_count.toLocaleString() + ' alarms, using ' + Math.round(data.rrd_memory_bytes / 1024 / 1024).toLocaleString() + ' MB of memory for ' + NETDATA.seconds4human(data.update_every * data.history, { space: ' ' }) + ' of real-time history.
     
    netdata
    ' + data.version.toString() + '
  • '; + sidebar += '
  • Every ' + + ((data.update_every === 1) ? 'second' : data.update_every.toString() + ' seconds') + ', ' + + 'Netdata collects ' + data.dimensions_count.toLocaleString() + ' metrics, presents them in ' + + data.charts_count.toLocaleString() + ' charts and monitors them with ' + + data.alarms_count.toLocaleString() + ' alarms. Netdata is using ' + + Math.round(data.rrd_memory_bytes / 1024 / 1024).toLocaleString() + ' MB of memory on ' + + data.hostname.toString() + ' for ' + + NETDATA.seconds4human(data.update_every * data.history, { + minute: 'minute', minutes: 'minutes', second: 'second', seconds: 'seconds', space: ' ', + }) + + ' of real-time history.
     
    ' + 'Get more history by ' + + 'configuring Netdata\'s history or using the DB engine.' + + '
     
    netdata
    ' + data.version.toString() + '
  • '; sidebar += ''; div.innerHTML = html; document.getElementById('sidebar').innerHTML = sidebar; diff --git a/web/gui/src/dashboard.js/charting/dygraph.js b/web/gui/src/dashboard.js/charting/dygraph.js index a60af18b83..f34d2f4aa1 100644 --- a/web/gui/src/dashboard.js/charting/dygraph.js +++ b/web/gui/src/dashboard.js/charting/dygraph.js @@ -483,8 +483,28 @@ NETDATA.dygraphChartCreate = function (state, data) { NETDATA.globalSelectionSync.stop(); }, underlayCallback: function (canvas, area, g) { - // the chart is about to be drawn + + // update history_tip_element + if (state.tmp.dygraph_history_tip_element) { + const xHookRightSide = g.toDomXCoord(state.netdata_first); + if (xHookRightSide > area.x) { + state.tmp.dygraph_history_tip_element_displayed = true; + // group the styles for possible better performance + state.tmp.dygraph_history_tip_element.setAttribute( + 'style', + `display: block; left: ${area.x}px; right: calc(100% - ${xHookRightSide}px);` + ) + } else { + if (state.tmp.dygraph_history_tip_element_displayed) { + // additional check just for performance + // don't update the DOM when it's not needed + state.tmp.dygraph_history_tip_element.style.display = 'none'; + state.tmp.dygraph_history_tip_element_displayed = false; + } + } + } + // this function renders global highlighted time-frame if (NETDATA.globalChartUnderlay.isActive()) { @@ -953,6 +973,21 @@ NETDATA.dygraphChartCreate = function (state, data) { state.tmp.dygraph_instance = new Dygraph(state.element_chart, data.result.data, state.tmp.dygraph_options); + + state.tmp.dygraph_history_tip_element = document.createElement('div'); + state.tmp.dygraph_history_tip_element.innerHTML = ` + + Want to extend your history of real-time metrics? +
    + + Configure Netdata's history + or use the DB engine. +
    + `; + state.tmp.dygraph_history_tip_element.className = 'dygraph__history-tip'; + state.element_chart.appendChild(state.tmp.dygraph_history_tip_element); + + state.tmp.dygraph_force_zoom = false; state.tmp.dygraph_user_action = false; state.tmp.dygraph_last_rendered = Date.now(); -- cgit v1.2.3