Merge branch 'dev' into logbook_map

pull/2420/head
Andreas Kristiansen 2023-08-19 19:41:56 +02:00 zatwierdzone przez GitHub
commit 24dbe6f6f0
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
9 zmienionych plików z 202 dodań i 2 usunięć

Wyświetl plik

@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
*/
$config['migration_version'] = 137;
$config['migration_version'] = 138;
/*
|--------------------------------------------------------------------------

Wyświetl plik

@ -0,0 +1,52 @@
<?php
class User_Options extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->model('user_model');
$this->load->model('user_options_model');
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
}
public function add_edit_fav() {
$obj = json_decode(file_get_contents("php://input"), true);
foreach($obj as $option_key => $option_value) {
$obj[$option_key]=$this->security->xss_clean($option_value);
}
if ($obj['sat_name'] ?? '' != '') {
$option_name=$obj['sat_name'].'/'.$obj['mode'];
} else {
$option_name=$obj['band'].'/'.$obj['mode'];
}
$this->user_options_model->set_option('Favourite',$option_name, $obj);
$jsonout['success']=1;
header('Content-Type: application/json');
echo json_encode($jsonout);
}
public function get_fav() {
$result=$this->user_options_model->get_options('Favourite');
$jsonout=[];
foreach($result->result() as $options) {
$jsonout[$options->option_name][$options->option_key]=$options->option_value;
}
header('Content-Type: application/json');
echo json_encode($jsonout);
}
public function del_fav() {
$result=$this->user_options_model->get_options('Favourite');
$obj = json_decode(file_get_contents("php://input"), true);
if ($obj['option_name'] ?? '' != '') {
$option_name=$this->security->xss_clean($obj['option_name']);
$this->user_options_model->del_option('Favourite',$option_name);
}
$jsonout['success']=1;
header('Content-Type: application/json');
echo json_encode($jsonout);
}
}
?>

Wyświetl plik

@ -32,3 +32,4 @@ $lang['qso_btn_edit_qso'] = 'Edit QSO';
// QSO Details
$lang['qso_details'] = 'QSO Details';
$lang['fav_add'] = 'Add Band/Mode to Favs';

Wyświetl plik

@ -32,3 +32,5 @@ $lang['qso_btn_edit_qso'] = 'Editiere QSO';
// QSO Details
$lang['qso_details'] = 'QSO Details';
$lang['fav_add'] = 'Band/Mode zu Favoriten hinzufügen';

Wyświetl plik

@ -0,0 +1,19 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_user_options_table extends CI_Migration {
public function up() {
if (!$this->db->table_exists('user_options')) {
$this->db->query("CREATE TABLE `user_options` ( `user_id` int(11) NOT NULL, `option_type` varchar(45) NOT NULL, `option_name` varchar(45) NOT NULL, `option_key` varchar(45) NOT NULL, `option_value` varchar(45) DEFAULT NULL, PRIMARY KEY (`user_id`,`option_type`,`option_key`,`option_name`))");
}
}
public function down(){
if ($this->db->table_exists('user_options')) {
$this->dbforge->drop_table('user_options');
}
}
}

Wyświetl plik

@ -0,0 +1,33 @@
<?php
class User_options_model extends CI_Model {
public function options($option_type) {
$this->db->where('user_id', $this->session->userdata('user_id'));
$this->db->where('option_type', $option_type);
return $this->db->get('user_options');
}
public function set_option($option_type, $option_name, $option_array) {
$uid=$this->session->userdata('user_id');
$sql='insert into user_options (user_id,option_type,option_name,option_key,option_value) values (?,?,?,?,?) ON DUPLICATE KEY UPDATE option_value=?';
foreach($option_array as $option_key => $option_value) {
$query = $this->db->query($sql, array($uid, $option_type, $option_name, $option_key, $option_value, $option_value));
}
}
public function get_options($option_type) {
$uid=$this->session->userdata('user_id');
$sql='select option_name,option_key,option_value from user_options where user_id=? and option_type=?';
return $this->db->query($sql, array($uid, $option_type));
}
public function del_option($option_type, $option_name) {
$uid=$this->session->userdata('user_id');
$sql='delete from user_options where user_id=? and option_type=? and option_name=?';
return $this->db->query($sql, array($uid, $option_type,$option_name));
}
}
?>

Wyświetl plik

@ -34,7 +34,17 @@
<li class="nav-item">
<a class="nav-link" id="qsl-tab" data-toggle="tab" href="#qsl" role="tab" aria-controls="qsl" aria-selected="false"><?php echo lang('gen_hamradio_qsl'); ?></a>
</li>
</ul>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="fav_item" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-star"></i></a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#" id="fav_add"><?php echo lang('fav_add'); ?></a>
<div class="dropdown-divider"></div>
<div id="fav_menu"></div>
</div>
</li>
</ul>
</div>
<div class="card-body">

Wyświetl plik

@ -520,4 +520,11 @@ div#station_logbooks_linked_table_paginate {
#advancedmap {
height: calc(100vh - 280px) !important;
max-height: 1000px !important;
.lotw-cert-list table {
margin-bottom: 0px;
}
.qso_panel a i.fa.fa-star:hover {
color: #FFD700 !important;
}

Wyświetl plik

@ -1,5 +1,81 @@
$( document ).ready(function() {
var favs={};
get_fav();
$('#fav_add').click(function (event) {
save_fav();
});
$(document).on("click", "#fav_del", function (event) {
del_fav($(this).attr('name'));
});
$(document).on("click", "#fav_recall", function (event) {
$('#sat_name').val(favs[this.innerText].sat_name);
$('#sat_mode').val(favs[this.innerText].sat_mode);
$('#band_rx').val(favs[this.innerText].band_rx);
$('#band').val(favs[this.innerText].band);
$('#frequency_rx').val(favs[this.innerText].frequency_rx);
$('#frequency').val(favs[this.innerText].frequency);
$('#selectPropagation').val(favs[this.innerText].prop_mode);
$('#mode').val(favs[this.innerText].mode);
});
function del_fav(name) {
if (confirm("Are you sure to delete Fav?")) {
$.ajax({
url: base_url+'index.php/user_options/del_fav',
method: 'POST',
dataType: 'json',
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ "option_name": name }),
success: function(result) {
get_fav();
}
});
}
}
function get_fav() {
$.ajax({
url: base_url+'index.php/user_options/get_fav',
method: 'GET',
dataType: 'json',
contentType: "application/json; charset=utf-8",
success: function(result) {
$("#fav_menu").empty();
for (const key in result) {
$("#fav_menu").append('<label class="dropdown-item"><span id="fav_del" name="'+key+'"><i class="fas fa-trash-alt"></i></span>&nbsp;&nbsp;<span id="fav_recall">'+key+'</span></label>');
}
favs=result;
}
});
}
function save_fav() {
var payload={};
payload.sat_name=$('#sat_name').val();
payload.sat_mode=$('#sat_mode').val();
payload.band_rx=$('#band_rx').val();
payload.band=$('#band').val();
payload.frequency_rx=$('#frequency_rx').val();
payload.frequency=$('#frequency').val();
payload.prop_mode=$('#selectPropagation').val();
payload.mode=$('#mode').val();
$.ajax({
url: base_url+'index.php/user_options/add_edit_fav',
method: 'POST',
dataType: 'json',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(payload),
success: function(result) {
get_fav();
}
});
}
var bc_bandmap = new BroadcastChannel('qso_window');
bc_bandmap.onmessage = function (ev) {