diff --git a/application/controllers/Satellite.php b/application/controllers/Satellite.php index 129669559..8638cfc6f 100644 --- a/application/controllers/Satellite.php +++ b/application/controllers/Satellite.php @@ -227,16 +227,25 @@ class Satellite extends CI_Controller { $this->load->view('satellite/schedule',$data); } - public function get_tle() { + public function get_sat_info() { $sat = $this->security->xss_clean($this->input->post('sat')); $this->load->model('satellite_model'); - $satellite_data = $this->satellite_model->get_tle($sat); + $satellite_data = $this->satellite_model->get_sat_info($sat); header('Content-Type: application/json'); echo json_encode($satellite_data, JSON_FORCE_OBJECT); } + public function lotw_support() { + $sat = $this->security->xss_clean($this->input->post('sat')); + $this->load->model('satellite_model'); + $lotw_data = $this->satellite_model->lotw_support($sat); + + header('Content-Type: application/json'); + echo json_encode($lotw_data); + } + public function pass() { $this->load->model('satellite_model'); @@ -384,12 +393,12 @@ class Satellite extends CI_Controller { foreach ($satellites as $sat) { // Loop through known SATs if ( (count($input_sat) > 0) && !((count($input_sat) == 1) && (($input_sat[0] ?? '') == '')) ) { // User wants specific SATs (which isn't "All" or empty)?? if (in_array($sat->satname,$input_sat)) { - $tles[]=$this->satellite_model->get_tle($sat->satname); + $tles[]=$this->satellite_model->get_sat_info($sat->satname); } else { continue; } } else { // No specific SAT, but all - $tles[]=$this->satellite_model->get_tle($sat->satname); + $tles[]=$this->satellite_model->get_sat_info($sat->satname); } } return $tles; @@ -660,7 +669,7 @@ class Satellite extends CI_Controller { $this->load->model('satellite_model'); $data['satinfo'] = $this->satellite_model->getsatellite($id)->result(); - $data['tleinfo'] = $this->satellite_model->get_tle($data['satinfo'][0]->name); + $data['tleinfo'] = $this->satellite_model->get_sat_info($data['satinfo'][0]->name); $this->load->view('satellite/tleinfo', $data); } diff --git a/application/models/Satellite_model.php b/application/models/Satellite_model.php index 46a7d0784..67fa8f6b4 100644 --- a/application/models/Satellite_model.php +++ b/application/models/Satellite_model.php @@ -189,9 +189,9 @@ class Satellite_model extends CI_Model { return $groups; } - function get_tle($sat) { - $this->db->select('satellite.name AS satellite, satellite.displayname AS displayname, tle.tle, tle.updated'); - $this->db->join('tle', 'satellite.id = tle.satelliteid'); + function get_sat_info($sat) { + $this->db->select('satellite.name AS satellite, satellite.displayname AS displayname, tle.tle, tle.updated, satellite.lotw AS lotw_support'); + $this->db->join('tle', 'satellite.id = tle.satelliteid', 'left'); $this->db->where('name', $sat); $query = $this->db->get('satellite'); return $query->row(); diff --git a/application/views/qso/index.php b/application/views/qso/index.php index bd657926b..c3424093a 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -38,6 +38,9 @@ switch ($date_format) { var lang_qso_wait_before_saving = "= __("Please wait before saving another QSO"); ?>"; var latlng=[]; var user_date_format = ""; // Pass the user's date format to JavaScript + var lang_qso_sat_lotw_support_not_found = "= __("Satellite not found"); ?>"; + var lang_qso_sat_lotw_supported = "= __("Supported by LoTW"); ?>"; + var lang_qso_sat_lotw_not_supported = "= __("Not supported by LoTW"); ?>"; @@ -668,7 +671,9 @@ if (typeof window.DX_WATERFALL_FIELD_MAP === 'undefined') { - +
' . $tleinfo->tle . ''; echo ''; diff --git a/assets/js/sections/flightpath.js b/assets/js/sections/flightpath.js index 3e6cfaebc..94d06e5d2 100644 --- a/assets/js/sections/flightpath.js +++ b/assets/js/sections/flightpath.js @@ -719,7 +719,7 @@ function plot_sat() { } $.ajax({ - url: base_url + 'index.php/satellite/get_tle', + url: base_url + 'index.php/satellite/get_sat_info', type: 'post', data: { sat: $("#sats").val(), diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 8b8e61e86..73ecb119e 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -933,10 +933,18 @@ $("#sat_name").on('change', function () { $("#selectPropagation").val(""); stop_az_ele_ticker(); } else { - get_tles(); + $('#lotw_support').text(""); + $('#lotw_support').removeClass(); + get_sat_info(); } }); +$("#sat_name").on('focusout', function () { + if ($(this).val().length == 0) { + $('#lotw_support').text(""); + $('#lotw_support').removeClass(); + } +}); var satupdater; @@ -997,27 +1005,39 @@ function start_az_ele_ticker(tle) { satupdater=setInterval(updateAzEl, 1000); } -function get_tles() { +function get_sat_info() { stop_az_ele_ticker(); $.ajax({ - url: base_url + 'index.php/satellite/get_tle', + url: base_url + 'index.php/satellite/get_sat_info', type: 'post', data: { sat: $("#sat_name").val(), }, success: function (data) { if (data !== null) { - start_az_ele_ticker(data); + if (data.tle) { + start_az_ele_ticker(data); + } + if (data.lotw_support == 'Y') { + $('#lotw_support').html(lang_qso_sat_lotw_supported).fadeIn("slow"); + $('#lotw_support').addClass('badge bg-success'); + } else if (data.lotw_support == 'N') { + $('#lotw_support').html(lang_qso_sat_lotw_not_supported).fadeIn("slow"); + $('#lotw_support').addClass('badge bg-danger'); + } + } else { + $('#lotw_support').html(lang_qso_sat_lotw_support_not_found).fadeIn("slow"); + $('#lotw_support').addClass('badge bg-warning'); } }, error: function (data) { - console.log('Something went wrong while trying to fetch TLE for sat: '+$("#sat_name")); + console.log('Something went wrong while trying to fetch info for sat: '+$("#sat_name")); }, }); } if ($("#sat_name").val() !== '') { - get_tles(); + get_sat_info(); } $('#stateDropdown').on('change', function () { @@ -1214,6 +1234,8 @@ function reset_fields() { pendingReferencesMap.clear(); $('#locator_info').text(""); + $('#lotw_support').text(""); + $('#lotw_support').removeClass(); $('#comment').val(""); $('#country').val(""); $('#continent').val(""); @@ -2846,6 +2868,8 @@ function highlightSCP(term, base) { function resetDefaultQSOFields() { $('#callsign_info').text(""); $('#locator_info').text(""); + $('#lotw_support').text(""); + $('#lotw_support').removeClass(); $('#country').val(""); $('#continent').val(""); $("#distance").val("");