diff --git a/application/controllers/Satellite.php b/application/controllers/Satellite.php index cdf285253..8638cfc6f 100644 --- a/application/controllers/Satellite.php +++ b/application/controllers/Satellite.php @@ -227,11 +227,11 @@ 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); @@ -393,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; @@ -669,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 4e435ed5e..67fa8f6b4 100644 --- a/application/models/Satellite_model.php +++ b/application/models/Satellite_model.php @@ -189,16 +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'); - $this->db->where('name', $sat); - $query = $this->db->get('satellite'); - return $query->row(); - } - - function lotw_support($sat) { - $this->db->select('satellite.lotw AS lotw_support'); + 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/satellite/tleinfo.php b/application/views/satellite/tleinfo.php index 81ee748dd..6806ef1bb 100644 --- a/application/views/satellite/tleinfo.php +++ b/application/views/satellite/tleinfo.php @@ -2,7 +2,7 @@
' . $tleinfo->tle . ''; echo ''; diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 3fed03b2f..73ecb119e 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -935,8 +935,7 @@ $("#sat_name").on('change', function () { } else { $('#lotw_support').text(""); $('#lotw_support').removeClass(); - get_tles(); - get_lotw_support(); + get_sat_info(); } }); @@ -1006,56 +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); - } - }, - error: function (data) { - console.log('Something went wrong while trying to fetch TLE for sat: '+$("#sat_name")); - }, - }); -} - -function get_lotw_support() { - $.ajax({ - url: base_url + 'index.php/satellite/lotw_support', - type: 'post', - data: { - sat: $("#sat_name").val(), - }, - success: function (data) { - if (data == null) { + 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'); - } else { - if (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'); - } - } } }, error: function (data) { - console.log('Something went wrong while trying to determine LoTW support 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 () {