Auto-calculate observation when parameters are set
parent
e5fc9b8cb7
commit
0d0e4f7898
|
@ -354,20 +354,22 @@ def observation_new(request):
|
|||
transmitter = filter_form.cleaned_data['transmitter']
|
||||
norad = filter_form.cleaned_data['norad']
|
||||
|
||||
if start_date:
|
||||
obs_filter['dates'] = False
|
||||
if start_date and end_date: # Either give both dates or ignore if only one is given
|
||||
start_date = datetime.strptime(start_date,
|
||||
'%Y/%m/%d %H:%M').strftime('%Y-%m-%d %H:%M')
|
||||
if end_date:
|
||||
end_date = (datetime.strptime(end_date, '%Y/%m/%d %H:%M') +
|
||||
timedelta(minutes=1)).strftime('%Y-%m-%d %H:%M')
|
||||
obs_filter['start_date'] = start_date
|
||||
obs_filter['end_date'] = end_date
|
||||
obs_filter['dates'] = True
|
||||
|
||||
obs_filter['exists'] = True
|
||||
obs_filter['norad'] = norad
|
||||
obs_filter['start_date'] = start_date
|
||||
obs_filter['end_date'] = end_date
|
||||
if norad:
|
||||
obs_filter['norad'] = norad
|
||||
obs_filter['transmitter'] = transmitter # Add transmitter only if norad exists
|
||||
if ground_station:
|
||||
obs_filter['ground_station'] = ground_station
|
||||
if norad:
|
||||
obs_filter['transmitter'] = transmitter
|
||||
else:
|
||||
obs_filter['exists'] = False
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* global moment, d3, Slider, calcPolarPlotSVG */
|
||||
|
||||
$(document).ready( function(){
|
||||
function select_proper_transmitters(filters){
|
||||
function select_proper_transmitters(filters, callback){
|
||||
var url = '/transmitters/' + filters.satellite + '/';
|
||||
if (filters.station) {
|
||||
url = '/transmitters/' + filters.satellite + '/' + filters.station + '/';
|
||||
|
@ -62,6 +62,9 @@ $(document).ready( function(){
|
|||
</option>`).prop('disabled', true);
|
||||
$('#transmitter-selection').selectpicker('refresh');
|
||||
}
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -140,14 +143,6 @@ $(document).ready( function(){
|
|||
var obs_filter_satellite = $('#form-obs').data('obs-filter-satellite');
|
||||
var obs_filter_transmitter = $('#form-obs').data('obs-filter-transmitter');
|
||||
|
||||
if (obs_filter) {
|
||||
select_proper_transmitters({
|
||||
satellite: obs_filter_satellite,
|
||||
value: obs_filter_transmitter,
|
||||
station: obs_filter_station
|
||||
});
|
||||
}
|
||||
|
||||
if (!obs_filter_dates) {
|
||||
var minStart = $('#datetimepicker-start').data('date-minstart');
|
||||
var minEnd = $('#datetimepicker-end').data('date-minend');
|
||||
|
@ -191,7 +186,7 @@ $(document).ready( function(){
|
|||
$('#windows-data').empty();
|
||||
});
|
||||
|
||||
$('#calculate-observation').click( function(){
|
||||
function calculate_observation(){
|
||||
$('.calculation-result').show();
|
||||
$('#timeline').empty();
|
||||
$('#hover-obs').hide();
|
||||
|
@ -276,7 +271,7 @@ $(document).ready( function(){
|
|||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function timeline_init(start, end, payload){
|
||||
var start_time_timeline = moment.utc(start).valueOf();
|
||||
|
@ -392,12 +387,29 @@ $(document).ready( function(){
|
|||
$('#schedule-observation').removeAttr('disabled');
|
||||
}
|
||||
|
||||
$('#calculate-observation').click( function(){
|
||||
calculate_observation();
|
||||
});
|
||||
|
||||
if (obs_filter) {
|
||||
select_proper_transmitters({
|
||||
satellite: obs_filter_satellite,
|
||||
value: obs_filter_transmitter,
|
||||
station: obs_filter_station
|
||||
}, function(){
|
||||
if (obs_filter_dates && obs_filter_station && obs_filter_satellite){
|
||||
$('#calculate-observation').hide();
|
||||
$('#obs-selection-tools').hide();
|
||||
calculate_observation();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Hotkeys bindings
|
||||
$(document).bind('keyup', function(event){
|
||||
if(document.activeElement.tagName != 'INPUT'){
|
||||
if (event.which == 67) {
|
||||
var link_calculate = $('#calculate-observation');
|
||||
link_calculate[0].click();
|
||||
calculate_observation();
|
||||
} else if (event.which == 83) {
|
||||
var link_schedule = $('#schedule-observation');
|
||||
link_schedule[0].click();
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
<form class="form-horizontal" role="form" action="{% url 'base:observation_new' %}"
|
||||
method="post" data-obs-filter="{{ obs_filter.exists|lower }}" data-obs-filter-station="{{ obs_filter.ground_station }}"
|
||||
data-obs-filter-dates="{{ obs_filter.start_date }}" data-obs-filter-transmitter="{{ obs_filter.transmitter }}"
|
||||
data-obs-filter-dates="{{ obs_filter.dates|lower }}" data-obs-filter-transmitter="{{ obs_filter.transmitter }}"
|
||||
data-obs-filter-satellite="{{ obs_filter.norad }}" id="form-obs">{% csrf_token %}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
|
@ -87,7 +87,7 @@
|
|||
<div class="col-sm-9">
|
||||
<div class='input-group date' id="datetimepicker-start"
|
||||
data-date-minstart="{{ date_min_start }}">
|
||||
{% if obs_filter.start_date %}
|
||||
{% if obs_filter.dates %}
|
||||
<input type="text" class="form-control" name="start-time"
|
||||
value="{{ obs_filter.start_date}}" readonly>
|
||||
{% else %}
|
||||
|
@ -109,7 +109,7 @@
|
|||
<div class='input-group date' id="datetimepicker-end"
|
||||
data-date-maxrange="{{ date_max_range }}"
|
||||
data-date-minend="{{ date_min_end }}">
|
||||
{% if obs_filter.end_date %}
|
||||
{% if obs_filter.dates %}
|
||||
<input type="text" class="form-control" name="end-time"
|
||||
value="{{ obs_filter.end_date}}" readonly>
|
||||
{% else %}
|
||||
|
|
Loading…
Reference in New Issue