added SSTV image page to the nav menu in the header

pull/3047/head
Patrick Burns 2024-04-02 16:55:00 -05:00
rodzic f8eeaab064
commit e345364bfa
30 zmienionych plików z 251 dodań i 47 usunięć

13
.vscode/settings.json vendored 100644
Wyświetl plik

@ -0,0 +1,13 @@
{
"cSpell.words": [
"callsign",
"cloudlog",
"hamradio",
"qslcard",
"sstv",
"sstvimages",
"sstvtable",
"SUBMODE",
"userdata"
]
}

Wyświetl plik

@ -15,7 +15,7 @@ class Qsl extends CI_Controller {
// Default view when loading controller.
public function index() {
$this->load->helper('storage'); // Load the storage helper
$folder_name = "assets/qslcard";
$data['storage_used'] = sizeFormat(folderSize($folder_name));
@ -181,48 +181,4 @@ class Qsl extends CI_Controller {
$this->load->view('qslcard/qslcarousel', $data);
}
}
// Functions for storage, these need shifted to a libary to use across Cloudlog
function folderSize($dir){
$count_size = 0;
$count = 0;
$dir_array = scandir($dir);
foreach($dir_array as $key=>$filename){
if($filename!=".." && $filename!="."){
if(is_dir($dir."/".$filename)){
$new_foldersize = foldersize($dir."/".$filename);
$count_size = $count_size+ $new_foldersize;
}else if(is_file($dir."/".$filename)){
$count_size = $count_size + filesize($dir."/".$filename);
$count++;
}
}
}
return $count_size;
}
function sizeFormat($bytes){
$kb = 1024;
$mb = $kb * 1024;
$gb = $mb * 1024;
$tb = $gb * 1024;
if (($bytes >= 0) && ($bytes < $kb)) {
return $bytes . ' B';
} elseif (($bytes >= $kb) && ($bytes < $mb)) {
return ceil($bytes / $kb) . ' KB';
} elseif (($bytes >= $mb) && ($bytes < $gb)) {
return ceil($bytes / $mb) . ' MB';
} elseif (($bytes >= $gb) && ($bytes < $tb)) {
return ceil($bytes / $gb) . ' GB';
} elseif ($bytes >= $tb) {
return ceil($bytes / $tb) . ' TB';
} else {
return $bytes . ' B';
}
}
}

Wyświetl plik

