diff options
author | Jogi Hofmüller <jogi@mur.at> | 2011-08-03 11:19:44 +0000 |
---|---|---|
committer | Jogi Hofmüller <jogi@mur.at> | 2011-08-03 11:19:44 +0000 |
commit | 502b6a813a6f90c2e7adb5781b1beecd559014d9 (patch) | |
tree | 6c46b328e6a106bc770ad77650c0b6a14fb525e5 /tools/mmd/MmdWidgets.py | |
parent | cleanup (diff) |
- added functionality for location
- user's default location is save
- map centers on user's location iff available
git-svn-id: https://svn.spreadspace.org/mur.sat@96 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'tools/mmd/MmdWidgets.py')
-rw-r--r-- | tools/mmd/MmdWidgets.py | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/tools/mmd/MmdWidgets.py b/tools/mmd/MmdWidgets.py index ec77eb0..4f0d582 100644 --- a/tools/mmd/MmdWidgets.py +++ b/tools/mmd/MmdWidgets.py @@ -3,6 +3,7 @@ web widgets for MURSAT1 Dashboard """ import time +from MmdLocation import Location def loginFormWidget (): html = ''' @@ -49,10 +50,12 @@ def registerFormWidget (): <tr><td class="formfield">Lastname*: </td><td><input type="text" name="lastname" /></td></tr> <tr><td class="formfield">Email*: </td><td><input type="text" name="email" /></td></tr> <tr><td class="formfield">Callsign: </td><td><input type="text" name="callsign" /></td></tr> - <tr><td class="formfield">Longitude: </td><td><input type="text" name="latitude" /></td></tr> - <tr><td class="formfield">Latitude: </td><td><input type="text" name="longitude" /></td></tr> <tr><td class="formfield">Password*: </td><td><input type="password" name="password" /></td></tr> <tr><td class="formfield">Confirm Password*: </td><td><input type="password" name="confirm" /></td></tr> + <tr><td colspan="2">You can enter your prefered location if you wish</td></tr> + <tr><td class="formfield">Name: </td><td><input type="text" name="location_name" /></td></tr> + <tr><td class="formfield">Longitude: </td><td><input type="text" name="latitude" /></td></tr> + <tr><td class="formfield">Latitude: </td><td><input type="text" name="longitude" /></td></tr> <!-- <tr><td class="formfield"><input type="submit" value="Register" disabled="disabled" /></td><td></td></tr> --> <tr><td class="formfield"><input type="submit" value="register" /></td><td></td></tr> </table> @@ -96,7 +99,10 @@ def confirmRegistrationWidget (user): Thank you for participating in this project by registerting here! We are looking forward to receiving your reports from MURSAT1. </div> <div> - Sessions here stay valid for 24 hours after your last click. If your session expires, just use your email and password to logon again using this link: <a href="http://hofos.at/mmd/?cmd=login">http://hofos.at/mmd/?cmd=login</a>. + Sessions here stay valid for 48 hours after your last click. If your session expires, just use your email and password to logon again using this link: <a href="http://hofos.at/mmd/?cmd=login">http://hofos.at/mmd/?cmd=login</a>. + </div> + <div> + Greetings from the MURSAT1 team </div> '''.format (user.firstname, user.lastname) @@ -145,14 +151,18 @@ def logWidget (): return html -def osmWidget (longitude = 15.4426, latitude = 47.06576): +def osmWidget (satellite, user): + user_location = user.getDefaultLocation () + if not user_location: + user_location = Location () html = ''' <div id="osm"></div> <script src="http://www.openlayers.org/api/OpenLayers.js"></script> <script> var from = new OpenLayers.Projection ("EPSG:4326"); var to = new OpenLayers.Projection ("EPSG:900913"); - var lonlat = new OpenLayers.LonLat ({0}, {1}).transform (from, to); + var satellite = new OpenLayers.LonLat ({0}, {1}).transform (from, to); + var user_location = new OpenLayers.LonLat ({2}, {3}).transform (from, to); // create a map map = new OpenLayers.Map ("osm"); @@ -161,12 +171,14 @@ def osmWidget (longitude = 15.4426, latitude = 47.06576): // set a marker var markers = new OpenLayers.Layer.Markers ("Markers"); map.addLayer (markers); - markers.addMarker (new OpenLayers.Marker (lonlat)); + markers.addMarker (new OpenLayers.Marker (satellite)); + markers.addMarker (new OpenLayers.Marker (user_location)); // center the map - map.setCenter (lonlat, 2); + map.setCenter (user_location, 2); </script> - '''.format (longitude, latitude) + <!-- lon: {2} lat: {3} --> + '''.format (satellite['longitude'], satellite['latitude'], user_location.longitude, user_location.latitude) return html @@ -189,6 +201,9 @@ def statusWidget (session): def indexWidget (lcol, rcol, status, debug_info = False): if debug_info: + user_location = debug_info.user.getDefaultLocation () + if not user_location: + user_location = Location () debug = ''' <pre class="debug"> Debug Info @@ -200,6 +215,9 @@ def indexWidget (lcol, rcol, status, debug_info = False): Expires: {4} Renewal: {5} Now: {6} + User's Location Name: {7} + Longitude: {8} + Latitude: {9} </pre> '''.format ( debug_info.session_id, @@ -208,7 +226,10 @@ def indexWidget (lcol, rcol, status, debug_info = False): debug_info.status, debug_info.expires, debug_info.renewal, - time.strftime ('%s')) + time.strftime ('%s'), + user_location.name, + user_location.longitude, + user_location.latitude) else: debug = '' |