4 <title>Goto a host you know...</title>
5 <meta name="application-name" content="netdata">
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
10 <meta name="viewport" content="width=device-width, initial-scale=1">
11 <meta name="apple-mobile-web-app-capable" content="yes">
12 <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
16 var netdataRegistry = true;
17 var netdataRegistryAfterMs = 0;
18 var netdataTheme = 'slate';
19 var netdataShowHelp = true;
21 <script type="text/javascript" src="dashboard.js?v20170105-7"></script>
32 hasProperty: function(property) {
33 return typeof this[property] !== 'undefined';
37 function netdataQueryParse() {
38 var query = document.location.search.split('?');
39 var variables = query[1].split('&');
40 var len = variables.length;
42 var p = variables[len].split('=');
43 if(urlOptions.hasProperty(p[0]) && typeof p[1] !== 'undefined')
44 urlOptions[p[0]] = decodeURIComponent(p[1]);
47 if(typeof urlOptions.family !== 'string')
48 urlOptions.family = '';
50 if(typeof urlOptions.chart !== 'string')
51 urlOptions.chart = '';
54 function netdataURL(url) {
58 + ';chart=' + encodeURIComponent(urlOptions.chart)
59 + ';family=' + encodeURIComponent(urlOptions.family)
60 + ';alarm=' + encodeURIComponent(urlOptions.alarm)
61 + ';alarm_unique_id=' + urlOptions.alarm_unique_id.toString()
62 + ';alarm_id=' + urlOptions.alarm_id.toString()
63 + ';alarm_event_id=' + urlOptions.alarm_event_id.toString()
67 var gotoServerValidateRemaining = 0;
68 var gotoServerMiddleClick = false;
69 var gotoServerStop = false;
70 var thisIsHttps = false;
72 function gotoServerValidateUrl(id, guid, url) {
76 if(thisIsHttps === false && url.toString().startsWith('https://'))
77 // we penalize https only if the current url is http
78 // to allow the user walk through all its servers.
81 else if(thisIsHttps === true && url.toString().startsWith('http://')) {
82 error = 'can\'t check';
86 var finalURL = netdataURL(url);
88 setTimeout(function() {
89 document.getElementById('gotoServerList').innerHTML += '<tr><td style="padding-left: 20px;"><a href="' + finalURL + '" target="_blank">' + url + '</a></td><td style="padding-left: 30px;"><code id="' + guid + '-' + id + '-status">checking...</code></td></tr>';
91 NETDATA.registry.hello(url, function(data) {
92 if(typeof data !== 'undefined' && data !== null && typeof data.machine_guid === 'string' && data.machine_guid === guid) {
93 // console.log('OK ' + id + ' URL: ' + url);
94 document.getElementById(guid + '-' + id + '-status').innerHTML = "OK";
97 gotoServerStop = true;
99 if(gotoServerMiddleClick) {
100 window.open(finalURL);
101 gotoServerMiddleClick = false;
102 document.getElementById('gotoServerResponse').innerHTML = '<b>Opening new window to ' + NETDATA.registry.machines[guid].name + '<br/><a href="' + finalURL + '">' + url + '</a></b><br/>(check your pop-up blocker if it fails)';
105 document.getElementById('gotoServerResponse').innerHTML += 'found it! It is at:<br/><small>' + url + '</small>';
106 document.location = finalURL;
111 if(typeof data !== 'undefined' && data !== null && typeof data.machine_guid === 'string' && data.machine_guid !== guid)
112 error = 'wrong machine';
114 document.getElementById(guid + '-' + id + '-status').innerHTML = error;
115 gotoServerValidateRemaining--;
116 if(gotoServerValidateRemaining <= 0) {
117 gotoServerMiddleClick = false;
118 document.getElementById('gotoServerResponse').innerHTML = '<b>Sorry! I cannot find any operational URL for this server</b>';
120 if(thisIsHttps === true && urlsInHttp > 0) {
121 document.getElementById('gotoServerResponse').innerHTML += '<br/>redirecting myself to HTTP to allow checking';
122 document.location = document.location.toString().replace('https://', 'http://');
127 }, (id * 50) + penaldy);
130 var netdataRegistryCallback = function(machines_array) {
131 if(typeof urlOptions.host !== 'string') {
132 document.getElementById('bodylog').innerHTML = "Sorry... bad request.";
136 document.getElementById('message').innerHTML = 'These are the URLs this machine is known:';
138 if(document.location.toString().startsWith('https://'))
144 var len = machines_array.length;
148 if(machines_array[len].name === urlOptions.host) {
149 var ulen = machines_array[len].alternate_urls.length;
150 var guid = machines_array[len].guid;
153 gotoServerValidateRemaining = ulen;
155 var url = machines_array[len].alternate_urls[ulen];
157 gotoServerValidateUrl(count++, guid, url);
160 setTimeout(function() {
161 if(gotoServerStop === false) {
162 document.getElementById('gotoServerResponse').innerHTML = '<b>Added all the known URLs for this machine.</b>';
165 NETDATA.registry.search(guid, function(data) {
166 // console.log(data);
167 len = data.urls.length;
169 var url = data.urls[len][1];
171 if(typeof checked[url] === 'undefined') {
172 gotoServerValidateRemaining++;
174 gotoServerValidateUrl(count++, guid, url);
187 document.getElementById('bodylog').innerHTML = "Sorry... your account is not linked to a netdata server named: <b>" + urlOptions.host + '</b>';
193 <div class="container" id="">
194 <div id="bodylog" style="padding-top: 8vmax; font-size: 2.0vmax;">
195 <span id="message">Please wait...</span>
197 <div style="padding-top: 20px;">
198 <table id="gotoServerList" class="table">
201 <p style="padding-top: 10px;"><small>
202 This page can only find netdata URLs you have already visited and are linked to your account on this netdata registry.
204 <div id="gotoServerResponse" style="display: block; width: 100%; text-align: center; padding-top: 20px;"></div>