aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2011-02-24 17:35:59 +0000
committerRomain d'Alverny <rda@mageia.org>2011-02-24 17:35:59 +0000
commit26956358c8eb3564ec8acaf4653969394a2d2a9d (patch)
treeb41a46d1792956c3a22c7e4f2b50ffd321d4f078
parent8638ecf933c74ea33633cf4b94a364e51709c725 (diff)
downloadmgamirrors-26956358c8eb3564ec8acaf4653969394a2d2a9d.tar
mgamirrors-26956358c8eb3564ec8acaf4653969394a2d2a9d.tar.gz
mgamirrors-26956358c8eb3564ec8acaf4653969394a2d2a9d.tar.bz2
mgamirrors-26956358c8eb3564ec8acaf4653969394a2d2a9d.tar.xz
mgamirrors-26956358c8eb3564ec8acaf4653969394a2d2a9d.zip
Update links color/weight between mirrors depending on source and bandwidth.
* the bigger the bandwidth available, the larger the link. * red links from source to Tier1 servers, blue otherwise. Could be improved (link weight depends on mirroring server output capacity, not on actual link capacity between this mirror and source mirror). Could be good to have distinct icons for source, Tier1 and Tier2 mirrors (not sure how to do that in JS, maybe using KML instead?).
-rw-r--r--root/html/pages/report/index.tt43
1 files changed, 40 insertions, 3 deletions
diff --git a/root/html/pages/report/index.tt b/root/html/pages/report/index.tt
index 5fac7ab..b52a1a8 100644
--- a/root/html/pages/report/index.tt
+++ b/root/html/pages/report/index.tt
@@ -2,6 +2,10 @@
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false">
</script>
+<style>
+div.infow { margin: 0; font-size: 70%; font-family: Helvetica, Arial, sans-serif; }
+div.infow p { margin: 0; }
+</style>
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(20,0);
@@ -12,6 +16,32 @@
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
+
+ /**
+ * Get colour for link to mirror.
+ * Tier1 mirrors are linked in red. Others are linked in blue.
+ *
+ * @param string source
+ * @return string (colour code)
+ */
+ function getStrokeColor(source) {
+ return (source == "rsync.mageia.org") ? "#FF0000" : "#0000FF";
+ }
+
+ /**
+ * Return a stroke weight after bandwidth provided.
+ * The bigger the bandwidth, their larger the stroke.
+ *
+ * @param string bw
+ * @return integer
+ */
+ function getStrokeWeight(bw) {
+ var bws = { "1Mbits": 1, "10Mbits": 2, "100Mbits": 3,
+ "1Gbits": 4, "2Gbits": 5
+ };
+ return (bw in bws) ? bws[bw] : 1;
+ }
+
[% FOREACH m = c.model('Mirrors').find_mirrors %]
[% IF m.latitude %]
var myLatlng = new google.maps.LatLng([% m.latitude %],[% m.longitude %]);
@@ -21,9 +51,12 @@
title:"[% m.hostname %]"
});
var infowindow[% loop.count %] = new google.maps.InfoWindow({
- content: '<div style="font-size: 75%">' +
+ content: '<div class="infow">' +
'<p><a href="[% c.uri_for('/mirrors', m.hostname) %]">[% m.hostname %]</a></p>' +
[% IF m.syncfrom %]
+ [% IF m.syncfrom == 'rsync.mageia.org' %]
+ '<p>Tier1 mirror.</p>' +
+ [% END %]
'<p>Sync from [% m.syncfrom %]</p>' +
[% END %]
'</div>'
@@ -37,10 +70,11 @@
var fLatLng = new google.maps.LatLng([% mf.0.latitude %], [% mf.0.longitude %]);
var flightPath = new google.maps.Polyline({
path: [ fLatLng, myLatlng ],
- strokeColor: "#FF0000",
+ strokeColor: getStrokeColor("[% m.syncfrom %]"),
strokeOpacity: 1.0,
- strokeWeight: 2
+ strokeWeight: getStrokeWeight("[% m.bandwidth %]")
});
+
flightPath.setMap(map);
[% END %]
[% END %]
@@ -51,6 +85,9 @@
</script>
<div id="map_canvas" style="width:75%; height:500px"></div>
+<p>Red links from source to Tier1 mirrors. Blue links from Tier1 mirrors
+to Tier2 mirrors.</p>
+
<script type="text/javascript">
initialize();
</script>