aboutsummaryrefslogtreecommitdiffstats
path: root/root/html/pages/report/index.tt
blob: b6c4364c031980c9b9c3460ca8dd59386ba21b14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!-- $Id$ -->
<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);
    var myOptions = {
      zoom: 2,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    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": 1, "100Mbits": 1,
            "1Gbits": 2, "2Gbits": 2,
            "10Gbits": 3, "20Gbits": 3,
            "100Gbits": 4, "200Gbits": 4
        };
        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 %]);
    var marker[% loop.count %] = new google.maps.Marker({
      position: myLatlng, 
      map: map, 
      title:"[% m.hostname %]"
    }); 
    var infowindow[% loop.count %] = new google.maps.InfoWindow({
        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>'
    });
    google.maps.event.addListener(marker[% loop.count %], 'click', function() {
        infowindow[% loop.count %].open(map,marker[% loop.count %]);
    });
[% IF m.syncfrom %]
[% mf = c.model('Mirrors').find_mirrors({ hostname => m.syncfrom }) %]
    [% IF mf.0.latitude %]
    var fLatLng = new google.maps.LatLng([% mf.0.latitude %], [% mf.0.longitude %]);
    var flightPath = new google.maps.Polyline({
        path: [ fLatLng, myLatlng ],
        strokeColor: getStrokeColor("[% m.syncfrom %]"),
        strokeOpacity: 1.0,
        strokeWeight: getStrokeWeight("[% m.bandwidth %]")
    });

    flightPath.setMap(map);
    [% END %]
[% END %]
[% END %]
[% END %]
    }

</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>

<h2>Synchronisation tree</h2>
<img src="[% c.uri_for('/graph') %]">