Add basis continent statistics

这个提交包含在:
phl0 2023-02-09 01:05:36 +01:00
父节点 9efb643a5a
当前提交 8b38d28122
找不到此签名对应的密钥
GPG 密钥 ID: 48EA1E640798CA9A
共有 6 个文件被更改,包括 253 次插入0 次删除

查看文件

@ -0,0 +1,48 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Continents extends CI_Controller {
public function index()
{
$this->load->model('user_model');
$this->load->model('bands');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) {
if($this->user_model->validate_session()) {
$this->user_model->clear_session();
show_error('Access denied<p>Click <a href="'.site_url('user/login').'">here</a> to log in as another user', 403);
} else {
redirect('user/login');
}
}
// Render User Interface
// Set Page Title
$data['page_title'] = "Continents";
// Load Views
$this->load->view('interface_assets/header', $data);
$this->load->view('continents/index');
$this->load->view('interface_assets/footer');
}
public function get_continents() {
$this->load->model('logbook_model');
$continentsstats = array();
$total_continents = $this->logbook_model->total_continents();
$i = 0;
if ($total_continents) {
foreach($total_continents->result() as $qso_numbers) {
$continentsstats[$i]['cont'] = $qso_numbers->COL_CONT;
$continentsstats[$i++]['count'] = $qso_numbers->count;
}
}
header('Content-Type: application/json');
echo json_encode($continentsstats);
}
}

查看文件

@ -1630,6 +1630,28 @@ class Logbook_model extends CI_Model {
return $query;
}
/* Return total number of QSOs per continent */
function total_continents() {
$CI =& get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$this->db->select('COL_CONT, COUNT( * ) as count', FALSE);
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_CONT is not null');
$this->db->where('COL_CONT !=', '');
$this->db->order_by('count DESC');
$this->db->group_by('COL_CONT');
$query = $this->db->get($this->config->item('table_name'));
return $query;
}
/* Return total number of CW QSOs */
function total_cw() {

查看文件

@ -0,0 +1,38 @@
<style>
#continentChart{
margin: 0 auto;
}
</style>
<div class="container statistics">
<h2>
<?php echo $page_title; ?>
</h2>
<br>
<div hidden class="tabs">
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="continents-tab" data-toggle="tab" href="#continents" role="tab" aria-controls="continents" aria-selected="true">No of QSOs</a>
</li>
</ul>
</div>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade active show" id="continents" role="tabpanel" aria-labelledby="continents-tab">
<br/>
<div style="display: flex;" id="continentContainer"><div style="flex: 1;"><canvas id="continentChart" width="500" height="500"></canvas></div><div style="flex: 1;" id="continentTable">
<table style="width:100%" class="continentstable table table-sm table-bordered table-hover table-striped table-condensed text-center"><thead>
<tr>
<td>#</td>
<td>Continent</td>
<td># of QSO's worked</td>
</tr>
</thead>
<tbody></tbody>
</table></div></div>
</div>
</div>
</div>

查看文件

@ -64,6 +64,12 @@ function load_was_map() {
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/sections/statistics.js"></script>
<?php } ?>
<?php if ($this->uri->segment(1) == "continents") { ?>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/chart.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/chartjs-plugin-piechart-outlabels.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/sections/continents.js"></script>
<?php } ?>
<?php if ($this->uri->segment(1) == "adif" || $this->uri->segment(1) == "qrz") { ?>
<!-- Javascript used for ADIF Import and Export Areas -->
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/moment.min.js"></script>

查看文件

@ -110,6 +110,8 @@
<a class="dropdown-item" href="<?php echo site_url('timeplotter');?>" title="View time when worked"><i class="fas fa-chart-area"></i> Timeplotter</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('map/custom');?>" title="Custom Maps of QSOs"><i class="fas fa-globe-europe"></i> Custom Maps</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('continents');?>" title="Continents"><i class="fas fa-globe-europe"></i> Continents</a>
</div>
</li>

查看文件

@ -0,0 +1,137 @@
totalContinentQsos();
// Needed for continentstable header fix, will be squished without
$("a[href='#continents']").on('shown.bs.tab', function(e) {
$(".continentstable").DataTable().columns.adjust();
});
function totalContinentQsos() {
// using this to change color of legend and label according to background color
var color = ifDarkModeThemeReturn('white', 'grey');
$.ajax({
url: base_url+'index.php/continents/get_continents',
type: 'post',
success: function (data) {
if (data.length > 0) {
$('.tabs').removeAttr('hidden');
var labels = [];
var dataQso = [];
var totalQso = Number(0);
var $myTable = $('.continentstable');
var i = 1;
// building the rows in the table
var rowElements = data.map(function (row) {
var $row = $('<tr></tr>');
var $iterator = $('<td></td>').html(i++);
var $type = $('<td></td>').html(row.cont);
var $content = $('<td></td>').html(row.count);
$row.append($iterator, $type, $content);
return $row;
});
// finally inserting the rows
$myTable.append(rowElements);
$.each(data, function () {
labels.push(this.cont);
dataQso.push(this.count);
totalQso = Number(totalQso) + Number(this.count);
});
const COLORS = ["#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00", "#b82e2e", "#316395", "#994499"]
var ctx = document.getElementById("continentChart").getContext('2d');
var myChart = new Chart(ctx, {
plugins: [ChartPieChartOutlabels],
type: 'doughnut',
data: {
labels: labels,
datasets: [{
borderColor: 'rgba(54, 162, 235, 1)',
label: 'Number of QSO\'s worked',
data: dataQso,
backgroundColor: ["#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00", "#b82e2e", "#316395", "#994499"],
borderWidth: 1,
labels: labels,
}]
},
options: {
layout: {
padding: 100
},
title: {
fontColor: color,
fullSize: true,
},
responsive: false,
maintainAspectRatio: true,
plugins: {
legend: {
display: false,
labels: {
boxWidth: 15,
color: color,
font: {
size: 14,
}
},
position: 'right',
align: "middle"
},
outlabels: {
display: function(context) { // Hide labels with low percentage
return ((context.dataset.data[context.dataIndex] / totalQso * 100) > 1)
},
backgroundColor: COLORS,
borderColor: COLORS,
borderRadius: 2, // Border radius of Label
borderWidth: 2, // Thickness of border
color: 'white',
stretch: 10,
padding: 0,
font: {
resizable: true,
minSize: 12,
maxSize: 25,
family: Chart.defaults.font.family,
size: Chart.defaults.font.size,
style: Chart.defaults.font.style,
lineHeight: Chart.defaults.font.lineHeight,
},
zoomOutPercentage: 100,
textAlign: 'start',
backgroundColor: COLORS,
}
}
}
});
// 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");
}
$('.continentstable').DataTable({
responsive: false,
ordering: false,
"scrollY": "330px",
"scrollX": true,
"ScrollCollapse": true,
"paging": false,
bFilter: false,
bInfo: false,
});
}
}
});
}