[Bandmap] Added cat

pull/2317/head
Andreas 2023-07-21 13:27:13 +02:00
rodzic 906ecbc045
commit fb39d8ec0d
3 zmienionych plików z 91 dodań i 20 usunięć

Wyświetl plik

@ -11,6 +11,11 @@ class Bandmap extends CI_Controller {
}
function index() {
$this->load->model('cat');
$this->load->model('bands');
$data['radios'] = $this->cat->radios();
$data['bands'] = $this->bands->get_user_bands_for_qso_entry();
$footerData = [];
$footerData['scripts'] = [
'assets/js/sections/bandmap.js',

Wyświetl plik

@ -1,31 +1,38 @@
<script>
var dxcluster_provider="<?php echo base_url(); ?>index.php/dxcluster";
var cat_timeout_interval="<?php echo $this->optionslib->get_option('cat_timeout_interval'); ?>";
</script>
<div class="container">
<div class="container">
<br>
<h2><?php echo $page_title; ?></h2>
<div class="form-group col-md-6">
<label for="band"><?php echo lang('gen_hamradio_band'); ?></label>
<div class="messages"></div>
<div class="form-inline">
<label class="my-1 mr-2" for="radio"><?php echo lang('gen_hamradio_radio'); ?></label>
<select class="form-control-sm radios my-1 mr-sm-2" id="radio" name="radio">
<option value="0" selected="selected"><?php echo lang('general_word_none'); ?></option>
<?php foreach ($radios->result() as $row) { ?>
<option value="<?php echo $row->id; ?>" <?php if($this->session->userdata('radio') == $row->id) { echo "selected=\"selected\""; } ?>><?php echo $row->radio; ?></option>
<?php } ?>
</select>
<label class="my-1 mr-2" for="band"><?php echo lang('gen_hamradio_band'); ?></label>
<select id="band" class="form-control-sm my-1 mr-sm-2" name="band">
<?php foreach($bands as $key=>$bandgroup) {
echo '<optgroup label="' . strtoupper($key) . '">';
foreach($bandgroup as $band) {
echo '<option value="' . $band . '"';
if ($band == "20m") echo ' selected';
echo '>' . $band . '</option>'."\n";
}
echo '</optgroup>';
}
?>
</select>
</div>
<select id="band" class="form-control form-control-sm" name="band">
<?php
$bands = $this->bands->get_user_bands_for_qso_entry();
foreach($bands as $key=>$bandgroup) {
echo '<optgroup label="' . strtoupper($key) . '">';
foreach($bandgroup as $band) {
echo '<option value="' . $band . '"';
if ($band == "20m") echo ' selected';
echo '>' . $band . '</option>'."\n";
}
echo '</optgroup>';
}
?>
</select>
</div>
<figure class="highcharts-figure">
<div id="bandmap"></div>
<p class="highcharts-description">

Wyświetl plik

@ -147,7 +147,7 @@ $(function() {
function set_chart(band,maxAgeMinutes) {
let dxurl = dxcluster_provider + "/spots/" + band + "/" +maxAgeMinutes;
$.ajax({
url: dxurl,
url: dxurl,
cache: false,
dataType: "json"
}).done(function(dxspots) {
@ -169,3 +169,62 @@ $(function() {
set_chart($('#band option:selected').val(),30);
});
});
var updateFromCAT = function() {
if($('select.radios option:selected').val() != '0') {
radioID = $('select.radios option:selected').val();
$.getJSON( "radio/json/" + radioID, function( data ) {
if (data.error) {
if (data.error == 'not_logged_in') {
$(".radio_cat_state" ).remove();
if($('.radio_login_error').length == 0) {
$('.messages').prepend('<div class="alert alert-danger radio_login_error" role="alert"><i class="fas fa-broadcast-tower"></i> You\'re not logged it. Please <a href="'+base_url+'">login</a></div>');
}
}
// Put future Errorhandling here
} else {
if($('.radio_login_error').length != 0) {
$(".radio_login_error" ).remove();
}
var band = frequencyToBand(data.frequency);
if (band !== $("#band").val()) {
$("#band").val(band);
$("#band").trigger("change");
}
var minutes = Math.floor(cat_timeout_interval / 60);
if(data.updated_minutes_ago > minutes) {
$(".radio_cat_state" ).remove();
if($('.radio_timeout_error').length == 0) {
$('.messages').prepend('<div class="alert alert-danger radio_timeout_error" role="alert"><i class="fas fa-broadcast-tower"></i> Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.</div>');
} else {
$('.radio_timeout_error').html('Radio connection timed-out: ' + $('select.radios option:selected').text() + ' data is ' + data.updated_minutes_ago + ' minutes old.');
}
} else {
$(".radio_timeout_error" ).remove();
text = '<i class="fas fa-broadcast-tower"></i><span style="margin-left:10px;"></span><b>TX:</b> '+(Math.round(parseInt(data.frequency)/100)/10000).toFixed(4)+' MHz';
if(data.mode != null) {
text = text+'<span style="margin-left:10px"></span>'+data.mode;
}
if(data.power != null && data.power != 0) {
text = text+'<span style="margin-left:10px"></span>'+data.power+' W';
}
if (! $('#radio_cat_state').length) {
$('.messages').prepend('<div aria-hidden="true"><div id="radio_cat_state" class="alert alert-success radio_cat_state" role="alert">'+text+'</div></div>');
} else {
$('#radio_cat_state').html(text);
}
}
}
});
}
};
// Update frequency every three second
setInterval(updateFromCAT, 3000);
// If a radios selected from drop down select radio update.
$('.radios').change(updateFromCAT);