From: Costa Tsaousis (ktsaou) Date: Wed, 8 Jun 2016 21:56:13 +0000 (+0300) Subject: browser history is preserved while scrolling and navigating the dashboard; current... X-Git-Tag: v1.3.0~149^2~2 X-Git-Url: https://arthur.barton.de/gitweb/?a=commitdiff_plain;h=dfcdde046dd09cbafcef7ca104db7c32a41fe0da;p=netdata.git browser history is preserved while scrolling and navigating the dashboard; current position is propagated between registry servers; middle mouse button working on registry servers --- diff --git a/web/index.html b/web/index.html index cb92af5a..b2129c41 100644 --- a/web/index.html +++ b/web/index.html @@ -390,7 +390,7 @@ while(len--) { var u = machines[len]; found++; - el += '
  • ' + u.name + '
  • '; + el += '
  • ' + u.name + '
  • '; a1 += '
  • '; } } @@ -422,6 +422,8 @@ document.getElementById('mynetdata_servers').innerHTML = el; document.getElementById('mynetdata_servers2').innerHTML = el; document.getElementById('mynetdata_actions1').innerHTML = a1; + + gotoServerInit(); }; @@ -1019,6 +1021,8 @@ if(isdemo()) { document.getElementById('masthead').style.display = 'block'; } var gotoServerValidateRemaining = 0; +var gotoServerMiddleClick = false; +var gotoServerStop = false; function gotoServerValidateUrl(id, guid, url) { var penaldy = 0; if(document.location.toString().startsWith('http://') && url.toString().startsWith('https://')) @@ -1028,25 +1032,41 @@ function gotoServerValidateUrl(id, guid, url) { setTimeout(function() { document.getElementById('gotoServerList').innerHTML += '' + url + 'checking...'; + NETDATA.registry.hello(url, function(data) { if (data) { - console.log('OK ' + id + ' URL: ' + url); + // console.log('OK ' + id + ' URL: ' + url); document.getElementById(guid + '-' + id + '-status').innerHTML = "OK"; - document.location = url; + var hash = document.location.hash || ''; + + if(!gotoServerStop) { + gotoServerStop = true; + + if(gotoServerMiddleClick) { + window.open(url + hash, '_blank'); + gotoServerMiddleClick = false; + document.getElementById('gotoServerResponse').innerHTML = 'Opening new window to ' + NETDATA.registry.machines[guid].name + '
    ' + url + hash + '

    (check your pop-up blocker if it fails)'; + } + else + document.location = url + hash; + } } else { document.getElementById(guid + '-' + id + '-status').innerHTML = "failed!"; gotoServerValidateRemaining--; - if(gotoServerValidateRemaining <= 0) + if(gotoServerValidateRemaining <= 0) { + gotoServerMiddleClick = false; document.getElementById('gotoServerResponse').innerHTML = 'Sorry! I cannot find any operational URL for this server'; + } } }); }, (id * 50) + penaldy); } function gotoServerModalHandler(guid) { - console.log('goto server: ' + guid); + // console.log('goto server: ' + guid); + gotoServerStop = false; var len = NETDATA.registry.machines[guid].alternate_urls.length; document.getElementById('gotoServerResponse').innerHTML = ''; @@ -1061,6 +1081,17 @@ function gotoServerModalHandler(guid) { return false; } +function gotoServerInit() { + $(".registry_link").on('click', function(e) { + if(e.which == 2) { + e.preventDefault(); + gotoServerMiddleClick = true; + } + else + gotoServerMiddleClick = false; + }); +} + function switchRegistryModalHandler() { document.getElementById('switchRegistryPersonGUID').value = NETDATA.registry.person_guid; document.getElementById('switchRegistryURL').innerHTML = NETDATA.registry.server; @@ -1124,7 +1155,7 @@ var options = { chartsPerRow: 0, chartsMinWidth: 1450, chartsHeight: 180, - sparklinesHeight: 60 + sparklinesHeight: 60, }; // generate a sparkline @@ -1184,6 +1215,21 @@ function sortObjectByPriority(object) { return sorted; } + +// ---------------------------------------------------------------------------- +// scroll to a section, without changing the browser history + +function scrollToId(hash) { + if(hash && hash != '') { + var offset = $('#' + hash).offset(); + if(typeof offset !== 'undefined') + $('html, body').animate({ scrollTop: offset.top }, 0); + } + + // we must return false to prevent the default action + return false; +} + // ---------------------------------------------------------------------------- function gaugeChart(title, width, dimensions, colors) { @@ -1953,7 +1999,7 @@ function renderPage(menus, data) { // generate an entry at the main menu var menuid = name2id(menu); - sidebar += '
  • ' + menus[menu].title + '