@cryptotaxi247 / netdata-1 / commits / 520fbc734

fixed dashboard issues

Costa Tsaousis (ktsaou) committed Nov 30, 2017 at 01:30 UTC 520fbc7343efa0df1719239fd0153e10d75a6383
2 files changed +404 -321
web/dashboard.js
+7 -3
@@ -1471,9 +1471,6 @@ var NETDATA = window.NETDATA || {};
1471 if (this.state === null)
1472 this.state = NETDATA.options.targets[0];
1473
1474 - if (this.hasViewport() === true)
1475 - NETDATA.globalPanAndZoom.setMaster(this.state, this.view_after, this.view_before);
1476 -
1474 if (typeof this.callback === 'function')
1475 this.callback(true, this.after, this.before);
1476 }
@@ -1491,6 +1488,10 @@ var NETDATA = window.NETDATA || {};
1488 }
1489
1490 this.init(state, after, before, view_after, view_before);
1491 +
1492 + if (this.hasViewport() === true)
1493 + NETDATA.globalPanAndZoom.setMaster(this.state, this.view_after, this.view_before);
1494 +
1495 this.setup();
1496 },
1497
@@ -1748,12 +1749,14 @@ var NETDATA = window.NETDATA || {};
1749 // functions.
1750 // if this fails, we fallback to the above
1751 init: function(timezone) {
1752 + //console.log('init with timezone: ' + timezone);
1753
1754 // detect browser timezone
1755 try {
1756 NETDATA.options.browser_timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
1757 }
1758 catch(e) {
1759 + console.log('failed to detect browser timezone: ' + e.toString());
1760 NETDATA.options.browser_timezone = 'cannot-detect-it';
1761 }
1762
@@ -1833,6 +1836,7 @@ var NETDATA = window.NETDATA || {};
1836 }
1837
1838 // save it
1839 + //console.log('init setOption timezone: ' + timezone);
1840 NETDATA.setOption('timezone', timezone);
1841
1842 return ret;
web/index.html
+397 -318
@@ -46,6 +46,12 @@
46 <meta name="twitter:image" content="https://cloud.githubusercontent.com/assets/2662304/14092712/93b039ea-f551-11e5-822c-beadbf2b2a2e.gif" />
47
48 <style>
49 +
50 + /* force the vertical window scrollbar */
51 + html {
52 + overflow-y: scroll;
53 + }
54 +
55 /* prevent body from hiding under the navbar */
56 body {
57 padding-top: 50px;
@@ -676,6 +682,9 @@
682 },
683
684 netdataPanAndZoomCallback: function(status, after, before) {
685 + //console.log(1);
686 + //console.log(new Error().stack);
687 +
688 if(netdataSnapshotData === null) {
689 urlOptions.pan_and_zoom = status;
690 urlOptions.after = after;
@@ -685,6 +694,9 @@
694 },
695
696 netdataHighlightCallback: function(status, after, before) {
697 + //console.log(2);
698 + //console.log(new Error().stack);
699 +
700 if(status === true && (after === null || before === null || after <= 0 || before <= 0 || after >= before)) {
701 status = false;
702 after = 0;
@@ -1292,8 +1304,10 @@
1304 function scrollToId(hash) {
1305 if(hash && hash !== '' && document.getElementById(hash) !== null) {
1306 var offset = $('#' + hash).offset();
1295 - if(typeof offset !== 'undefined')
1296 - $('html, body').animate({ scrollTop: offset.top - 30 }, 0);
1307 + if(typeof offset !== 'undefined') {
1308 + //console.log('scrolling to ' + hash + ' at ' + offset.top.toString());
1309 + $('html, body').animate({scrollTop: offset.top - 30}, 0);
1310 + }
1311 }
1312
1313 // we must return false to prevent the default action
@@ -3632,66 +3646,382 @@
3646 // --------------------------------------------------------------------
3647 // activate netdata on the page
3648
3649 + function dashboardSettingsSetup() {
3650 + var update_options_modal = function() {
3651 + // console.log('update_options_modal');
3652 +
3653 + var sync_option = function(option) {
3654 + var self = $('#' + option);
3655 +
3656 + if(self.prop('checked') !== NETDATA.getOption(option)) {
3657 + // console.log('switching ' + option.toString());
3658 + self.bootstrapToggle(NETDATA.getOption(option)?'on':'off');
3659 + }
3660 + };
3661 +
3662 + var theme_sync_option = function(option) {
3663 + var self = $('#' + option);
3664 +
3665 + self.bootstrapToggle(netdataTheme === 'slate'?'on':'off');
3666 + };
3667 + var units_sync_option = function(option) {
3668 + var self = $('#' + option);
3669 +
3670 + if(self.prop('checked') !== (NETDATA.getOption('units') === 'auto')) {
3671 + self.bootstrapToggle(NETDATA.getOption('units') === 'auto' ? 'on' : 'off');
3672 + }
3673 +
3674 + if(self.prop('checked') === true) {
3675 + $('#settingsLocaleTempRow').show();
3676 + $('#settingsLocaleTimeRow').show();
3677 + }
3678 + else {
3679 + $('#settingsLocaleTempRow').hide();
3680 + $('#settingsLocaleTimeRow').hide();
3681 + }
3682 + };
3683 + var temp_sync_option = function(option) {
3684 + var self = $('#' + option);
3685 +
3686 + if(self.prop('checked') !== (NETDATA.getOption('temperature') === 'celsius')) {
3687 + self.bootstrapToggle(NETDATA.getOption('temperature') === 'celsius' ? 'on' : 'off');
3688 + }
3689 + };
3690 + var timezone_sync_option = function(option) {
3691 + var self = $('#' + option);
3692 +
3693 + document.getElementById('browser_timezone').innerText = NETDATA.options.browser_timezone;
3694 + document.getElementById('server_timezone').innerText = NETDATA.options.server_timezone;
3695 + document.getElementById('current_timezone').innerText = (NETDATA.options.current.timezone === 'default')?'unset, using browser default':NETDATA.options.current.timezone;
3696 +
3697 + if(self.prop('checked') === NETDATA.dateTime.using_timezone) {
3698 + self.bootstrapToggle(NETDATA.dateTime.using_timezone ? 'off' : 'on');
3699 + }
3700 + };
3701 +
3702 + sync_option('eliminate_zero_dimensions');
3703 + sync_option('destroy_on_hide');
3704 + sync_option('async_on_scroll');
3705 + sync_option('parallel_refresher');
3706 + sync_option('concurrent_refreshes');
3707 + sync_option('sync_selection');
3708 + sync_option('sync_pan_and_zoom');
3709 + sync_option('stop_updates_when_focus_is_lost');
3710 + sync_option('smooth_plot');
3711 + sync_option('pan_and_zoom_data_padding');
3712 + sync_option('show_help');
3713 + sync_option('seconds_as_time');
3714 + theme_sync_option('netdata_theme_control');
3715 + units_sync_option('units_conversion');
3716 + temp_sync_option('units_temp');
3717 + timezone_sync_option('local_timezone');
3718 +
3719 + if(NETDATA.getOption('parallel_refresher') === false) {
3720 + $('#concurrent_refreshes_row').hide();
3721 + }
3722 + else {
3723 + $('#concurrent_refreshes_row').show();
3724 + }
3725 + };
3726 + NETDATA.setOption('setOptionCallback', update_options_modal);
3727 +
3728 + // handle options changes
3729 + $('#eliminate_zero_dimensions').change(function() { NETDATA.setOption('eliminate_zero_dimensions', $(this).prop('checked')); });
3730 + $('#destroy_on_hide').change(function() { NETDATA.setOption('destroy_on_hide', $(this).prop('checked')); });
3731 + $('#async_on_scroll').change(function() { NETDATA.setOption('async_on_scroll', $(this).prop('checked')); });
3732 + $('#parallel_refresher').change(function() { NETDATA.setOption('parallel_refresher', $(this).prop('checked')); });
3733 + $('#concurrent_refreshes').change(function() { NETDATA.setOption('concurrent_refreshes', $(this).prop('checked')); });
3734 + $('#sync_selection').change(function() { NETDATA.setOption('sync_selection', $(this).prop('checked')); });
3735 + $('#sync_pan_and_zoom').change(function() { NETDATA.setOption('sync_pan_and_zoom', $(this).prop('checked')); });
3736 + $('#stop_updates_when_focus_is_lost').change(function() {
3737 + urlOptions.update_always = !$(this).prop('checked');
3738 + urlOptions.hashUpdate();
3739 +
3740 + NETDATA.setOption('stop_updates_when_focus_is_lost', !urlOptions.update_always);
3741 + });
3742 + $('#smooth_plot').change(function() { NETDATA.setOption('smooth_plot', $(this).prop('checked')); });
3743 + $('#pan_and_zoom_data_padding').change(function() { NETDATA.setOption('pan_and_zoom_data_padding', $(this).prop('checked')); });
3744 + $('#seconds_as_time').change(function() { NETDATA.setOption('seconds_as_time', $(this).prop('checked')); });
3745 + $('#local_timezone').change(function() {
3746 + if($(this).prop('checked'))
3747 + selected_server_timezone('default', true);
3748 + else
3749 + selected_server_timezone('default', false);
3750 + });
3751 +
3752 +
3753 + $('#units_conversion').change(function() {
3754 + NETDATA.setOption('units', $(this).prop('checked')?'auto':'original');
3755 + });
3756 + $('#units_temp').change(function() {
3757 + NETDATA.setOption('temperature', $(this).prop('checked')?'celsius':'fahrenheit');
3758 + });
3759 +
3760 + $('#show_help').change(function() {
3761 + urlOptions.help = $(this).prop('checked');
3762 + urlOptions.hashUpdate();
3763 +
3764 + NETDATA.setOption('show_help', urlOptions.help);
3765 + netdataReload();
3766 + });
3767 +
3768 + // this has to be the last
3769 + // it reloads the page
3770 + $('#netdata_theme_control').change(function() {
3771 + urlOptions.theme = $(this).prop('checked')?'slate':'white';
3772 + urlOptions.hashUpdate();
3773 +
3774 + if(setTheme(urlOptions.theme))
3775 + netdataReload();
3776 + });
3777 + }
3778 +
3779 + function scrollDashboardTo() {
3780 + if(netdataSnapshotData !== null && typeof netdataSnapshotData.hash !== 'undefined') {
3781 + //console.log(netdataSnapshotData.hash);
3782 + scrollToId(netdataSnapshotData.hash.replace('#',''));
3783 + }
3784 + else {
3785 + // check if we have to jump to a specific section
3786 + scrollToId(urlOptions.hash.replace('#', ''));
3787 +
3788 + if (urlOptions.chart !== null) {
3789 + NETDATA.alarms.scrollToChart(urlOptions.chart);
3790 + //urlOptions.hash = '#' + NETDATA.name2id('menu_' + charts[c].menu + '_submenu_' + charts[c].submenu);
3791 + //urlOptions.hash = '#chart_' + NETDATA.name2id(urlOptions.chart);
3792 + //console.log('hash = ' + urlOptions.hash);
3793 + }
3794 + }
3795 + }
3796 +
3797 var runOnceOnDashboardLastRun = 0;
3798 function runOnceOnDashboardWithjQuery() {
3637 - if(runOnceOnDashboardLastRun !== 0)
3799 + if(runOnceOnDashboardLastRun !== 0) {
3800 + scrollDashboardTo();
3801 +
3802 + // restore the scrollspy at the proper position
3803 + $(document.body).scrollspy('refresh');
3804 + $(document.body).scrollspy('process');
3805 +
3806 return;
3807 + }
3808
3809 runOnceOnDashboardLastRun = Date.now();
3810
3811 + // ------------------------------------------------------------------------
3812 + // bootstrap modals
3813 +
3814 // prevent bootstrap modals from scrolling the page
3815 // maintains the current scroll position
3816 // https://stackoverflow.com/a/34754029/4525767
3817
3818 var scrollPos = 0;
3647 - var modal_shown = false;
3648 - var netdata_paused_on_modal = false;
3819 + var modal_depth = 0; // how many modals are currently open
3820 + var modal_shown = false; // set to true, if a modal is shown
3821 + var netdata_paused_on_modal = false; // set to true, if the modal paused netdata
3822 + var scrollspyOffset = $(window).height() / 3; // will be updated below - the offset of scrollspy to select an item
3823 +
3824 $('.modal')
3825 .on('show.bs.modal', function () {
3651 - scrollPos = window.scrollY;
3826 + if(modal_depth === 0) {
3827 + scrollPos = window.scrollY;
3828
3653 - $('body').css({
3654 - overflow: 'hidden',
3655 - position: 'fixed',
3656 - top: -scrollPos
3657 - });
3829 + $('body').css({
3830 + overflow: 'hidden',
3831 + position: 'fixed',
3832 + top: -scrollPos
3833 + });
3834
3659 - modal_shown = true;
3835 + modal_shown = true;
3836
3661 - if(NETDATA.options.pauseCallback === null) {
3662 - NETDATA.pause(function() {});
3663 - netdata_paused_on_modal = true;
3837 + if (NETDATA.options.pauseCallback === null) {
3838 + NETDATA.pause(function () {});
3839 + netdata_paused_on_modal = true;
3840 + }
3841 + else
3842 + netdata_paused_on_modal = false;
3843 }
3665 - else
3666 - netdata_paused_on_modal = false;
3844 +
3845 + modal_depth++;
3846 + //console.log(urlOptions.after);
3847 +
3848 })
3849 .on('hide.bs.modal', function () {
3850
3670 - $('body')
3671 - .css({
3672 - overflow: '',
3673 - position: '',
3674 - top: ''
3675 - });
3851 + modal_depth--;
3852
3677 - $('html, body')
3678 - .animate({ scrollTop: scrollPos }, 0);
3853 + if(modal_depth <= 0) {
3854 + modal_depth = 0;
3855
3680 - modal_shown = false;
3856 + $('body')
3857 + .css({
3858 + overflow: '',
3859 + position: '',
3860 + top: ''
3861 + });
3862
3682 - if(netdata_paused_on_modal === true) {
3683 - NETDATA.unpause();
3684 - netdata_paused_on_modal = false;
3863 + // scroll to the position we had open before the modal
3864 + $('html, body')
3865 + .animate({scrollTop: scrollPos}, 0);
3866 +
3867 + // unpause netdata, if we paused it
3868 + if (netdata_paused_on_modal === true) {
3869 + NETDATA.unpause();
3870 + netdata_paused_on_modal = false;
3871 + }
3872 +
3873 + // restore the scrollspy at the proper position
3874 + $(document.body).scrollspy('process');
3875 + }
3876 + //console.log(urlOptions.after);
3877 + })
3878 + .on('hidden.bs.modal', function () {
3879 + if(modal_depth === 0)
3880 + modal_shown = false;
3881 + //console.log(urlOptions.after);
3882 + });
3883 +
3884 +
3885 + // ------------------------------------------------------------------------
3886 + // sidebar / affix
3887 +
3888 + $('#sidebar')
3889 + .affix({
3890 + offset: {
3891 + top: (isdemo())?150:0,
3892 + bottom: 0
3893 + }
3894 + })
3895 + .on('affixed.bs.affix', function() {
3896 + // fix scrolling of very long affix lists
3897 + // http://stackoverflow.com/questions/21691585/bootstrap-3-1-0-affix-too-long
3898 +
3899 + $(this).removeAttr('style');
3900 + })
3901 + .on( 'affix-top.bs.affix', function() {
3902 + // fix bootstrap affix click bug
3903 + // https://stackoverflow.com/a/37847981/4525767
3904 +
3905 + if(modal_shown) return false;
3906 + })
3907 + .on('activate.bs.scrollspy', function (e) {
3908 + // change the URL based on the current position of the screen
3909 +
3910 + if(modal_shown === false) {
3911 + var el = $(e.target);
3912 + var hash = el.find('a').attr('href');
3913 + if (typeof hash === 'string' && hash.substring(0, 1) === '#' && urlOptions.hash.startsWith(hash + '_submenu_') === false) {
3914 + urlOptions.hash = hash;
3915 + urlOptions.hashUpdate();
3916 + }
3917 }
3918 });
3919
3920 + Ps.initialize(document.getElementById('sidebar'), {
3921 + wheelSpeed: 0.5,
3922 + wheelPropagation: true,
3923 + swipePropagation: true,
3924 + minScrollbarLength: null,
3925 + maxScrollbarLength: null,
3926 + useBothWheelAxes: false,
3927 + suppressScrollX: true,
3928 + suppressScrollY: false,
3929 + scrollXMarginOffset: 0,
3930 + scrollYMarginOffset: 0,
3931 + theme: 'default'
3932 + });
3933 +
3934 +
3935 + // ------------------------------------------------------------------------
3936 + // scrollspy
3937 +
3938 + if(scrollspyOffset > 250) scrollspyOffset = 250;
3939 + if(scrollspyOffset < 75) scrollspyOffset = 75;
3940 + document.body.setAttribute('data-offset', scrollspyOffset);
3941 +
3942 + // scroll the dashboard, before activating the scrollspy, so that our
3943 + // hash will not be updated before we got the chance to scroll to it
3944 + scrollDashboardTo();
3945 +
3946 + $(document.body).scrollspy({
3947 + target: '#sidebar',
3948 + offset: scrollspyOffset // controls the diff of the <hX> element to the top, to select it
3949 + });
3950 +
3951 +
3952 + // ------------------------------------------------------------------------
3953 + // my-netdata menu
3954 +
3955 + Ps.initialize(document.getElementById('myNetdataDropdownUL'), {
3956 + wheelSpeed: 1,
3957 + wheelPropagation: false,
3958 + swipePropagation: false,
3959 + minScrollbarLength: null,
3960 + maxScrollbarLength: null,
3961 + useBothWheelAxes: false,
3962 + suppressScrollX: true,
3963 + suppressScrollY: false,
3964 + scrollXMarginOffset: 0,
3965 + scrollYMarginOffset: 0,
3966 + theme: 'default'
3967 + });
3968 +
3969 + $('#myNetdataDropdownParent')
3970 + .on('show.bs.dropdown', function () {
3971 + var hash = urlOptions.genHash();
3972 + $('.registry_link').each(function(idx) {
3973 + this.setAttribute('href', this.getAttribute("href").replace(/#.*$/, hash));
3974 + });
3975 +
3976 + NETDATA.pause(function() {});
3977 + })
3978 + .on('shown.bs.dropdown', function () {
3979 + Ps.update(document.getElementById('myNetdataDropdownUL'));
3980 + })
3981 + .on('hidden.bs.dropdown', function () {
3982 + NETDATA.unpause();
3983 + });
3984 +
3985 +
3986 + $('#deleteRegistryModal')
3987 + .on('hidden.bs.modal', function() {
3988 + deleteRegistryGuid = null;
3989 + });
3990 +
3991 +
3992 + // ------------------------------------------------------------------------
3993 + // update modal
3994 +
3995 + $('#updateModal')
3996 + .on('show.bs.modal', function() {
3997 + versionLog('checking, please wait...');
3998 + })
3999 + .on('shown.bs.modal', function() {
4000 + notifyForUpdate(true);
4001 + });
4002 +
4003 +
4004 + // ------------------------------------------------------------------------
4005 + // alarms modal
4006 +
4007 + $('#alarmsModal')
4008 + .on('shown.bs.modal', function() {
4009 + alarmsUpdateModal();
4010 + })
4011 + .on('hidden.bs.modal', function() {
4012 + document.getElementById('alarms_active').innerHTML =
4013 + document.getElementById('alarms_all').innerHTML =
4014 + document.getElementById('alarms_log').innerHTML =
4015 + 'loading...';
4016 + });
4017 +
4018 +
4019 // ------------------------------------------------------------------------
3689 - // fix bootstrap affix click bug
3690 - // https://stackoverflow.com/a/37847981/4525767
4020
3692 - $( '#sidebar' ).on( 'affix-top.bs.affix', function() {
3693 - if(modal_shown) return false;
3694 - } );
4021 + dashboardSettingsSetup();
4022 + loadSnapshotDragAndDropSetup();
4023 + saveSnapshotModalSetup();
4024 + showPageFooter();
4025
4026
4027 // ------------------------------------------------------------------------
@@ -3829,83 +4159,31 @@
4159 }
4160
4161 function finalizePage() {
3832 - runOnceOnDashboardWithjQuery();
3833 -
4162 // resize all charts - without starting the background thread
4163 // this has to be done while NETDATA is paused
4164 // if we ommit this, the affix menu will be wrong, since all
4165 // the Dom elements are initially zero-sized
4166 NETDATA.parseDom();
4167
3840 - if(urlOptions.pan_and_zoom === true && NETDATA.options.targets.length > 0)
3841 - NETDATA.globalPanAndZoom.setMaster(NETDATA.options.targets[0], urlOptions.after, urlOptions.before);
3842 -
4168 // ------------------------------------------------------------------------
4169
3845 - $(".shorten").shorten();
4170 + NETDATA.globalPanAndZoom.callback = null;
4171 + NETDATA.globalChartUnderlay.callback = null;
4172
3847 - // ------------------------------------------------------------------------
4173 + if(urlOptions.pan_and_zoom === true && NETDATA.options.targets.length > 0)
4174 + NETDATA.globalPanAndZoom.setMaster(NETDATA.options.targets[0], urlOptions.after, urlOptions.before);
4175
4176 // callback for us to track PanAndZoom operations
4177 NETDATA.globalPanAndZoom.callback = urlOptions.netdataPanAndZoomCallback;
4178 NETDATA.globalChartUnderlay.callback = urlOptions.netdataHighlightCallback;
4179
4180 + // ------------------------------------------------------------------------
4181 +
4182 // let it run (update the charts)
4183 NETDATA.unpause();
4184
3856 - // check if we have to jump to a specific section
3857 - scrollToId(urlOptions.hash.replace('#',''));
3858 -
3859 - if(urlOptions.chart !== null) {
3860 - NETDATA.alarms.scrollToChart(urlOptions.chart);
3861 - //urlOptions.hash = '#' + NETDATA.name2id('menu_' + charts[c].menu + '_submenu_' + charts[c].submenu);
3862 - //urlOptions.hash = '#chart_' + NETDATA.name2id(urlOptions.chart);
3863 - //console.log('hash = ' + urlOptions.hash);
3864 - }
3865 -
3866 - var $sidebar = $('#sidebar');
3867 - /* activate bootstrap sidebar (affix) */
3868 - $sidebar.affix({
3869 - offset: {
3870 - top: (isdemo())?150:0,
3871 - bottom: 0
3872 - }
3873 - });
3874 -
3875 - /* fix scrolling of very long affix lists
3876 - http://stackoverflow.com/questions/21691585/bootstrap-3-1-0-affix-too-long
3877 - */
3878 - $sidebar.on('affixed.bs.affix', function() {
3879 - $(this).removeAttr('style');
3880 - });
3881 -
3882 - /* activate bootstrap scrollspy (needed for sidebar) */
3883 - var scrollspyOffset = $(window).height() / 3;
3884 - if(scrollspyOffset > 250) scrollspyOffset = 250;
3885 - if(scrollspyOffset < 75) scrollspyOffset = 75;
3886 - document.body.setAttribute('data-offset', scrollspyOffset);
3887 - // console.log(scrollspyOffset);
3888 - $(document.body).scrollspy({
3889 - target: '#sidebar',
3890 - offset: scrollspyOffset // controls the diff of the <hX> element to the top, to select it
3891 - });
3892 -
3893 - // change the URL based on the current position of the screen
3894 - $sidebar.on('activate.bs.scrollspy', function (e) {
3895 - //console.log(e);
3896 - var el = $(e.target);
3897 - //if(el.find('ul').size() === 0) {
3898 - var hash = el.find('a').attr('href');
3899 - // console.log(hash);
3900 - if(typeof hash === 'string' && hash.substring(0, 1) === '#' && urlOptions.hash.startsWith(hash + '_submenu_') === false) {
3901 - urlOptions.hash = hash;
3902 - //console.log(urlOptions.hash);
3903 - urlOptions.hashUpdate();
3904 - }
3905 - //else console.log('hash: not accepting ' + hash);
3906 - //}
3907 - //else console.log('el.find(): not found');
3908 - });
4185 + runOnceOnDashboardWithjQuery();
4186 + $(".shorten").shorten();
4187
4188 $('[data-toggle="tooltip"]').tooltip({
4189 animated: 'fade',
@@ -3916,162 +4194,6 @@
4194 });
4195 $('[data-toggle="popover"]').popover();
4196
3919 - loadSnapshotDragAndDropSetup();
3920 - saveSnapshotModalSetup();
3921 - showPageFooter();
3922 -
3923 - var update_options_modal = function() {
3924 - // console.log('update_options_modal');
3925 -
3926 - var sync_option = function(option) {
3927 - var self = $('#' + option);
3928 -
3929 - if(self.prop('checked') !== NETDATA.getOption(option)) {
3930 - // console.log('switching ' + option.toString());
3931 - self.bootstrapToggle(NETDATA.getOption(option)?'on':'off');
3932 - }
3933 - };
3934 -
3935 - var theme_sync_option = function(option) {
3936 - var self = $('#' + option);
3937 -
3938 - self.bootstrapToggle(netdataTheme === 'slate'?'on':'off');
3939 - };
3940 - var units_sync_option = function(option) {
3941 - var self = $('#' + option);
3942 -
3943 - if(self.prop('checked') !== (NETDATA.getOption('units') === 'auto')) {
3944 - self.bootstrapToggle(NETDATA.getOption('units') === 'auto' ? 'on' : 'off');
3945 - }
3946 -
3947 - if(self.prop('checked') === true) {
3948 - $('#settingsLocaleTempRow').show();
3949 - $('#settingsLocaleTimeRow').show();
3950 - }
3951 - else {
3952 - $('#settingsLocaleTempRow').hide();
3953 - $('#settingsLocaleTimeRow').hide();
3954 - }
3955 - };
3956 - var temp_sync_option = function(option) {
3957 - var self = $('#' + option);
3958 -
3959 - if(self.prop('checked') !== (NETDATA.getOption('temperature') === 'celsius')) {
3960 - self.bootstrapToggle(NETDATA.getOption('temperature') === 'celsius' ? 'on' : 'off');
3961 - }
3962 - };
3963 - var timezone_sync_option = function(option) {
3964 - var self = $('#' + option);
3965 -
3966 - document.getElementById('browser_timezone').innerText = NETDATA.options.browser_timezone;
3967 - document.getElementById('server_timezone').innerText = NETDATA.options.server_timezone;
3968 - document.getElementById('current_timezone').innerText = (NETDATA.options.current.timezone === 'default')?'unset, using browser default':NETDATA.options.current.timezone;
3969 -
3970 - if(self.prop('checked') === NETDATA.dateTime.using_timezone) {
3971 - self.bootstrapToggle(NETDATA.dateTime.using_timezone ? 'off' : 'on');
3972 - }
3973 - };
3974 -
3975 - sync_option('eliminate_zero_dimensions');
3976 - sync_option('destroy_on_hide');
3977 - sync_option('async_on_scroll');
3978 - sync_option('parallel_refresher');
3979 - sync_option('concurrent_refreshes');
3980 - sync_option('sync_selection');
3981 - sync_option('sync_pan_and_zoom');
3982 - sync_option('stop_updates_when_focus_is_lost');
3983 - sync_option('smooth_plot');
3984 - sync_option('pan_and_zoom_data_padding');
3985 - sync_option('show_help');
3986 - sync_option('seconds_as_time');
3987 - theme_sync_option('netdata_theme_control');
3988 - units_sync_option('units_conversion');
3989 - temp_sync_option('units_temp');
3990 - timezone_sync_option('local_timezone');
3991 -
3992 - if(NETDATA.getOption('parallel_refresher') === false) {
3993 - $('#concurrent_refreshes_row').hide();
3994 - }
3995 - else {
3996 - $('#concurrent_refreshes_row').show();
3997 - }
3998 - };
3999 - NETDATA.setOption('setOptionCallback', update_options_modal);
4000 -
4001 - // handle options changes
4002 - $('#eliminate_zero_dimensions').change(function() { NETDATA.setOption('eliminate_zero_dimensions', $(this).prop('checked')); });
4003 - $('#destroy_on_hide').change(function() { NETDATA.setOption('destroy_on_hide', $(this).prop('checked')); });
4004 - $('#async_on_scroll').change(function() { NETDATA.setOption('async_on_scroll', $(this).prop('checked')); });
4005 - $('#parallel_refresher').change(function() { NETDATA.setOption('parallel_refresher', $(this).prop('checked')); });
4006 - $('#concurrent_refreshes').change(function() { NETDATA.setOption('concurrent_refreshes', $(this).prop('checked')); });
4007 - $('#sync_selection').change(function() { NETDATA.setOption('sync_selection', $(this).prop('checked')); });
4008 - $('#sync_pan_and_zoom').change(function() { NETDATA.setOption('sync_pan_and_zoom', $(this).prop('checked')); });
4009 - $('#stop_updates_when_focus_is_lost').change(function() {
4010 - urlOptions.update_always = !$(this).prop('checked');
4011 - urlOptions.hashUpdate();
4012 -
4013 - NETDATA.setOption('stop_updates_when_focus_is_lost', !urlOptions.update_always);
4014 - });
4015 - $('#smooth_plot').change(function() { NETDATA.setOption('smooth_plot', $(this).prop('checked')); });
4016 - $('#pan_and_zoom_data_padding').change(function() { NETDATA.setOption('pan_and_zoom_data_padding', $(this).prop('checked')); });
4017 - $('#seconds_as_time').change(function() { NETDATA.setOption('seconds_as_time', $(this).prop('checked')); });
4018 - $('#local_timezone').change(function() {
4019 - if($(this).prop('checked'))
4020 - selected_server_timezone('default', true);
4021 - else
4022 - selected_server_timezone('default', false);
4023 - });
4024 -
4025 -
4026 - $('#units_conversion').change(function() {
4027 - NETDATA.setOption('units', $(this).prop('checked')?'auto':'original');
4028 - });
4029 - $('#units_temp').change(function() {
4030 - NETDATA.setOption('temperature', $(this).prop('checked')?'celsius':'fahrenheit');
4031 - });
4032 -
4033 - $('#show_help').change(function() {
4034 - urlOptions.help = $(this).prop('checked');
4035 - urlOptions.hashUpdate();
4036 -
4037 - NETDATA.setOption('show_help', urlOptions.help);
4038 - netdataReload();
4039 - });
4040 -
4041 - // this has to be the last
4042 - // it reloads the page
4043 - $('#netdata_theme_control').change(function() {
4044 - urlOptions.theme = $(this).prop('checked')?'slate':'white';
4045 - urlOptions.hashUpdate();
4046 -
4047 - if(setTheme(urlOptions.theme))
4048 - netdataReload();
4049 - });
4050 -
4051 - var $updateModal = $('#updateModal');
4052 - $updateModal.on('show.bs.modal', function() {
4053 - versionLog('checking, please wait...');
4054 - });
4055 -
4056 - $updateModal.on('shown.bs.modal', function() {
4057 - notifyForUpdate(true);
4058 - });
4059 -
4060 - var $alarmsModal = $('#alarmsModal');
4061 - $alarmsModal.on('shown.bs.modal', function() {
4062 - alarmsUpdateModal();
4063 - });
4064 -
4065 - $alarmsModal.on('hidden.bs.modal', function() {
4066 - document.getElementById('alarms_active').innerHTML =
4067 - document.getElementById('alarms_all').innerHTML =
4068 - document.getElementById('alarms_log').innerHTML =
4069 - 'loading...';
4070 - });
4071 -
4072 - $('#deleteRegistryModal').on('hidden.bs.modal', function() {
4073 - deleteRegistryGuid = null;
4074 - });
4197
4198 if(isdemo()) {
4199 // do not to give errors on netdata demo servers for 60 seconds
@@ -4100,58 +4222,11 @@
4222 if(urlOptions.show_alarms === true)
4223 setTimeout(function() { $('#alarmsModal').modal('show'); }, 1000);
4224
4103 - var sidebar = document.getElementById('sidebar');
4104 - Ps.initialize(sidebar, {
4105 - wheelSpeed: 0.5,
4106 - wheelPropagation: true,
4107 - swipePropagation: true,
4108 - minScrollbarLength: null,
4109 - maxScrollbarLength: null,
4110 - useBothWheelAxes: false,
4111 - suppressScrollX: true,
4112 - suppressScrollY: false,
4113 - scrollXMarginOffset: 0,
4114 - scrollYMarginOffset: 0,
4115 - theme: 'default'
4116 - });
4117 - Ps.update(sidebar);
4118 -
4119 - var registry = document.getElementById('myNetdataDropdownUL');
4120 - Ps.initialize(registry, {
4121 - wheelSpeed: 1,
4122 - wheelPropagation: false,
4123 - swipePropagation: false,
4124 - minScrollbarLength: null,
4125 - maxScrollbarLength: null,
4126 - useBothWheelAxes: false,
4127 - suppressScrollX: true,
4128 - suppressScrollY: false,
4129 - scrollXMarginOffset: 0,
4130 - scrollYMarginOffset: 0,
4131 - theme: 'default'
4132 - });
4133 - Ps.update(registry);
4134 -
4225 NETDATA.onresizeCallback = function() {
4136 - Ps.update(sidebar);
4137 - Ps.update(registry);
4226 + Ps.update(document.getElementById('sidebar'));
4227 + Ps.update(document.getElementById('myNetdataDropdownUL'));
4228 };
4139 -
4140 - $('#myNetdataDropdownParent')
4141 - .on('show.bs.dropdown', function () {
4142 - var hash = urlOptions.genHash();
4143 - $('.registry_link').each(function(idx) {
4144 - this.setAttribute('href', this.getAttribute("href").replace(/#.*$/, hash));
4145 - });
4146 -
4147 - NETDATA.pause(function() {});
4148 - })
4149 - .on('shown.bs.dropdown', function () {
4150 - Ps.update(registry);
4151 - })
4152 - .on('hidden.bs.dropdown', function () {
4153 - NETDATA.unpause();
4154 - });
4229 + NETDATA.onresizeCallback();
4230
4231 if(netdataSnapshotData !== null) {
4232 NETDATA.globalPanAndZoom.setMaster(NETDATA.options.targets[0], netdataSnapshotData.after_ms, netdataSnapshotData.before_ms);
@@ -4201,7 +4276,7 @@
4276 };
4277
4278 var selected_server_timezone = function(timezone, status) {
4204 - // console.log(timezone + " " + ((typeof status === 'undefined')?'undefined':status).toString());
4279 + //console.log('called with timezone: ' + timezone + ", status: " + ((typeof status === 'undefined')?'undefined':status).toString());
4280
4281 // clear the error
4282 document.getElementById('timezone_error_message').innerHTML = '';
@@ -4209,6 +4284,8 @@
4284 if (typeof status === 'undefined') {
4285 // the user selected a timezone from the menu
4286
4287 + NETDATA.setOption('user_set_server_timezone', timezone);
4288 +
4289 if (NETDATA.dateTime.init(timezone) === false) {
4290 NETDATA.dateTime.init();
4291
@@ -4219,30 +4296,32 @@
4296 NETDATA.setOption('user_set_server_timezone', NETDATA.options.server_timezone);
4297 }
4298 else {
4222 - NETDATA.setOption('user_set_server_timezone', timezone);
4223 -
4299 if($('#local_timezone').prop('checked'))
4300 $('#local_timezone').bootstrapToggle('off');
4301 }
4302 }
4303 + else if (status === true) {
4304 + // the user wants the browser default timezone to be activated
4305 +
4306 + NETDATA.dateTime.init();
4307 + }
4308 else {
4229 - if (status === true) {
4230 - NETDATA.dateTime.init();
4231 - }
4232 - else {
4233 - if (NETDATA.options.current.user_set_server_timezone === 'default')
4234 - NETDATA.options.current.user_set_server_timezone = NETDATA.options.server_timezone;
4309 + // the user wants the server default timezone to be activated
4310 + //console.log('found ' + NETDATA.options.current.user_set_server_timezone);
4311
4236 - timezone = NETDATA.options.current.user_set_server_timezone;
4237 - if (NETDATA.dateTime.init(timezone) === false) {
4238 - NETDATA.dateTime.init();
4312 + if (NETDATA.options.current.user_set_server_timezone === 'default')
4313 + NETDATA.options.current.user_set_server_timezone = NETDATA.options.server_timezone;
4314
4240 - if(!$('#local_timezone').prop('checked'))
4241 - $('#local_timezone').bootstrapToggle('on');
4315 + timezone = NETDATA.options.current.user_set_server_timezone;
4316
4243 - document.getElementById('timezone_error_message').innerHTML = 'Sorry. The timezone "' + timezone.toString() + '" is not accepted by your browser. Please select one from the list.';
4244 - NETDATA.setOption('user_set_server_timezone', NETDATA.options.server_timezone);
4245 - }
4317 + if (NETDATA.dateTime.init(timezone) === false) {
4318 + NETDATA.dateTime.init();
4319 +
4320 + if(!$('#local_timezone').prop('checked'))
4321 + $('#local_timezone').bootstrapToggle('on');
4322 +
4323 + document.getElementById('timezone_error_message').innerHTML = 'Sorry. The timezone "' + timezone.toString() + '" is not accepted by your browser. Please select one from the list.';
4324 + NETDATA.setOption('user_set_server_timezone', NETDATA.options.server_timezone);
4325 }
4326 }
4327
@@ -5462,6 +5541,6 @@
5541 </div>
5542 </div>
5543 <div id="hiddenDownloadLinks" style="display: none;" hidden></div>
5465 - <script type="text/javascript" src="dashboard.js?v20171122-3"></script>
5544 + <script type="text/javascript" src="dashboard.js?v20171130-1"></script>
5545 </body>
5546 </html>