]> arthur.barton.de Git - netdata.git/commitdiff
dashboard online help and button next to each chart to zoom in/out, pan left/right...
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 10 Apr 2016 14:39:22 +0000 (17:39 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 10 Apr 2016 14:39:22 +0000 (17:39 +0300)
web/dashboard.css
web/dashboard.js
web/dashboard.slate.css
web/index.html

index 1135b39a7db4664ee4d009a006a1e31953818879..a7b090d665c186e110057f5e8b3b74c8d5afc27d 100644 (file)
@@ -66,6 +66,43 @@ body {
        margin: 0px;
 }
 
+.netdata-legend-toolbox {
+       display: block;
+       position: absolute;
+       bottom: 0px;
+       right: 30px;
+       height: 15px;
+       width: 110px;
+       background-color: White;
+       font-size: 12px;
+       vertical-align: middle;
+       line-height: 15px;
+       color: #DDDDDD;
+       text-align: center;
+       overflow: hidden;
+       z-index: 20;
+       padding: 0px;
+       margin: 0px;
+}
+
+.netdata-legend-toolbox-button {
+       display: inline-block;
+       position: relative;
+       height: 15px;
+       width: 18px;
+       background-color: White;
+       font-size: 12px;
+       vertical-align: middle;
+       line-height: 15px;
+       color: #CDCDCD;
+       text-align: center;
+       overflow: hidden;
+       z-index: 21;
+       padding: 0px;
+       margin: 0px;
+       cursor: pointer;
+}
+
 .netdata-message {
        display: inline-block;
        text-align: left;
@@ -453,3 +490,11 @@ body {
        color: #999999;
        font-weight: normal;
 }
+
+.popover-title {
+       font-weight: bold;
+       font-size: 12px;
+}
+.popover-content {
+       font-size: 11px;
+}
index c9725d87c84665620d83d9de3c6a207b51d7fc85..e90ffc15dbbbaa4c3df62528730a54a81114d1f9 100644 (file)
 
                        destroy_on_hide: false,         // destroy charts when they are not visible
 
+                       show_help: true,                        // when enabled the charts will show some help
+
                        eliminate_zero_dimensions: true, // do not show dimensions with just zeros
 
                        stop_updates_when_focus_is_lost: true, // boolean - shall we stop auto-refreshes when document does not have user focus
                        color_fill_opacity_area: 0.2,
                        color_fill_opacity_stacked: 0.8,
 
+                       pan_and_zoom_step: 0.1,         // the increment when panning and zooming with the toolbox
+
                        setOptionCallback: function() { ; }
                },
 
                                this.element_legend_childs = {
                                        content: content,
                                        resize_handler: document.createElement('div'),
+                                       toolbox: document.createElement('div'),
+                                       toolbox_left: document.createElement('div'),
+                                       toolbox_right: document.createElement('div'),
+                                       toolbox_reset: document.createElement('div'),
+                                       toolbox_zoomin: document.createElement('div'),
+                                       toolbox_zoomout: document.createElement('div'),
+                                       toolbox_volume: document.createElement('div'),
                                        title_date: document.createElement('span'),
                                        title_time: document.createElement('span'),
                                        title_units: document.createElement('span'),
 
                                this.element_legend.innerHTML = '';
 
+                               if(this.library.toolboxPanAndZoom !== null) {
+                                       this.element_legend_childs.toolbox.className += ' netdata-legend-toolbox';
+                                       this.element.appendChild(this.element_legend_childs.toolbox);
+
+                                       this.element_legend_childs.toolbox_left.className += ' netdata-legend-toolbox-button';
+                                       this.element_legend_childs.toolbox_left.innerHTML = '<i class="fa fa-backward"></i>';
+                                       this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_left);
+                                       this.element_legend_childs.toolbox_left.onclick = function(e) {
+                                               e.preventDefault();
+                                               var dt = (that.view_before - that.view_after) * NETDATA.options.current.pan_and_zoom_step;
+                                               var before = that.view_before - dt;
+                                               var after = that.view_after - dt;
+                                               if(after >= that.netdata_first)
+                                                       that.library.toolboxPanAndZoom(that, after, before);
+                                       }
+                                       if(NETDATA.options.current.show_help === true)
+                                               $(this.element_legend_childs.toolbox_left).popover({
+                                               container: "body",
+                                               animation: false,
+                                               html: true,
+                                               trigger: 'hover',
+                                               placement: 'bottom',
+                                               delay: 100,
+                                               title: 'Pan Left',
+                                               content: 'Pan the chart to the left. You can also <b>drag it</b> with your mouse or your finger (on touch devices).<br/><small>Help, can be disabled from the settings.</small>'
+                                       });
+
+
+                                       this.element_legend_childs.toolbox_reset.className += ' netdata-legend-toolbox-button';
+                                       this.element_legend_childs.toolbox_reset.innerHTML = '<i class="fa fa-play"></i>';
+                                       this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_reset);
+                                       this.element_legend_childs.toolbox_reset.onclick = function(e) {
+                                               e.preventDefault();
+                                               NETDATA.resetAllCharts(that);
+                                       }
+                                       if(NETDATA.options.current.show_help === true)
+                                               $(this.element_legend_childs.toolbox_reset).popover({
+                                               container: "body",
+                                               animation: false,
+                                               html: true,
+                                               trigger: 'hover',
+                                               placement: 'bottom',
+                                               delay: 100,
+                                               title: 'Chart Reset',
+                                               content: 'Reset all the charts to their default auto-refreshing state. You can also <b>double click</b> the chart contents with your mouse or your finger (on touch devices).<br/><small>Help, can be disabled from the settings.</small>'
+                                       });
+                                       
+                                       this.element_legend_childs.toolbox_right.className += ' netdata-legend-toolbox-button';
+                                       this.element_legend_childs.toolbox_right.innerHTML = '<i class="fa fa-forward"></i>';
+                                       this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_right);
+                                       this.element_legend_childs.toolbox_right.onclick = function(e) {
+                                               e.preventDefault();
+                                               var dt = (that.view_before - that.view_after) * NETDATA.options.current.pan_and_zoom_step;
+                                               var before = that.view_before + dt;
+                                               var after = that.view_after + dt;
+                                               if(before <= that.netdata_last)
+                                                       that.library.toolboxPanAndZoom(that, after, before);
+                                       }
+                                       if(NETDATA.options.current.show_help === true)
+                                               $(this.element_legend_childs.toolbox_right).popover({
+                                               container: "body",
+                                               animation: false,
+                                               html: true,
+                                               trigger: 'hover',
+                                               placement: 'bottom',
+                                               delay: 100,
+                                               title: 'Pan Right',
+                                               content: 'Pan the chart to the right. You can also <b>drag it</b> with your mouse or your finger (on touch devices).<br/><small>Help, can be disabled from the settings.</small>'
+                                       });
+
+                                       
+                                       this.element_legend_childs.toolbox_zoomin.className += ' netdata-legend-toolbox-button';
+                                       this.element_legend_childs.toolbox_zoomin.innerHTML = '<i class="fa fa-plus"></i>';
+                                       this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomin);
+                                       this.element_legend_childs.toolbox_zoomin.onclick = function(e) {
+                                               e.preventDefault();
+                                               var dt = (that.view_before - that.view_after) * NETDATA.options.current.pan_and_zoom_step;
+                                               var before = that.view_before - dt;
+                                               var after = that.view_after + dt;
+                                               that.library.toolboxPanAndZoom(that, after, before);
+                                       }
+                                       if(NETDATA.options.current.show_help === true)
+                                               $(this.element_legend_childs.toolbox_zoomin).popover({
+                                               container: "body",
+                                               animation: false,
+                                               html: true,
+                                               trigger: 'hover',
+                                               placement: 'bottom',
+                                               delay: 100,
+                                               title: 'Chart Zoom In',
+                                               content: 'Zoom in the chart. On Chrome and Opera, you can also press the SHIFT or the ALT keys and then use the mouse wheel to zoom in or out.<br/><small>Help, can be disabled from the settings.</small>'
+                                       });
+                                       
+                                       this.element_legend_childs.toolbox_zoomout.className += ' netdata-legend-toolbox-button';
+                                       this.element_legend_childs.toolbox_zoomout.innerHTML = '<i class="fa fa-minus"></i>';
+                                       this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomout);
+                                       this.element_legend_childs.toolbox_zoomout.onclick = function(e) {
+                                               e.preventDefault();
+                                               var dt = (that.view_before - that.view_after) * NETDATA.options.current.pan_and_zoom_step;
+                                               var before = that.view_before + dt;
+                                               var after = that.view_after - dt;
+
+                                               that.library.toolboxPanAndZoom(that, after, before);
+                                       }
+                                       if(NETDATA.options.current.show_help === true)
+                                               $(this.element_legend_childs.toolbox_zoomout).popover({
+                                               container: "body",
+                                               animation: false,
+                                               html: true,
+                                               trigger: 'hover',
+                                               placement: 'bottom',
+                                               delay: 100,
+                                               title: 'Chart Zoom Out',
+                                               content: 'Zoom out the chart. On Chrome and Opera, you can also press the SHIFT or the ALT keys and then use the mouse wheel to zoom in or out.<br/><small>Help, can be disabled from the settings.</small>'
+                                       });
+                                       
+                                       //this.element_legend_childs.toolbox_volume.className += ' netdata-legend-toolbox-button';
+                                       //this.element_legend_childs.toolbox_volume.innerHTML = '<i class="fa fa-sort-amount-desc"></i>';
+                                       //this.element_legend_childs.toolbox_volume.title = 'Visible Volume';
+                                       //this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_volume);
+                                       //this.element_legend_childs.toolbox_volume.onclick = function(e) {
+                                               //e.preventDefault();
+                                               //alert('clicked toolbox_volume on ' + that.id);
+                                       //}
+                               }
+                               else {
+                                       this.element_legend_childs.toolbox = null;
+                                       this.element_legend_childs.toolbox_left = null;
+                                       this.element_legend_childs.toolbox_reset = null;
+                                       this.element_legend_childs.toolbox_right = null;
+                                       this.element_legend_childs.toolbox_zoomin = null;
+                                       this.element_legend_childs.toolbox_zoomout = null;
+                                       this.element_legend_childs.toolbox_volume = null;
+                               }
+                               
                                this.element_legend_childs.resize_handler.className += " netdata-legend-resize-handler";
                                this.element_legend_childs.resize_handler.innerHTML = '<i class="fa fa-chevron-up"></i><i class="fa fa-chevron-down"></i>';
                                this.element.appendChild(this.element_legend_childs.resize_handler);