@ -8,11 +8,27 @@ class Sstv extends CI_Controller {
function __construct() {
parent::__construct();
$this->lang->load('qslcard');
$this->lang->load('sstv');
$this->load->model('user_model');
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
}
public function index() {
$this->load->helper('storage');
$folder_name = "assets/sstvimages";
$data['storage_used'] = sizeFormat(folderSize($folder_name));
// Render Page
$data['page_title'] = "SSTV Images";
$this->load->model('sstv_model');
$data['sstvArray'] = $this->sstv_model->getQsoWithSstvImageList();
$this->load->view('interface_assets/header', $data);
$this->load->view('sstv/index');
$this->load->view('interface_assets/footer');
}
public function uploadSSTV() {
$this->load->model('user_model');
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }

Wyświetl plik

@ -0,0 +1,44 @@
<?php
if (!function_exists('folderSize')) {
function folderSize($dir){
$count_size = 0;
$count = 0;
$dir_array = scandir($dir);
foreach($dir_array as $key=>$filename){
if($filename!=".." && $filename!="."){
if(is_dir($dir."/".$filename)){
$new_foldersize = folderSize($dir."/".$filename);
$count_size = $count_size+ $new_foldersize;
}else if(is_file($dir."/".$filename)){
$count_size = $count_size + filesize($dir."/".$filename);
$count++;
}
}
}
return $count_size;
}
}
if (!function_exists('sizeFormat')) {
function sizeFormat($bytes){
$kb = 1024;
$mb = $kb * 1024;
$gb = $mb * 1024;
$tb = $gb * 1024;
if (($bytes >= 0) && ($bytes < $kb)) {
return $bytes . ' B';
} elseif (($bytes >= $kb) && ($bytes < $mb)) {
return ceil($bytes / $kb) . ' KB';
} elseif (($bytes >= $mb) && ($bytes < $gb)) {
return ceil($bytes / $mb) . ' MB';
} elseif (($bytes >= $gb) && ($bytes < $tb)) {
return ceil($bytes / $gb) . ' GB';
} elseif ($bytes >= $tb) {
return ceil($bytes / $tb) . ' TB';
} else {
return $bytes . ' B';
}
}
}

Wyświetl plik

@ -17,6 +17,7 @@ $lang['menu_post_contest_logging'] = 'Post Contest Logging';
$lang['menu_bandmap'] = 'Bandmap';
$lang['menu_view_qsl'] = 'View QSL Cards';
$lang['menu_view_eqsl'] = 'View eQSL Cards';
$lang['menu_view_sstv'] = 'View SSTV Images';
$lang['menu_notes'] = 'Notes';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -17,6 +17,7 @@ $lang['menu_post_contest_logging'] = 'Post Contest Logging';
$lang['menu_bandmap'] = 'Bandmap';
$lang['menu_view_qsl'] = 'View QSL Cards';
$lang['menu_view_eqsl'] = 'View eQSL Cards';
$lang['menu_view_sstv'] = 'View SSTV Images';
$lang['menu_notes'] = 'Notes';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -17,6 +17,7 @@ $lang['menu_post_contest_logging'] = 'Post Contest Logging';
$lang['menu_bandmap'] = 'Bandmap';
$lang['menu_view_qsl'] = 'View QSL Cards';
$lang['menu_view_eqsl'] = 'View eQSL Cards';
$lang['menu_view_sstv'] = 'View SSTV Images';
$lang['menu_notes'] = 'Notes';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -17,6 +17,7 @@ $lang['menu_post_contest_logging'] = 'Post Contest Logging';
$lang['menu_bandmap'] = 'Bandmap';
$lang['menu_view_qsl'] = 'View QSL Cards';
$lang['menu_view_eqsl'] = 'View eQSL Cards';
$lang['menu_view_sstv'] = 'View SSTV Images';
$lang['menu_notes'] = 'Notes';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -17,6 +17,7 @@ $lang['menu_post_contest_logging'] = 'Post Contest Logging';
$lang['menu_bandmap'] = 'Bandmap';
$lang['menu_view_qsl'] = 'View QSL Cards';
$lang['menu_view_eqsl'] = 'View eQSL Cards';
$lang['menu_view_sstv'] = 'View SSTV Images';
$lang['menu_notes'] = 'Notes';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -17,6 +17,7 @@ $lang['menu_post_contest_logging'] = 'Post Contest Logging';
$lang['menu_bandmap'] = 'Bandmap';
$lang['menu_view_qsl'] = 'View QSL Cards';
$lang['menu_view_eqsl'] = 'View eQSL Cards';
$lang['menu_view_sstv'] = 'View SSTV Images';
$lang['menu_notes'] = 'Notes';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -17,6 +17,7 @@ $lang['menu_post_contest_logging'] = 'Post Contest Logging';
$lang['menu_bandmap'] = 'Bandmap';
$lang['menu_view_qsl'] = 'View QSL Cards';
$lang['menu_view_eqsl'] = 'View eQSL Cards';
$lang['menu_view_sstv'] = 'View SSTV Images';
$lang['menu_notes'] = 'Notes';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -17,6 +17,7 @@ $lang['menu_post_contest_logging'] = 'Post Contest Logging';
$lang['menu_bandmap'] = 'Bandmap';
$lang['menu_view_qsl'] = 'View QSL Cards';
$lang['menu_view_eqsl'] = 'View eQSL Cards';
$lang['menu_view_sstv'] = 'View SSTV Images';
$lang['menu_notes'] = 'Notes';

Wyświetl plik

@ -0,0 +1,5 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$lang['sstv_string_disk_space'] = 'of disk space to store SSTV image assets';

Wyświetl plik

@ -88,4 +88,23 @@ class Sstv_model extends CI_Model
return $this->db->get()->result();
}
function getQsoWithSstvImageList()
{
$CI = &get_instance();
$CI->load->model('logbooks_model');
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (is_array($logbooks_locations_array) && !empty($logbooks_locations_array)) {
$this->db->select('*');
$this->db->from($this->config->item('table_name'));
$this->db->join('sstv_images', 'sstv_images.qsoid = ' . $this->config->item('table_name') . '.col_primary_key');
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->order_by("id", "desc");
return $this->db->get();
} else {
return false;
}
}
}

