summaryrefslogtreecommitdiff
path: root/tools/mmd/MmdWidgets.py
blob: 6ff3f3d668ba02e4a2230f65a86cbd81ae802a40 (plain) (blame)
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
"""
web widgets for MURSAT1 Dashboard
"""

import time

def loginFormWidget ():
  html = '''
   Please enter your email and password in the form below.
   <form method="post" accept-charset="UTF-8">
    <table>
     <tr><td class="formfield">Email:</td><td><input type="text" name="email" /></td></tr>
     <tr><td class="formfield">Password:</td><td><input type="password" name="password" /></td></tr>
     <tr><td class="formfield"><input type="submit" value="login" /></td><td></td></tr>
     <!-- <tr><td class="formfield"><input type="submit" value="login" disabled="disabled" /></td><td></td></tr> -->
    </table>
    <input type="hidden" name="cmd" value="login" />
   </form>
   Don't have an account yet?  <a href="?cmd=registerForm">Register</a> here!
  '''

  return html

def loginWidget (user):
  html = '''
  <h3>Hello {0} {1}!</h3>
  <div>
   You are now logged on to MMD.
  </div>
  '''.format (user.firstname, user.lastname)

  return html

def registerFormWidget ():
  html = '''
   Please fill in the form below and click on register.  You will receive a confirmation email.
   <form method="post" accept-charset="UTF-8">
    <table>
     <tr><td class="formfield">Firstname*:</td><td><input type="text" name="firstname" /></td></tr>
     <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 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>
    <input type="hidden" name="cmd" value="register" />
   </form>
   Fields marked with a * are mandatory.
  '''

  return html

def registerWidget ():
  html = '''
  <h3>Thank you for registering!</h3>
  You will receive an email containing a link to confirm your registration.  Please use this link within 24 hours to complete registration.
  '''

  return html

def completeRegistrationWidget (code):
  html = '''
  <h3>Completing registration!</h3>
  <div>
   By clicking <a href="?cmd=confirmRegistration&code={0}">confirm</a> you confirm you registration to the MURSAT1 Mission Dashboard.  If you received an email that brought you here but never registered, you might want to <a href="?cmd=cancelRegistration&code={0}">cancel</a> the registration or simply do nothing since a registration code is only valid vor 24 hrs.
  </div>
  <div>
   Greetings from the MURSAT1 Team!
  </div>
  '''.format (code)

  return html

def confirmRegistrationWidget (user):
  html = '''
  <h3>Dear {0} {1}!</h3>
   <div>
    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>.
   </div>
   '''.format (user.firstname, user.lastname)

  return html

def cancelRegistrationWidget ():
  html = '''
  <h3>We are sorry!</h3>
  <div>
   Your registration has been canceled and all the data has been deleted from our records.
  </div>
  <div>
   Regards from the MURSAT1 team
  </div>
  '''

  return html

def errorWidget (error_message):
  html = '''
  <h3>An error occured!</h3>
  <div>Error: {0}</div>
  <div>Description: {1}</div>
  '''.format (error_message['error'], error_message['description'])

  return html

def submitFormWidget ():
  html = '''
  sorry, no form yet!
  '''
  
  return html

def submitWidget ():
  html = '''
  need processing of data
  '''

  return html

def logWidget ():
  html = '''
  Log data, lot's of log data ...
  '''

  return html

def osmWidget (longitude = 15.4426, latitude = 47.06576):
  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);

    // create a map
    map = new OpenLayers.Map ("osm");
    map.addLayer (new OpenLayers.Layer.OSM ());

    // set a marker
    var markers = new OpenLayers.Layer.Markers ("Markers");
    map.addLayer (markers);
    markers.addMarker (new OpenLayers.Marker (lonlat));

    // center the map
    map.setCenter (lonlat, 2);
  </script>
  '''.format (longitude, latitude)

  return html

def statusWidget (session):
  if session.status == 'auth':
    inout = '''<span id="logout"><a href="?cmd=logout">logout</a></span>'''
  else:
    inout = '''<span id="login"><a href="?cmd=loginForm">login</a></span>'''
  html = '''
   <a href="/mmd/">
    <img src="http://sat.mur.at/pics/sat-logo-notext.png" alt="mur.sat logo" />
   </a>
   MURSAT1 Mission Dashboard
   <div id="info">
    Hello {0} with session id '{1}'! Local time is {2}. {3}
   </div>
  '''.format (session.user.email, session.session_id, time.strftime ('%c'), inout)

  return html

def indexWidget (lcol, rcol, status):
  html = '''
<!Doctype html>
<html>
 <head>
  <title>MURSAT1 Dashboard</title>
  <meta charset="utf-8" />
  <link rel="stylesheet" type="text/css" href="static/mmd.css" />
 </head>
 <body>
  <div id="status">
   {0}
  </div>
  <div id="lcol">
   {1}
  </div>
  <div id="rcol">
   {2}
  </div>
  <div id="dev">
   Development version!
  </div>
 </body>
</html>
  '''.format (status, lcol, rcol)

  return html

def dataWidget (longitude = 15.44226, latitude = 47.06576):
  html = '''
   <div id="datahead">
    Current Data
   </div>
   <div>Time: 00 D 00 H 00 M 00 S</div>
   <div>Longitude: {0}</div>
   <div>Latitude: {1}</div>
   <hr />
   <div><a href="?cmd=submitForm">Submit</a> a report</div>
   <div>View <a href="?cmd=viewlog">Log</a> of reports</div>
   <hr />
   <div>Checkout the <a href="http://sat.mur.at/">project page</a>!</div>
  '''.format (longitude, latitude)
  
  return html

if __name__ == "__main__":
  pass

# vim: ft=html tw=0 ts=2 expandtab
# EOF