Add selector for prefilling satellite on new observations
parent
ebaa662379
commit
e4122d5a0c
|
@ -170,9 +170,15 @@ def observation_new(request):
|
|||
satellites = Satellite.objects.filter(transmitters__alive=True).distinct()
|
||||
transmitters = Transmitter.objects.filter(alive=True)
|
||||
|
||||
norad = 0
|
||||
if request.method == 'GET':
|
||||
form = SatelliteFilterForm(request.GET)
|
||||
if form.is_valid():
|
||||
norad = form.cleaned_data['norad']
|
||||
|
||||
return render(request, 'base/observation_new.html',
|
||||
{'satellites': satellites,
|
||||
'transmitters': transmitters,
|
||||
'transmitters': transmitters, 'norad': norad,
|
||||
'date_min_start': settings.DATE_MIN_START,
|
||||
'date_max_range': settings.DATE_MAX_RANGE})
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
$(function () {
|
||||
$( document ).ready( function(){
|
||||
var minstart = $('#datetimepicker-start').data('date-minstart');
|
||||
var maxrange = $('#datetimepicker-end').data('date-maxrange');
|
||||
$('#datetimepicker-start').datetimepicker();
|
||||
|
@ -12,18 +12,23 @@ $(function () {
|
|||
$('#datetimepicker-end').data('DateTimePicker').maxDate(moment.utc(e.date).add(maxrange, 'm'));
|
||||
});
|
||||
|
||||
$('#satellite-selection').bind('keyup change', function() {
|
||||
var norad = $(this).find(':selected').data('norad');
|
||||
function select_proper_transmitters(norad) {
|
||||
$('#transmitter-selection').prop('disabled', false);
|
||||
$('#transmitter-selection option').hide();
|
||||
$('#transmitter-selection option[data-satellite="'+norad+'"]').show().prop('selected', true);
|
||||
|
||||
$('.tle').hide();
|
||||
$('.tle[data-norad="'+norad+'"]').show();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var norad = $(this).find(':selected').data('norad');
|
||||
select_proper_transmitters(norad);
|
||||
|
||||
$('#satellite-selection').bind('keyup change', function() {
|
||||
var norad = $(this).find(':selected').data('norad');
|
||||
select_proper_transmitters(norad);
|
||||
});
|
||||
|
||||
$( document ).ready( function(){
|
||||
$('#calculate-observation').click( function(){
|
||||
$('.calculation-result').show();
|
||||
$('#timeline').empty();
|
||||
|
@ -72,36 +77,36 @@ $( document ).ready( function(){
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
function timeline_init( start, end, payload ){
|
||||
var start_time_timeline = moment.utc(start).valueOf();
|
||||
var end_time_timeline = moment.utc(end).valueOf();
|
||||
|
||||
$('#timeline').empty();
|
||||
$('.coloredDiv').css('background-color', 'transparent');
|
||||
$('#name').empty();
|
||||
|
||||
var chart = d3.timeline()
|
||||
.stack()
|
||||
.beginning(start_time_timeline)
|
||||
.ending(end_time_timeline)
|
||||
.hover(function (d, i, datum) {
|
||||
var div = $('#hoverRes');
|
||||
var colors = chart.colors();
|
||||
div.find('.coloredDiv').css('background-color', colors(i));
|
||||
div.find('#name').text(datum.label);
|
||||
})
|
||||
.margin({left:140, right:10, top:0, bottom:50})
|
||||
.tickFormat({format: d3.time.format.utc('%H:%M'), tickTime: d3.time.minutes, tickInterval: 30, tickSize: 6});
|
||||
|
||||
var svg_width = 1140;
|
||||
if (screen.width < 1200) { svg_width = 940; }
|
||||
if (screen.width < 992) { svg_width = 720; }
|
||||
if (screen.width < 768) { svg_width = screen.width - 30; }
|
||||
var svg = d3.select('#timeline').append('svg').attr('width', svg_width)
|
||||
.datum(payload).call(chart);
|
||||
|
||||
$('#hoverRes').show();
|
||||
$('#schedule-observation').removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
|
||||
function timeline_init( start, end, payload ){
|
||||
var start_time_timeline = moment.utc(start).valueOf();
|
||||
var end_time_timeline = moment.utc(end).valueOf();
|
||||
|
||||
$('#timeline').empty();
|
||||
$('.coloredDiv').css('background-color', 'transparent');
|
||||
$('#name').empty();
|
||||
|
||||
var chart = d3.timeline()
|
||||
.stack()
|
||||
.beginning(start_time_timeline)
|
||||
.ending(end_time_timeline)
|
||||
.hover(function (d, i, datum) {
|
||||
var div = $('#hoverRes');
|
||||
var colors = chart.colors();
|
||||
div.find('.coloredDiv').css('background-color', colors(i));
|
||||
div.find('#name').text(datum.label);
|
||||
})
|
||||
.margin({left:140, right:10, top:0, bottom:50})
|
||||
.tickFormat({format: d3.time.format.utc('%H:%M'), tickTime: d3.time.minutes, tickInterval: 30, tickSize: 6});
|
||||
|
||||
var svg_width = 1140;
|
||||
if (screen.width < 1200) { svg_width = 940; }
|
||||
if (screen.width < 992) { svg_width = 720; }
|
||||
if (screen.width < 768) { svg_width = screen.width - 30; }
|
||||
var svg = d3.select('#timeline').append('svg').attr('width', svg_width)
|
||||
.datum(payload).call(chart);
|
||||
|
||||
$('#hoverRes').show();
|
||||
$('#schedule-observation').removeAttr('disabled');
|
||||
}
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
<select id="satellite-selection" class="form-control" name="satellite" autocomplete="off">
|
||||
<option value="" disabled selected>Select a satellite</option>
|
||||
{% for satellite in satellites %}
|
||||
<option data-norad="{{ satellite.norad_cat_id }}" value="{{ satellite.norad_cat_id }}">
|
||||
<option data-norad="{{ satellite.norad_cat_id }}" value="{{ satellite.norad_cat_id }}"
|
||||
{% ifequal satellite.norad_cat_id norad %}selected{% endifequal %}>
|
||||
{{ satellite.norad_cat_id }} - {{ satellite.name }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in New Issue