1
0
Fork 0

Add ability to filter by failed observations

Fixes #437.
merge-requests/455/head
Pierros Papadeas 2017-12-27 16:13:29 +01:00
parent ad9cb400b8
commit e5b9e2419e
No known key found for this signature in database
GPG Key ID: AB1301B4FCDFF5D4
8 changed files with 119 additions and 42 deletions

View File

@ -118,11 +118,12 @@ class ObservationListView(ListView):
def get_queryset(self):
"""
Optionally filter based on norad get argument
Optionally filter based on good/bad/unvetted
Optionally filter based on future/good/bad/unvetted/failed
"""
norad_cat_id = self.request.GET.get('norad', '')
observer = self.request.GET.get('observer', '')
station = self.request.GET.get('station', '')
self.filtered = False
bad = self.request.GET.get('bad', '1')
if bad == '0':
@ -144,22 +145,35 @@ class ObservationListView(ListView):
future = False
else:
future = True
failed = self.request.GET.get('failed', '1')
if failed == '0':
failed = False
else:
failed = True
if False in (bad, good, unvetted, future, failed):
self.filtered = True
observations = Observation.objects.all()
if not norad_cat_id == '':
observations = observations.filter(
satellite__norad_cat_id=norad_cat_id)
self.filtered = True
if not observer == '':
observations = observations.filter(
author=observer)
self.filtered = True
if not station == '':
observations = observations.filter(
ground_station_id=station)
self.filtered = True
if not bad:
observations = observations.exclude(vetted_status='no_data')
if not good:
observations = observations.exclude(vetted_status='good')
if not failed:
observations = observations.exclude(vetted_status='failed')
if not unvetted:
observations = observations.exclude(vetted_status='unknown',
id__in=(o.id for
@ -184,6 +198,8 @@ class ObservationListView(ListView):
context['bad'] = self.request.GET.get('bad', '1')
context['good'] = self.request.GET.get('good', '1')
context['unvetted'] = self.request.GET.get('unvetted', '1')
context['failed'] = self.request.GET.get('failed', '1')
context['filtered'] = self.filtered
if norad_cat_id is not None and norad_cat_id != '':
context['norad'] = int(norad_cat_id)
if observer is not None and observer != '':

View File

@ -27,7 +27,7 @@
}
.label-failed {
background-color: black;
background-color: #444;
color: white;
}
@ -35,7 +35,7 @@
@extend .label-failed;
&:hover {
background-color: #333;
background-color: #666;
color: white;
}
}

View File

@ -347,14 +347,17 @@ span.datetime-time {
display: block;
}
.form-group.status-filter {
display: inline-block;
}
#collapseFilters h4,
#collapseFilters h3 {
display: inline-block;
}
#collapseFilters button,
#collapseFilters span {
margin-right: 5px;
#collapseFilters label.btn-unknown {
font-weight: 900;
}
#collapseFilters button.active {

View File

