From 240f68b217a215727d6b35199ff424646e5706cd Mon Sep 17 00:00:00 2001 From: phl0 Date: Tue, 25 Feb 2025 20:14:52 +0100 Subject: [PATCH 1/4] Pan map on station profile select --- application/controllers/Station.php | 9 +++++++++ application/models/Stations.php | 15 +++++++++++++++ application/views/qso/index.php | 2 +- assets/js/sections/qso.js | 16 ++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/application/controllers/Station.php b/application/controllers/Station.php index f7afddada..78f138d32 100644 --- a/application/controllers/Station.php +++ b/application/controllers/Station.php @@ -171,4 +171,13 @@ class Station extends CI_Controller redirect('stationsetup'); } + public function stationProfileCoords($id) { + $id = $this->security->xss_clean($id); + $this->load->model('stations'); + if ($this->stations->check_station_is_accessible($id)) { + $coords = $this->stations->lookupProfileCoords($id); + print json_encode($coords); + } + } + } diff --git a/application/models/Stations.php b/application/models/Stations.php index c59704c3a..d41d80254 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -601,6 +601,21 @@ class Stations extends CI_Model { if (($station_lat!=0)&&($station_lng!=0)) { $_jsonresult = array('lat'=>$station_lat,'lng'=>$station_lng,'html'=>$station_active->station_gridsquare,'label'=>$station_active->station_profile_name,'icon'=>'stationIcon'); } return (count($_jsonresult)>0)?(array('station'=>$_jsonresult)):array(); } + + public function lookupProfileCoords($stationid) { + $sql = "SELECT station_gridsquare FROM station_profile WHERE station_id = ?;"; + $query = $this->db->query($sql, $stationid); + if ($query->num_rows() == 1) { + $row = $query->row(); + if ($row->station_gridsquare != '') { + if (!$this->load->is_loaded('Qra')) { + $this->load->library('Qra'); + } + return $this->qra->qra2latlong($row->station_gridsquare); + } + } + return false; + } } ?> diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 83d74988c..993934697 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -305,7 +305,7 @@
- result() as $stationrow) { diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index becb9e7ec..500d1ca7a 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -1254,7 +1254,23 @@ function testTimeOffConsistency() { return true; } +function panMap(stationProfileIndex) { + $.ajax({ + url: base_url + 'index.php/station/stationProfileCoords/'+stationProfileIndex, + type: 'get', + success: function(data) { + result = JSON.parse(data); + if (typeof result[0] !== "undefined" && typeof result[1] !== "undefined") { + mymap.panTo([result[0], result[1]]); + } + }, + error: function() { + }, + }); +} + $(document).ready(function () { + qrg_inputtype(); clearTimeout(); set_timers(); From 948ac968f92fd4137be70fd533cd34bb7630ce9a Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 26 Feb 2025 08:36:24 +0100 Subject: [PATCH 2/4] Store position of new station location for map --- assets/js/sections/qso.js | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 500d1ca7a..ec35049c3 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -1262,6 +1262,7 @@ function panMap(stationProfileIndex) { result = JSON.parse(data); if (typeof result[0] !== "undefined" && typeof result[1] !== "undefined") { mymap.panTo([result[0], result[1]]); + pos = result; } }, error: function() { From ed3241f2735ec1014c606c42dd3f644c3ecb6d5e Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 26 Feb 2025 08:46:52 +0100 Subject: [PATCH 3/4] Pan map back to active station upon full reset of fields --- assets/js/sections/qso.js | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index ec35049c3..f7255607e 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -506,6 +506,7 @@ $('#btn_fullreset').on("click", function () { function reset_to_default() { reset_fields(); + panMap(activeStationId); $("#stationProfile").val(activeStationId); $("#selectPropagation").val(""); $("#frequency_rx").val(""); From c40b91e14773a36f177092c091322ec3f576a40e Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 26 Feb 2025 08:49:41 +0100 Subject: [PATCH 4/4] Remove blank line --- assets/js/sections/qso.js | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index f7255607e..7d5559efd 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -1272,7 +1272,6 @@ function panMap(stationProfileIndex) { } $(document).ready(function () { - qrg_inputtype(); clearTimeout(); set_timers();