+                               if(NETDATA.options.current.show_help === true)
+                                       $(this.element_legend_childs.resize_handler).popover({
+                                       container: "body",
+                                       animation: false,
+                                       html: true,
+                                       trigger: 'hover',
+                                       placement: 'bottom',
+                                       delay: 100,
+                                       title: 'Chart Resize',
+                                       content: 'Drag this point with your mouse or your finger (on touch devices), to resize the chart vertically. You can also <b>double click it</b> or <b>double tap it</b> to reset between 2 states: the default and the one that fits all the values.<br/><small>Help, can be disabled from the settings.</small>'
+                               });
 
                                // mousedown event
                                this.element_legend_childs.resize_handler.onmousedown =
 
                                content.className = 'netdata-legend-series-content';
                                this.element_legend_childs.nano.appendChild(content);
+
+                               if(NETDATA.options.current.show_help === true)
+                                       $(content).popover({
+                                       container: "body",
+                                       animation: false,
+                                       html: true,
+                                       trigger: 'hover',
+                                       placement: 'bottom',
+                                       title: 'Chart Legend',
+                                       delay: 100,
+                                       content: 'You can click or tap on the values or the labels to select dimentions. By pressing SHIFT or ALT, you can enable or disable multiple dimensions.<br/><small>Help, can be disabled from the settings.</small>'
+                               });
                        }
                        else {
                                this.element_legend_childs = {
                                        content: content,
                                        resize_handler: null,
+                                       toolbox: null,
+                                       toolbox_left: null,
+                                       toolbox_right: null,
+                                       toolbox_reset: null,
+                                       toolbox_zoomin: null,
+                                       toolbox_zoomout: null,
+                                       toolbox_volume: null,
                                        title_date: null,
                                        title_time: null,
                                        title_units: null,
                smooth: false
        };
 
+       NETDATA.dygraphToolboxPanAndZoom = function(state, after, before) {
+               if(after < state.netdata_first)
+                       after = state.netdata_first;
+
+               if(before > state.netdata_last)
+                       before = state.netdata_last;
+
+               state.setMode('zoom');
+               state.globalSelectionSyncStop();
+               state.globalSelectionSyncDelay();
+               state.dygraph_user_action = true;
+               state.dygraph_force_zoom = true;
+               state.updateChartPanOrZoom(after, before);
+               NETDATA.globalPanAndZoom.setMaster(state, after, before);
+       };
+
        NETDATA.dygraphSetSelection = function(state, t) {
                if(typeof state.dygraph_instance !== 'undefined') {
                        var r = state.calculateRowForTime(t);
                        },
                        setSelection: NETDATA.dygraphSetSelection,
                        clearSelection:  NETDATA.dygraphClearSelection,
+                       toolboxPanAndZoom: NETDATA.dygraphToolboxPanAndZoom,
                        initialized: false,
                        enabled: true,
                        format: function(state) { return 'json'; },
                        resize: null,
                        setSelection: undefined, // function(state, t) { return true; },
                        clearSelection: undefined, // function(state) { return true; },
+                       toolboxPanAndZoom: null,
                        initialized: false,
                        enabled: true,
                        format: function(state) { return 'array'; },
                        resize: null,
                        setSelection: undefined, // function(state, t) { return true; },
                        clearSelection: undefined, // function(state) { return true; },
+                       toolboxPanAndZoom: null,
                        initialized: false,
                        enabled: true,
                        format: function(state) { return 'ssvcomma'; },
                        resize: null,
                        setSelection: undefined, // function(state, t) { return true; },
                        clearSelection: undefined, // function(state) { return true; },
+                       toolboxPanAndZoom: null,
                        initialized: false,
                        enabled: true,
                        format: function(state) { return 'json'; },
                        resize: null,
                        setSelection: undefined, //function(state, t) { return true; },
                        clearSelection: undefined, //function(state) { return true; },
+                       toolboxPanAndZoom: null,
                        initialized: false,
                        enabled: true,
                        format: function(state) { return 'datatable'; },
                        resize: null,
                        setSelection: undefined, // function(state, t) { return true; },
                        clearSelection: undefined, // function(state) { return true; },
+                       toolboxPanAndZoom: null,
                        initialized: false,
                        enabled: true,
                        format: function(state) { return 'json'; },
                        resize: null,
                        setSelection: undefined, // function(state, t) { return true; },
                        clearSelection: undefined, // function(state) { return true; },
+                       toolboxPanAndZoom: null,
                        initialized: false,
                        enabled: true,
                        format: function(state) { return 'csvjsonarray'; },
                        resize: null,
                        setSelection: undefined, // function(state, t) { return true; },
                        clearSelection: undefined, // function(state) { return true; },
+                       toolboxPanAndZoom: null,
                        initialized: false,
                        enabled: true,
                        format: function(state) { return 'json'; },
                        resize: null,
                        setSelection: NETDATA.easypiechartSetSelection,
                        clearSelection: NETDATA.easypiechartClearSelection,
+                       toolboxPanAndZoom: null,
                        initialized: false,
                        enabled: true,
                        format: function(state) { return 'array'; },
                        resize: null,
                        setSelection: NETDATA.gaugeSetSelection,
                        clearSelection: NETDATA.gaugeClearSelection,
+                       toolboxPanAndZoom: null,
                        initialized: false,
                        enabled: true,
                        format: function(state) { return 'array'; },
index 8a3adf321814271c8e5df14ddb6501029f515a93..662731061b55cb04d91f65a3f9e7c584f434b94d 100644 (file)
@@ -74,6 +74,43 @@ body {
        margin: 0px;
 }
 
+.netdata-legend-toolbox {
+       display: block;
+       position: absolute;
+       bottom: 0px;
+       right: 30px;
+       height: 15px;
+       width: 110px;
+       background-color: #272b30;
+       font-size: 12px;
+       vertical-align: middle;
+       line-height: 15px;
+       color: #373b40;
+       text-align: center;
+       overflow: hidden;
+       z-index: 20;
+       padding: 0px;
+       margin: 0px;
+}
+
+.netdata-legend-toolbox-button {
+       display: inline-block;
+       position: relative;
+       height: 15px;
+       width: 18px;
+       background-color: #272b30;
+       font-size: 12px;
+       vertical-align: middle;
+       line-height: 15px;
+       color: #474b50;
+       text-align: center;
+       overflow: hidden;
+       z-index: 21;
+       padding: 0px;
+       margin: 0px;
+       cursor: pointer;
+}
+
 .netdata-message {
        display: inline-block;
        text-align: left;
@@ -465,3 +502,11 @@ body {
        color: #676b70;
        font-weight: normal;
 }
+
+.popover-title {
+       font-weight: bold;
+       font-size: 12px;
+}
+.popover-content {
+       font-size: 11px;
+}
index 3e82b4ffa9fb88371f6f0ff7713a8e6dde28b153..a7c254cc67a0a11019cf2e20867f15e5cefd7820 100644 (file)
                                                                        <tr class="option-row">
                                                                                <td class="option-control"><input id="netdata_theme_control" type="checkbox" checked data-toggle="toggle" data-offstyle="danger" data-onstyle="success" data-on="Dark" data-off="White" data-width="110px"></td>
                                                                                <td class="option-info"><strong>Which theme to use?</strong><br/>
-                                                                                       <small>Netdata comes with two themes: <b>Dark</b> (the default) and <b>White</b>.</small>
+                                                                                       <small>Netdata comes with two themes: <b>Dark</b> (the default) and <b>White</b>.
+                                                                                       <br/>
+                                                                                       <b>Switching this will reload the dashboard</b>.
+                                                                                       </small>
+                                                                               </td>
+                                                                               </tr>
+                                                                       <tr class="option-row">
+                                                                               <td class="option-control"><input id="show_help" type="checkbox" checked data-toggle="toggle" data-on="Help Me" data-off="No Help" data-width="110px"></td>
+                                                                               <td class="option-info"><strong>Do you need help?</strong><br/>
+                                                                                       <small>Netdata can show some help in some areas to help you use the dashboard. If all these balloons bother you, disable them using this switch.
+                                                                                       <br/>
+                                                                                       <b>Switching this will reload the dashboard</b>.
+                                                                                       </small>
                                                                                </td>
                                                                                </tr>
                                                                        <tr class="option-row">
                                                                        <tr class="option-row">
                                                                                <td class="option-control"><input id="smooth_plot" type="checkbox" checked data-toggle="toggle"  data-on="Smooth" data-off="Rough" data-width="110px"></td>
                                                                                <td class="option-info"><strong>Enable Bézier lines on charts?</strong><br/>
-                                                                                       <small>When set to <b>Smooth</b> the charts libraries that support it, will plot smooth curves instead of simple straight lines to connect the points.</small>
+                                                                                       <small>When set to <b>Smooth</b> the charts libraries that support it, will plot smooth curves instead of simple straight lines to connect the points.
+                                                                                       <br/>
+                                                                                       Keep in mind <a href="http://dygraphs.com" target="_blank">dygraphs</a>, the main charting library in netdata dashboards, can only smooth line charts. It cannot smooth area or stacked charts. When set to <b>Rough</b>, this setting can lower the CPU resources consumed by your browser.</small>
                                                                                </td>
                                                                                </tr>
                                                                        </table>
@@ -1854,7 +1868,7 @@ function finalizePage() {
                        var self = $('#' + option);
 
                        if(self.prop('checked') !== NETDATA.getOption(option)) {
-                               // console.log('switching ' + option.toString());
+                               console.log('switching ' + option.toString());
                                self.bootstrapToggle(NETDATA.getOption(option)?'on':'off');
                        }
                }
@@ -1874,6 +1888,7 @@ function finalizePage() {
                sync_option('stop_updates_when_focus_is_lost');
                sync_option('smooth_plot');
                sync_option('pan_and_zoom_data_padding');
+               sync_option('show_help');
                theme_sync_option('netdata_theme_control');
 
                if(NETDATA.getOption('parallel_refresher') === false) {
@@ -1895,6 +1910,7 @@ function finalizePage() {
        $('#stop_updates_when_focus_is_lost').change(function() { NETDATA.setOption('stop_updates_when_focus_is_lost', $(this).prop('checked')); });
        $('#smooth_plot').change(function()                     { NETDATA.setOption('smooth_plot', $(this).prop('checked')); });
        $('#pan_and_zoom_data_padding').change(function()       { NETDATA.setOption('pan_and_zoom_data_padding', $(this).prop('checked')); });
+       $('#show_help').change(function()                       { NETDATA.setOption('show_help', $(this).prop('checked')); location.reload(); });
 
        // this has to be the last
        // it reloads the page
@@ -1913,13 +1929,18 @@ function finalizePage() {
 
        $('#updateModal').on('shown.bs.modal', function() {
                notifyForUpdate(true);
-       })
+       });
 }
 
 function resetDashboardOptions() {
+       var help = NETDATA.options.current.show_help;
+
        NETDATA.resetOptions();
        if(setTheme('slate'))
                location.reload();
+
+       if(help !== NETDATA.options.current.show_help)
+               location.reload();
 }
 
 downloadAllCharts();