@ -17,11 +17,11 @@ $(document).ready(function() {
});
});
// Filters submits
$('.filter-section input[type=checkbox]').change(function() {
$('#observation-filter').submit();
});
// Satellite Filters
$('#satellite-selection').bind('keyup change', function() {
$('#observation-filter').submit();
});
@ -31,14 +31,15 @@ $(document).ready(function() {
$('#station-selection').bind('keyup change', function() {
$('#observation-filter').submit();
});
// Check if filters should be displayed
if (window.location.hash == '#collapseFilters') {
$('#collapseFilters').hide();
} else if ($('#satellite-selection').val() ||
$('#observer-selection').val() ||
$('#station-selection').val()) {
} else if ($('#collapseFilters').data('filtered') == 'True') {
$('#collapseFilters').show();
}
// Open all observations in new tabs
$('#open-all').click(function() {
$('a.obs-link').each(function() {
window.open($(this).attr('href'));

View File

@ -55,7 +55,7 @@
<li data-toggle="tooltip"
data-placement="bottom"
title="{{ owner_vetting_count }} observations need vetting">
<a href="{% url 'base:observations_list' %}?observer={{ request.user.id }}&future=0&good=0&bad=0&unvetted=1">
<a href="{% url 'base:observations_list' %}?observer={{ request.user.id }}&future=0&good=0&bad=0&unvetted=1&failed=0">
<span class="glyphicon glyphicon-check" aria-hidden="true"></span>
<span class="badge badge-unvetted">{{ owner_vetting_count }}</span>
</a>

View File

@ -5,39 +5,95 @@
{% block title %} - Observations{% endblock %}
{% block content %}
<h1>
Observations
<div class="pull-right">
<a class="btn btn-default" role="button" data-toggle="collapse"
href="#collapseFilters" aria-expanded="false" aria-controls="collapseFilters">
<span class="glyphicon glyphicon-th-list" aria-hidden="true"></span> Filters
</a>
<a class="btn btn-default" role="button" href="#legend" data-toggle="modal" data-target="#LegendModal">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> Legend
</a>
{% if can_schedule %}
<a class="btn btn-primary" href="{% url 'base:observation_new' %}">New Observation</a>
{% endif %}
<div class="row">
<div class="col-md-3 visible-md visible-lg">
<h1>
Observations
</h1>
</div>
</h1>
<div class="col-xs-3 hidden-md hidden-lg">
<h2>
Observations
</h2>
</div>
<div class="col-md-4 pull-right visible-md visible-lg">
<h1 class="pull-right">
<a href="#legend" class="btn" data-toggle="modal" data-target="#LegendModal">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
</a>
<a class="btn btn-default" role="button" data-toggle="collapse"
href="#collapseFilters" aria-expanded="false" aria-controls="collapseFilters">
<span class="glyphicon glyphicon-filter" aria-hidden="true"></span> Filters
</a>
{% if can_schedule %}
<a class="btn btn-primary" href="{% url 'base:observation_new' %}">New Observation</a>
{% endif %}
</h1>
</div>
<div class="col-md-4 pull-right hidden-md hidden-lg">
<h2 class="pull-right">
<a class="btn btn-default" role="button" data-toggle="collapse"
href="#collapseFilters" aria-expanded="false" aria-controls="collapseFilters">
<span class="glyphicon glyphicon-filter" aria-hidden="true"></span>
</a>
{% if can_schedule %}
<a class="btn btn-primary" href="{% url 'base:observation_new' %}">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
</a>
{% endif %}
</h2>
</div>
</div>
<div class="collapse{% if norad %} in{% endif %}" id="collapseFilters">
<div class="collapse{% if norad %} in{% endif %}" id="collapseFilters" data-filtered="{{ filtered }}">
<div class="filter-section row">
<form id="observation-filter" class="form" methon="get" action="{% url 'base:observations_list' %}">
<div class="form-group col-md-3">
<label for="data-selector">Data</label>
<div class="form-group status-filter col-md-3">
<label for="data-selector">Status</label>
<div id="data-selector" class="btn-group" data-toggle="buttons">
<label class="btn btn-future btn-sm {% if future == '1' %}active{% endif %}" aria-expanded="true" aria-controls="future">
<input type="checkbox" name="future" {% if future == '1' %}checked{% endif %} autocomplete="off">Future
<label class="btn btn-future btn-sm {% if future == '1' %}active{% endif %}"
aria-expanded="true"
aria-controls="future"
data-toggle="tooltip"
data-placement="bottom"
title="Future">
<input type="checkbox" name="future" {% if future == '1' %}checked{% endif %} autocomplete="off">
<span class="glyphicon glyphicon-time" aria-hidden="true"></span>
</label>
<label class="btn btn-good btn-sm {% if good == '1' %}active{% endif %}" aria-expanded="true" aria-controls="good">
<input type="checkbox" name="good" {% if good == '1' %}checked{% endif %} autocomplete="off">Good
<label class="btn btn-good btn-sm {% if good == '1' %}active{% endif %}"
aria-expanded="true"
aria-controls="good"
data-toggle="tooltip"
data-placement="bottom"
title="Good">
<input type="checkbox" name="good" {% if good == '1' %}checked{% endif %} autocomplete="off">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
</label>
<label class="btn btn-bad btn-sm {% if bad == '1' %}active{% endif %}" aria-expanded="true" aria-controls="bad">
<input type="checkbox" name="bad" {% if bad == '1' %}checked{% endif %} autocomplete="off">Bad
<label class="btn btn-bad btn-sm {% if bad == '1' %}active{% endif %}"
aria-expanded="true"
aria-controls="bad"
data-toggle="tooltip"
data-placement="bottom"
title="Bad">
<input type="checkbox" name="bad" {% if bad == '1' %}checked{% endif %} autocomplete="off">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
</label>
<label class="btn btn-unknown btn-sm {% if unvetted == '1' %}active{% endif %}" aria-expanded="true" aria-controls="unvetted">
<input type="checkbox" name="unvetted" {% if unvetted == '1' %}checked{% endif %} autocomplete="off">Unvetted
<label class="btn btn-unknown btn-sm {% if unvetted == '1' %}active{% endif %}"
aria-expanded="true"
aria-controls="unvetted"
data-toggle="tooltip"
data-placement="bottom"
title="Unvetted">
<input type="checkbox" name="unvetted" {% if unvetted == '1' %}checked{% endif %} autocomplete="off">?
</label>
<label class="btn btn-failed btn-sm {% if failed == '1' %}active{% endif %}"
aria-expanded="true"
aria-controls="failed"
data-toggle="tooltip"
data-placement="bottom"
title="Failed">
<input type="checkbox" name="failed" {% if failed == '1' %}checked{% endif %} autocomplete="off">
<span class="glyphicon glyphicon-alert" aria-hidden="true"></span>
</label>
</div>
</div>

View File

@ -76,7 +76,7 @@
</a>
</td>
<td>
<a href="{% url 'base:observations_list' %}?future=1&good=0&bad=0&unvetted=0&station={{ station.id }}">
<a href="{% url 'base:observations_list' %}?future=1&good=0&bad=0&unvetted=0&failed=0&station={{ station.id }}">
<span class="badge badge-info">
{{ station.observations_future_count }}
</span>

View File

@ -8,19 +8,20 @@
<div class="modal-body">
<h4>The ID number of each observation is listed below, colored as such:</h4>
<p>
<span class="label label-future" title="This observation is in the future">43</span> This observation is in the future</span>
<span class="label label-future" title="This observation is in the future">43</span> Future observation - This observation is scheduled</span>
</p>
<p>
<span class="label label-good" title="There is known good data in this observation">12</span> There is some known good data in this observation
<span class="label label-good" title="There is known good data in this observation">12</span> Good observation - Satellite was active in this pass
</p>
<p>
<span class="label label-unknown" title="There is data that needs vetting in this observation">56</span> There is data that needs vetting in this observation
<span class="label label-bad" title="No good data in this observation">78</span> Bad observation - Satellite was not active in this pass
</p>
<p>
<span class="label label-bad" title="No good data in this observation">78</span> No good data in this observation
<span class="label label-unknown" title="There is data that needs vetting in this observation">56</span> Unvetted observation - There is data that needs vetting in this pass
</p>
<p>
<span class="label label-failed" title="This observation failed">93</span> Observation failed
<span class="label label-failed" title="This observation failed">93</span> Observation failed - Ground station malfunction in this pass
</p>
</div>
<div class="modal-footer">