aboutsummaryrefslogtreecommitdiffstats
path: root/root/html/includes/host_information.tt
blob: 94fa7e30400274863e4e31bd75fee94597bcc6a9 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!-- $Id$ -->
<div style="float: left">
[% IF c.req.param('modify') AND NOT host.readonly %]
    [% edit = 1 %]
[% END %]

[% IF edit %]
<form action="[% action || c.uri_for() %]" method="POST">
<input type="hidden" name="hostinfo" value="1">
[% END %]
<table border=0>
<tr><th>Country</th>
<td>
[% IF NOT edit %]
[% c.model('Mirrors').country_info(host.country).name | html %]
[% ELSE %]
<select name="country" id="country">
<option value=""></option>
[% FOREACH country = c.model('Mirrors').country_list %]
<option value="[% country.code %]" [% "selected=select" IF country.code == host.country %]>[% country.name | html %]</option>
[% END %]
</select>
[% END %]
</td>
</tr>

<tr><th>City</th>
<td>
[% IF edit %]
<input type="text" id="city" name="city" value="[% host.city | html %]">
<a href="#" onClick="codeAddress()">
    <img src="[% c.uri_for('/static', 'images', 'page-zoom.png') %]" style="height: 1.5em">
</a>
[% ELSE %]
[% host.city | html %]
[% END %]
</td>
</tr>
[% IF edit %]
<tr><td colspan=2>Click on the map to update latitude and longitude</td></tr>
[% END %]
<tr><th>Latitude</th>
<td>
[% IF edit %]
<input type="text" id="latitude" name="latitude" value="[% host.latitude | html %]">
[% ELSE %]
[% host.latitude | html %]
[% END %]
</td>
</tr>
<tr><th>Longitude</th>
<td>
[% IF edit %]
<input type="text" id="longitude" name="longitude" value="[% host.longitude | html %]">
[% ELSE %]
[% host.longitude | html %]
[% END %]
</td>
</tr>

<tr><th>Synchronized from</th>
<td>
[% IF NOT edit %]
[% host.syncfrom | html %]
[% ELSE %]
[% FOREACH mirror = c.model('Mirrors').find_mirrors %]
[% IF loop.first %]
<select name="syncfrom">
<option value="">Unknown</option>
[% END %]
[% IF mirror.public %]
<option value="[% mirror.hostname | html %]" [% "selected=select" IF host.syncfrom == mirror.hostname %]>[% mirror.hostname | html %]</option>
[% END %]
[% IF loop.last %]
</select>
[% END %]
[% END %]
[% END %]
</td>
</tr>

<tr><th>Approximated bandwidth</th>
<td>
[% IF NOT edit %]
[% c.model('Mirrors').bandwidth_name(host.bandwidth) | html %]
[% ELSE %]
<select name="bandwidth">
<option value=""></option>
[% FOREACH bd = c.model('Mirrors').bandwidth_list %]
<option value="[% bd.value %]" [% "selected=select" IF host.bandwidth == bd.value %]>[% bd.name | html %]</option>
[% END %]
</select>
[% END %]
</td>
</tr>
[% IF edit AND needmail %]
<tr>
<td colspan=2>
A mail will be be sent with the link to confirm<br>
your update request.<br>
</td>
</tr>
<tr>
<th>Your e-mail</th>
<td><input type="text" name="mail"></td>
</tr>
[% END %]
</table>
[% IF edit %]
<input type="submit">
<input type="reset">
</form>
[% ELSE %]
[% IF NOT host.readonly %]
<form action="[% action || c.uri_for() %]" method="POST">
<input type="submit" name="modify" value="update information">
</form>
[% END %]
[% END %]
</div>

<script type="text/javascript"
    src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
    var map;

    function initialize() {
    var latlng = new google.maps.LatLng(
        [% host.latitude || 0 %],
        [% host.longitude || 0 %]
    );
    var myOptions = {
[% IF edit %]
      zoom: 5,
[% ELSE %]
      zoom: 4,
[% END %]
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);

[% IF edit %] 
    google.maps.event.addListener(map, 'click', function(event) {
        recordposition(event.latLng);
    });

    function recordposition(location) {
        document.getElementById("latitude").value = location.lat();
        document.getElementById("longitude").value = location.lng();
    }
[% ELSE %]
    var myLatlng = new google.maps.LatLng([% host.latitude %],[% host.longitude %]);
    var marker = new google.maps.Marker({
      position: myLatlng,
      map: map,
      title:"[% host.hostname %]"
    });
[% END %]
    }

[% IF edit %]
  function codeAddress() {
    var address = 
        document.getElementById("city").value + ',' +
        document.getElementById("country").value;
    var geocoder = new google.maps.Geocoder();
    geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        if (document.getElementById("city").value) {
            map.setZoom(12);
        } else {
            map.setZoom(5);
        }
      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });
  }

[% END %]

</script>

<div id="map_canvas" style="float: left; width:40%; height:300px"></div>
<div style="clear: both"></div>

<script type="text/javascript">
    initialize();
</script>