mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 10:24:14 +00:00
Reworked page. Added azimuth chart with filters
This commit is contained in:
@@ -239,13 +239,18 @@ class Statistics extends CI_Controller {
|
||||
|
||||
public function antennaanalytics() {
|
||||
$this->load->model('stats');
|
||||
$this->load->model('logbookadvanced_model');
|
||||
$this->load->model('bands');
|
||||
|
||||
$data = array();
|
||||
|
||||
$data['azelarray'] = $this->stats->azeldata();
|
||||
|
||||
$data['satellites'] = $this->stats->get_sats();
|
||||
|
||||
$data['bands'] = $this->bands->get_worked_bands();
|
||||
$data['modes'] = $this->logbookadvanced_model->get_modes();
|
||||
$data['sats'] = $this->bands->get_worked_sats();
|
||||
$data['orbits'] = $this->bands->get_worked_orbits();
|
||||
|
||||
$footerData = [];
|
||||
$footerData['scripts'] = [
|
||||
@@ -258,4 +263,17 @@ class Statistics extends CI_Controller {
|
||||
$this->load->view('statistics/antennaanalytics', $data);
|
||||
$this->load->view('interface_assets/footer', $footerData);
|
||||
}
|
||||
|
||||
public function get_azimuth_data() {
|
||||
$band = xss_clean($this->input->post('band'));
|
||||
$mode = xss_clean($this->input->post('mode'));
|
||||
$sat = xss_clean($this->input->post('sat'));
|
||||
$orbit = xss_clean($this->input->post('orbit'));
|
||||
|
||||
$this->load->model('stats');
|
||||
$azimutharray = $this->stats->azimuthdata($band, $mode, $sat, $orbit);
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($azimutharray);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -703,6 +703,59 @@
|
||||
$result = $this->db->query($sql);
|
||||
return $result->result();
|
||||
}
|
||||
|
||||
function azimuthdata($band, $mode, $sat, $orbit) {
|
||||
$conditions = [];
|
||||
$binding = [];
|
||||
|
||||
$this->load->model('logbooks_model');
|
||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||
|
||||
if (!$logbooks_locations_array) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($band !== 'All') {
|
||||
if($band != "SAT") {
|
||||
$conditions[] = "COL_BAND = ? and COL_PROP_MODE != 'SAT'";
|
||||
$binding[] = trim($band);
|
||||
} else {
|
||||
$conditions[] = "COL_PROP_MODE = 'SAT'";
|
||||
if ($sat !== 'All') {
|
||||
$conditions[] = "COL_SAT_NAME = ?";
|
||||
$binding[] = trim($sat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode !== 'All') {
|
||||
$conditions[] = "(COL_MODE = ? or COL_SUBMODE = ?)";
|
||||
$binding[] = $mode;
|
||||
$binding[] = $mode;
|
||||
}
|
||||
|
||||
if ($orbit !== 'All' && $orbit !== '') {
|
||||
$conditions[] = "orbit = ?";
|
||||
$binding[] = $orbit;
|
||||
}
|
||||
|
||||
$where = trim(implode(" AND ", $conditions));
|
||||
if ($where != "") {
|
||||
$where = "AND $where";
|
||||
}
|
||||
|
||||
$sql = "SELECT count(*) qsos, round(COL_ANT_AZ) azimuth
|
||||
FROM logbook
|
||||
where station_id in (" . implode(',',$logbooks_locations_array) . ")
|
||||
and coalesce(col_ant_az, '') <> ''
|
||||
$where
|
||||
group by round(col_ant_az)";
|
||||
|
||||
$result = $this->db->query($sql, $binding);
|
||||
return $result->result();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -5,44 +5,124 @@ echo json_encode($azelarray);
|
||||
?>;
|
||||
</script>
|
||||
<div class="container">
|
||||
<br />
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<?= __("Antenna Analytics"); ?>
|
||||
<br />
|
||||
<h2><?= __("Antenna Analytics"); ?></h2>
|
||||
<br>
|
||||
<div class="tabs">
|
||||
<ul class="nav nav-tabs" id="myTab" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" id="home-tab" data-bs-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true"><?= __("Azimuth"); ?></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="elevation-tab" data-bs-toggle="tab" href="#elevation" role="tab" aria-controls="elevation" aria-selected="false"><?= __("Elevation"); ?></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="tables-container mx-2">
|
||||
<form class="d-flex align-items-center">
|
||||
<label class="my-1 me-2" id="satslabel" for="distplot_sats"><?= __("Satellite"); ?></label>
|
||||
<select class="form-select my-1 me-sm-2 w-auto" id="sats">
|
||||
<?php foreach($satellites as $sat) {
|
||||
echo '<option value="' . $sat . '"' . '>' . $sat . '</option>'."\n";
|
||||
} ?>
|
||||
</select>
|
||||
<div class="tab-content" id="myTabContent">
|
||||
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab"><br />
|
||||
<form class="form">
|
||||
<!-- Select Basic -->
|
||||
<div class="mb-3 row">
|
||||
<label class="w-auto control-label" for="band"><?= __("Band") ?></label>
|
||||
<div class="w-auto">
|
||||
<select id="band" name="band" class="form-select">
|
||||
<option value="All" <?php if ($this->input->post('band') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> ><?= __("All") ?></option>
|
||||
<?php foreach($bands as $band) {
|
||||
echo '<option value="' . $band . '"';
|
||||
if ($this->input->post('band') == $band) echo ' selected';
|
||||
echo '>' . $band . '</option>'."\n";
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label class="w-auto control-label" for="mode"><?= __("Mode") ?></label>
|
||||
<div class="w-auto">
|
||||
<select id="mode" name="mode" class="form-select">
|
||||
<option value="All" <?php if ($this->input->post('mode') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> ><?= __("All") ?></option>
|
||||
<?php
|
||||
foreach($modes as $mode){
|
||||
echo '<option value="' . $mode . '"';
|
||||
if ($this->input->post('mode') == $mode) echo ' selected';
|
||||
echo '>' . $mode . '</option>'."\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<label class="w-auto control-label" for="mode"><?= __("Sat") ?></label>
|
||||
<div class="w-auto">
|
||||
<select id="sat" name="sat" class="form-select">
|
||||
<option value="All" <?php if ($this->input->post('sat') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> ><?= __("All") ?></option>
|
||||
<?php
|
||||
foreach($sats as $sat){
|
||||
echo '<option value="' . $sat . '"';
|
||||
if ($this->input->post('sat') == $sat) echo ' selected';
|
||||
echo '>' . $sat . '</option>'."\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<label class="w-auto control-label" for="mode"><?= __("Orbit") ?></label>
|
||||
<div class="w-auto">
|
||||
<select id="orbit" name="orbit" class="form-select">
|
||||
<option value="All" <?php if ($this->input->post('orbit') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> ><?= __("All") ?></option>
|
||||
<?php
|
||||
foreach($orbits as $orbit){
|
||||
echo '<option value="' . $orbit . '"';
|
||||
if ($this->input->post('orbit') == $orbit) echo ' selected';
|
||||
echo '>' . $orbit . '</option>'."\n";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button id="plot" type="button" name="plot" class="btn btn-primary me-1 ld-ext-right ld-ext-right-plot" onclick="plot_sat()"><?= __("Plot"); ?><div class="ld ld-ring ld-spin"></div></button>
|
||||
</form>
|
||||
<?php
|
||||
if ($azelarray) {
|
||||
echo '<table style="width:100%" class="qsotable table-sm table table-bordered table-hover table-striped table-condensed text-center">
|
||||
<thead>';
|
||||
echo '<tr>';
|
||||
echo '<th>'.__("Elevation").'</th>';
|
||||
echo '<th>'.__("# QSOs").'</th>';
|
||||
echo '</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($azelarray as $qso) {
|
||||
echo '<tr>';
|
||||
echo '<th>' . $qso->elevation . '</th>';
|
||||
echo '<th>' . $qso->qsos . '</th>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tfoot></table>';
|
||||
}
|
||||
<div class="w-auto">
|
||||
<button id="button1id" type="button" name="button1id" class="btn btn-primary" onclick="plot_azimuth()"><?= __("Show") ?></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
?>
|
||||
<canvas id="elevationchart"></canvas>
|
||||
</div>
|
||||
</form>
|
||||
<canvas id="azimuthchart"></canvas>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade show" id="elevation" role="tabpanel" aria-labelledby="elevation-tab"><br />
|
||||
<form>
|
||||
<div class="mb-3 row">
|
||||
<label class="w-auto control-label" id="satslabel" for="distplot_sats"><?= __("Satellite"); ?></label>
|
||||
<div class="w-auto">
|
||||
<select class="form-select" id="sats">
|
||||
<?php foreach($satellites as $sat) {
|
||||
echo '<option value="' . $sat . '"' . '>' . $sat . '</option>'."\n";
|
||||
} ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="w-auto">
|
||||
<button id="plot" type="button" name="plot" class="btn btn-primary me-1 ld-ext-right ld-ext-right-plot" onclick="plot_sat()"><?= __("Show"); ?><div class="ld ld-ring ld-spin"></div></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div>
|
||||
<?php
|
||||
if ($azelarray) {
|
||||
echo '<table style="width:100%" class="qsotable table-sm table table-bordered table-hover table-striped table-condensed text-center">
|
||||
<thead>';
|
||||
echo '<tr>';
|
||||
echo '<th>'.__("Elevation").'</th>';
|
||||
echo '<th>'.__("# QSOs").'</th>';
|
||||
echo '</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
foreach ($azelarray as $qso) {
|
||||
echo '<tr>';
|
||||
echo '<th>' . $qso->elevation . '</th>';
|
||||
echo '<th>' . $qso->qsos . '</th>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tfoot></table>';
|
||||
}
|
||||
|
||||
?>
|
||||
<canvas id="elevationchart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,79 @@
|
||||
makeChart();
|
||||
//makeChart();
|
||||
|
||||
function plot_sat() {
|
||||
alert ('Yeah right');
|
||||
}
|
||||
|
||||
function plot_azimuth() {
|
||||
$.ajax({
|
||||
url: base_url+'index.php/statistics/get_azimuth_data',
|
||||
type: 'post',
|
||||
data: {'band': $('#band').val(),
|
||||
'mode': $('#mode').val(),
|
||||
'sat': $('#sat').val(),
|
||||
'orbit': $('#orbit').val()
|
||||
},
|
||||
success: function(tmp) {
|
||||
var dataQso = [];
|
||||
var labels = [];
|
||||
$.each(tmp, function () {
|
||||
// labels.push('Azimuth ' + this.azimuth + '°');
|
||||
labels.push(this.azimuth);
|
||||
dataQso.push(this.qsos);
|
||||
});
|
||||
|
||||
// using this to change color of legend and label according to background color
|
||||
var color = ifDarkModeThemeReturn('white', 'grey');
|
||||
var ctx = document.getElementById("azimuthchart").getContext('2d');
|
||||
var myChart = new Chart(ctx, {
|
||||
type: 'radar',
|
||||
data: {
|
||||
labels: labels,
|
||||
datasets: [{
|
||||
label: '# QSOs',
|
||||
data: dataQso,
|
||||
backgroundColor: 'rgba(54, 162, 235, 1)',
|
||||
borderColor: 'rgba(54, 162, 235, 1)',
|
||||
borderWidth: 2,
|
||||
color: color
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
plugins: {
|
||||
legend: {
|
||||
labels: {
|
||||
color: color
|
||||
}
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
r: { // Radial scale (angle and radius)
|
||||
// startAngle: -Math.PI / 2, // Start at the top (default is 0, which starts at the right)
|
||||
pointLabels: {
|
||||
callback: (label, index) => {
|
||||
// Show labels only for every 5 degrees
|
||||
return label % 10 === 0 ? `${label}°` : '';
|
||||
},
|
||||
color: color
|
||||
},
|
||||
grid: {
|
||||
circular: true, // Show circular grid lines
|
||||
color: color
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// using this to change color of csv-button if dark mode is chosen
|
||||
var background = $('body').css("background-color");
|
||||
|
||||
if (background != ('rgb(255, 255, 255)')) {
|
||||
$(".buttons-csv").css("color", "white");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function makeChart() {
|
||||
var labels = [];
|
||||
|
||||
Reference in New Issue
Block a user