Merge pull request #1708 from phl0/panMapSttaionProfileSelect

Pan map on station profile select
This commit is contained in:
Florian (DF2ET)
2025-02-27 10:39:13 +01:00
committed by GitHub
4 changed files with 42 additions and 1 deletions

View File

@@ -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);
}
}
}

View File

@@ -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;
}
}
?>

View File

@@ -305,7 +305,7 @@
<div class="tab-pane fade" id="station" role="tabpanel" aria-labelledby="station-tab">
<div class="mb-3">
<label for="stationProfile"><?= __("Station Location"); ?></label>
<select id="stationProfile" class="form-select" name="station_profile">
<select id="stationProfile" class="form-select" name="station_profile" onChange="panMap(this.value);">
<?php
$power = '';
foreach ($stations->result() as $stationrow) {

View File

@@ -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("");
@@ -1254,6 +1255,22 @@ 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]]);
pos = result;
}
},
error: function() {
},
});
}
$(document).ready(function () {
qrg_inputtype();
clearTimeout();