[Bandmap] Added cat
这个提交包含在:
父节点
906ecbc045
当前提交
fb39d8ec0d
共有 3 个文件被更改,包括 91 次插入 和 20 次删除
|
|
@ -11,6 +11,11 @@ class Bandmap extends CI_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
function index() {
|
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 = [];
|
||||||
$footerData['scripts'] = [
|
$footerData['scripts'] = [
|
||||||
'assets/js/sections/bandmap.js',
|
'assets/js/sections/bandmap.js',
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,38 @@
|
||||||
<script>
|
<script>
|
||||||
var dxcluster_provider="<?php echo base_url(); ?>index.php/dxcluster";
|
var dxcluster_provider="<?php echo base_url(); ?>index.php/dxcluster";
|
||||||
|
var cat_timeout_interval="<?php echo $this->optionslib->get_option('cat_timeout_interval'); ?>";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<h2><?php echo $page_title; ?></h2>
|
<h2><?php echo $page_title; ?></h2>
|
||||||
<div class="form-group col-md-6">
|
<div class="messages"></div>
|
||||||
<label for="band"><?php echo lang('gen_hamradio_band'); ?></label>
|
<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">
|
<figure class="highcharts-figure">
|
||||||
<div id="bandmap"></div>
|
<div id="bandmap"></div>
|
||||||
<p class="highcharts-description">
|
<p class="highcharts-description">
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ $(function() {
|
||||||
function set_chart(band,maxAgeMinutes) {
|
function set_chart(band,maxAgeMinutes) {
|
||||||
let dxurl = dxcluster_provider + "/spots/" + band + "/" +maxAgeMinutes;
|
let dxurl = dxcluster_provider + "/spots/" + band + "/" +maxAgeMinutes;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: dxurl,
|
url: dxurl,
|
||||||
cache: false,
|
cache: false,
|
||||||
dataType: "json"
|
dataType: "json"
|
||||||
}).done(function(dxspots) {
|
}).done(function(dxspots) {
|
||||||
|
|
@ -169,3 +169,62 @@ $(function() {
|
||||||
set_chart($('#band option:selected').val(),30);
|
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);
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用