Wyświetl plik

@ -83,6 +83,8 @@
<a class="dropdown-item" href="<?php echo site_url('qsl'); ?>" title="QSL"><i class="fa fa-id-card"></i> <?php echo lang('menu_view_qsl'); ?></a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('eqsl'); ?>" title="eQSL"><i class="fa fa-id-card"></i> <?php echo lang('menu_view_eqsl'); ?></a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="<?php echo site_url('sstv'); ?>" title="SSTV"><i class="fa fa-image"></i> <?php echo lang('menu_view_sstv'); ?></a>
</div>
</li>

Wyświetl plik

@ -0,0 +1,71 @@
<div class="container">
<br>
<h2>
<?php echo lang('general_word_sstvimages'); ?>
</h2>
<div class="alert alert-info" role="alert">
<?php echo lang('qslcard_string_your_are_using'); ?>
<?php echo $storage_used; ?>
<?php echo lang('sstv_string_disk_space'); ?>
</div>
<?php
if ($this->session->userdata('user_date_format')) {
// If Logged in and session exists
$custom_date_format = $this->session->userdata('user_date_format');
} else {
// Get Default date format from /config/cloudlog.php
$custom_date_format = $this->config->item('qso_date_format');
}
if ($sstvArray !== FALSE && is_array($sstvArray->result())) {
echo '<table style="width:100%" class="sstvtable table table-sm table-bordered table-hover table-striped table-condensed">
<thead>
<tr>
<th style=\'text-align: center\'>' . lang('gen_hamradio_callsign') . '</th>
<th style=\'text-align: center\'>' . lang('gen_hamradio_mode') . '</th>
<th style=\'text-align: center\'>' . lang('general_word_date') . '</th>
<th style=\'text-align: center\'>' . lang('general_word_time') . '</th>
<th style=\'text-align: center\'>' . lang('gen_hamradio_band') . '</th>
<th style=\'text-align: center\'></th>
<th style=\'text-align: center\'></th>
<th style=\'text-align: center\'></th>
</tr>
</thead><tbody>';
foreach ($sstvArray->result() as $sstvImage) {
echo '<tr>';
echo '<td style=\'text-align: center\'>' . str_replace("0", "&Oslash;", $sstvImage->COL_CALL) . '</td>';
echo '<td style=\'text-align: center\'>';
echo $sstvImage->COL_SUBMODE == null ? $sstvImage->COL_MODE : $sstvImage->COL_SUBMODE;
echo '</td>';
echo '<td style=\'text-align: center\'>';
$timestamp = strtotime($sstvImage->COL_TIME_ON);
echo date($custom_date_format, $timestamp);
echo '</td>';
echo '<td style=\'text-align: center\'>';
$timestamp = strtotime($sstvImage->COL_TIME_ON);
echo date('H:i', $timestamp);
echo '</td>';
echo '<td style=\'text-align: center\'>';
if ($sstvImage->COL_SAT_NAME != null) {
echo $sstvImage->COL_SAT_NAME;
} else {
echo strtolower($sstvImage->COL_BAND);
}
;
echo '</td>';
echo '<td style=\'text-align: center\'>' . $sstvImage->filename . '</td>';
echo '<td id="' . $sstvImage->id . '" style=\'text-align: center\'><button onclick="deleteSstv(\'' . $sstvImage->id . '\')" class="btn btn-sm btn-danger">Delete</button></td>';
echo '<td style=\'text-align: center\'><button onclick="viewSstv(\'' . $sstvImage->filename . '\', \'' . $sstvImage->COL_CALL . '\')" class="btn btn-sm btn-success">View</button></td>';
echo '</tr>';
}
echo '</tbody></table>';
} else {
echo '<div class="alert alert-warning" role="alert">No SSTV images Found.</div>';
}
?>
</div>