Skip to content
Snippets Groups Projects
Commit e2e6c235 authored by Brian Moe's avatar Brian Moe
Browse files

A somewhat working javascript-alicious, all sorting, all adjustable query result page.

parent e148c2b2
No related branches found
No related tags found
No related merge requests found
Showing
with 494 additions and 17 deletions
......@@ -115,3 +115,34 @@ def utc(dt, format=FORMAT):
def gpsdate(gpstime, format=FORMAT):
return dateformat.format(gpsToUtc(gpstime), format)
def timeSelections(t):
rv = {}
if t is None:
return rv
format = FORMAT
if isinstance(t, datetime.datetime):
dt = t
if not dt.tzinfo:
dt = SERVER_TZ.localize(dt)
#dt = dt.astimezone(pytz.utc)
posix_time = time.mktime(dt.timetuple())
gps_time = int(posixToGpsTime(posix_time))
elif isinstance(t, int) or isinstance(t, long):
gps_time = t
dt = gpsToUtc(t)
posix_time = time.mktime(dt.timetuple())
else:
raise ValueError("time must be type int, long or datetime, not '%s'" % type(t))
# JavaScript -- parsable by Date() object constructor
# "Jan 2, 1985 00:00:00 UTC"
js_parsable_time = dateformat.format(dt, "F j, Y h:i:s")+" UTC"
rv['gps'] = gps_time
rv['lho'] = dateformat.format(dt.astimezone(LHO_TZ), format)
rv['llo'] = dateformat.format(dt.astimezone(LLO_TZ), format)
rv['virgo'] = dateformat.format(dt.astimezone(VIRGO_TZ), format)
rv['utc'] = dateformat.format(dt.astimezone(pytz.utc), format)
return rv
......@@ -407,7 +407,8 @@ def search(request, format=""):
limit = 1000
form2 = None
if format == "flex":
# This block is crap and for debugging. Remove it!
if False and format == "flex":
response = HttpResponse(mimetype='application/json')
rows = [
{ 'id': 1, 'cell':
......@@ -431,14 +432,9 @@ def search(request, format=""):
response.write(msg)
#query = request.POST['query']
# ???!!!
query = "blah"
f = open('/tmp/foo', 'a')
f.write('hello\n')
f.write(str(request.POST))
#f.write("query is: %s\n" % request.POST['query'])
f.write('\n\n')
f.close()
return response
if request.method == "GET" and "query" not in request.GET:
......@@ -460,9 +456,11 @@ def search(request, format=""):
if format == "json":
return HttpResponse("Not Implemented")
if format == "flex":
elif format == "flex":
# Flexigrid request.
return flexigridResponse(request, objects)
elif format == "jqgrid":
return jqgridResponse(request, objects)
else:
#objects = objects[:limit]
#if objects.count() >= limit:
......@@ -606,6 +604,13 @@ def timeline(request):
#-----------------------------------------------------------------
# Things that aren't views and should really be elsewhere.
#-----------------------------------------------------------------
from templatetags.timeutil import timeSelections
def jqgridResponse(request, objects):
# "GET /data?_search=false&nd=1266350238476&rows=10&page=1&sidx=invid&sord=asc HTTP/1.1"
pass
def flexigridResponse(request, objects):
response = HttpResponse(mimetype='application/json')
......@@ -614,10 +619,10 @@ def flexigridResponse(request, objects):
#page = int(request.POST.get('page', 1))
#rp = int(request.POST.get('rp', 10))
sortname = request.POST.get('sidx', None) # get index row - i.e. user click to sort
sortorder = request.POST.get('sord', 'desc') # get the direction
page = int(request.POST.get('page', 1)) # get the requested page
rp = int(request.POST.get('rows', 10)) # get how many rows we want to have into the grid
sortname = request.GET.get('sidx', None) # get index row - i.e. user click to sort
sortorder = request.GET.get('sord', 'desc') # get the direction
page = int(request.GET.get('page', 1)) # get the requested page
rp = int(request.GET.get('rows', 10)) # get how many rows we want to have into the grid
if sortname:
if sortorder == "desc":
......@@ -627,11 +632,18 @@ def flexigridResponse(request, objects):
start = (page-1) * rp
rows = []
total = objects.count()
total_pages = total / rp
if total:
total_pages = (total / rp) + 1
else:
total_pages = 0
if page > total_pages:
page = total_pages
for object in objects[start:start+rp]:
event_times = timeSelections(object.gpstime)
created_times = timeSelections(object.created)
rows.append(
{ 'id' : object.id,
'cell': [ '<a href="%s">%s</a>' %
......@@ -642,10 +654,16 @@ def flexigridResponse(request, objects):
]),
object.group.name,
object.get_analysisType_display(),
object.gpstime,
event_times.get('gps',""),
#event_times['utc'],
'<a href="%s">Data</a> <a href="%s">Wiki</a>' %
(object.weburl(), object.wikiurl()),
str(object.created),
#created_times['gps'],
created_times.get('utc',""),
]
}
)
......@@ -663,7 +681,7 @@ def flexigridResponse(request, objects):
response['Content-length'] = len(msg)
response.write(msg)
query = request.POST['query']
#query = request.POST['query']
return response
......
......@@ -47,7 +47,7 @@ GRACE_DATETIME_FORMAT = 'Y-m-d H:i:s T'
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 2
SITE_ID = 3
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
......
<?xml version="1.0"?>
<bindings
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="ellipsis">
<content>
<xul:window><!-- xul:window tag required for FF2 -->
<xul:description crop="end" xbl:inherits="value=xbl:text"><children/></xul:description>
</xul:window>
</content>
</binding>
</bindings>
static/css/jqgrid/theme/images/ui-bg_flat_0_aaaaaa_40x100.png

180 B

static/css/jqgrid/theme/images/ui-bg_flat_75_ffffff_40x100.png

178 B

static/css/jqgrid/theme/images/ui-bg_glass_55_fbf9ee_1x400.png

120 B

static/css/jqgrid/theme/images/ui-bg_glass_65_ffffff_1x400.png

105 B

static/css/jqgrid/theme/images/ui-bg_glass_75_dadada_1x400.png

111 B

static/css/jqgrid/theme/images/ui-bg_glass_75_e6e6e6_1x400.png

110 B

static/css/jqgrid/theme/images/ui-bg_glass_95_fef1ec_1x400.png

119 B

static/css/jqgrid/theme/images/ui-bg_highlight-soft_75_cccccc_1x100.png

101 B

static/css/jqgrid/theme/images/ui-icons_222222_256x240.png

4.27 KiB

static/css/jqgrid/theme/images/ui-icons_2e83ff_256x240.png

4.27 KiB

static/css/jqgrid/theme/images/ui-icons_454545_256x240.png

4.27 KiB

static/css/jqgrid/theme/images/ui-icons_888888_256x240.png

4.27 KiB

static/css/jqgrid/theme/images/ui-icons_cd0a0a_256x240.png

4.27 KiB

This diff is collapsed.
/* Accordion
----------------------------------*/
.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; }
.ui-accordion .ui-accordion-li-fix { display: inline; }
.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em 2.2em; }
.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; }
.ui-accordion .ui-accordion-content-active { display: block; }
\ No newline at end of file
@import "ui.base.css";
@import "ui.theme.css";
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment