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

Added listing of event neighbors in event list and event detail pages.

parent 8c91bef0
No related branches found
No related tags found
No related merge requests found
......@@ -114,6 +114,18 @@ class Event(models.Model):
gps_time = int(posixToGpsTime(posix_time))
return gps_time - self.gpstime
def neighbors(self, delta=5):
if not self.gpstime:
return []
if self.group.name == 'Test':
nearby = Event.objects.filter(group='Test')
else:
nearby = Event.objects.exclude(group__name='Test')
nearby = nearby.filter(gpstime__range=(self.gpstime-delta, self.gpstime+delta))
nearby = nearby.exclude(id=self.id)
nearby = nearby.order_by('gpstime')
return nearby
@classmethod
def getTypeLabel(cls, code):
for key, label in cls.ANALYSIS_TYPE_CHOICES:
......
......@@ -377,6 +377,8 @@ def view(request, graceid):
raise Http404
context['object'] = a
context['eventdesc'] = get_logfile(graceid)
context['nearby'] = [(event.gpstime - a.gpstime, event)
for event in a.neighbors()]
return render_to_response(
'gracedb/event_detail.html',
context,
......@@ -670,10 +672,17 @@ def flexigridResponse(request, objects):
{ 'id' : object.id,
'cell': [ '<a href="%s">%s</a>' %
(reverse(view, args=[object.graceid()]), object.graceid()),
#Labels
" ".join(['<span title="%s %s" style="color: %s">%s</span>' %
(label.creator.name, label.created, label.label.defaultColor, label.label.name)
for label in object.labelling_set.all()
]),
# Links to neighbors
', '.join([
'<a href="%s">%s</a>' %
(reverse(view, args=[n.graceid()]), n.graceid())
for n in object.neighbors()
]),
object.group.name,
object.get_analysisType_display(),
......
......@@ -47,6 +47,17 @@ a.link, a, a.active {
color: #369;
}
li.coinc-5, li.coinc--5 { color: #00F; }
li.coinc-4, li.coinc--4 { color: #03C; }
li.coinc-3, li.coinc--3 { color: #069; }
li.coinc-2, li.coinc--2 { color: #096; }
li.coinc-1, li.coinc--1 { color: #0C3; }
li.coinc-0 { color: #0F0; }
span.coinc-0,
span.coinc-1, span.coinc-2, span.coinc-3, span.coinc-4, span.coinc-5,
span.coinc--1, span.coinc--2, span.coinc--3, span.coinc--4, span.coinc--5
{ color: black; }
#header {
color: black;
......
......@@ -77,6 +77,19 @@
{% if eventdesc %}
<h3>Event Log File</h3>
{{ eventdesc }}
<br/>
{% endif %}
{% if nearby %}
<br/>
<h3>Nearby Events</h3>
<ul>
{% for delta, event in nearby %}
<li class="coinc-{{delta}}">
<span class="coinc-{{delta}}">{{ delta }}s <a href="{% url view event.graceid %}">{{ event.graceid }}</a></span>
</li>
{% endfor %}
</ul>
{% endif %}
</td></tr></table>
......
......@@ -48,16 +48,17 @@
url: '{% url search %}/flex?query={{rawquery}}',
datatype: 'json',
mtype: "GET",
colNames : ["UID", "Labels", "Group", "Type", "Event Time", "Links", "Submitted",
colNames : ["UID", "Labels", "Neighbors (+/-5sec)", "Group", "Type", "Event Time", "Links", "Submitted",
],
colModel : [
{name : 'id', index: 'id', width : 100, sortable : true, align: 'left', hidden: false},
{name : 'id', index: 'id', width : 50, sortable : true, align: 'left', hidden: false},
{name : 'labels', index: 'labels', width : 100, sortable : false, align: 'left'},
{name : 'group', index: 'group', width : 100, sortable : false, align: 'left', hidden: true},
{name : 'analysisType', index: 'analysisType', width : 130, sortable : true, align: 'left', hide: false},
{name : 'neighbors', index: 'neighbors', width : 100, sortable : false, align: 'left'},
{name : 'group', index: 'group', width : 50, sortable : false, align: 'left', hidden: true},
{name : 'analysisType', index: 'analysisType', width : 90, sortable : true, align: 'right', hide: false},
{name : 'gpstime', index: 'gpstime', width : 100, sortable : true, align: 'right'},
{name : 'links', index: 'links', width : 100, sortable : false, align: 'center'},
{name : 'gpstime', index: 'gpstime', width : 90, sortable : true, align: 'right'},
{name : 'links', index: 'links', width : 80, sortable : false, align: 'center'},
{name : 'created', index: 'created', width : 100, sortable : true, align: 'right'},
],
......
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