]> arthur.barton.de Git - netdata.git/commitdiff
sorted list of mirrored machines
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 12 Mar 2017 12:50:44 +0000 (14:50 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 12 Mar 2017 12:50:44 +0000 (14:50 +0200)
web/index.html

index 8f6dca018e39fdf49398aa26c6b9cca964a30f22..a254aa83907e547500c39e3b51ac8c78b4022cf7 100644 (file)
             var len, i, url, hostname, icon;
 
             if(options.hosts.length > 1) {
+                // there are mirrored hosts here
+
                 el += '<li><a href="#" onClick="return false;" style="color: #666;" target="_blank">databases available on this host</a></li>';
                 a1 += '<li><a href="#" onClick="return false;"><i class="fa fa-info-circle" aria-hidden="true" style="color: #666;"></i></a></li>';
 
                 if(base.endsWith("/"))
                     base = base.substring(0, base.length - 1);
 
+                var master = options.hosts[0].hostname;
+                var sorted = options.hosts.sort(function(a, b) {
+                    if(a.hostname === master) return -1;
+                    if(a.hostname === b.hostname) return 0;
+                    else if(a.hostname > b.hostname) return 1;
+                    return -1;
+                });
+
                 i = 0;
-                len = options.hosts.length;
+                len = sorted.length;
                 while(len--) {
-                    hostname = options.hosts[i].hostname;
-                    if(i == 0) {
+                    hostname = sorted[i].hostname;
+                    if(hostname == master) {
                         url = base + "/";
                         icon = "home";
                     }