From 2891cf09c8d8f8760ed2fdc906124e0eec13267f Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 18 Aug 2023 12:48:31 +0000 Subject: [PATCH 01/17] save QRG/Mode/Band as Favourite --- assets/js/sections/qso.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index a558465b..4e04d580 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -1,5 +1,30 @@ $( document ).ready(function() { + $('#start_time').click(function (event) { + save_fav(); + }); + + function save_fav() { + var payload={}; + payload.sat_name=$('#sat_name').val(); + payload.sat_mode=$('#sat_name').val(); + payload.band_rx=$('#band_rx').val(); + payload.band=$('#band').val(); + payload.frequency_tx=$('#frequency_rx').val(); + payload.frequency=$('#frequency').val(); + payload.prop_mode=$('#prop_mode').val(); + payload.mode=$('#mode').val(); + $.ajax({ + url: base_url+'index.php/user_options/set_options', + method: 'POST', + dataType: 'json', + contentType: "application/json; charset=utf-8", + data: JSON.stringify(payload), + success: function(result) { + } + }); + } + var bc_bandmap = new BroadcastChannel('qso_window'); bc_bandmap.onmessage = function (ev) { From 5dc5adb4bbd0537e1c0d276f74b6708cda2849cd Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 18 Aug 2023 12:49:12 +0000 Subject: [PATCH 02/17] Model for User-options --- application/models/User_options.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 application/models/User_options.php diff --git a/application/models/User_options.php b/application/models/User_options.php new file mode 100644 index 00000000..ea375bc3 --- /dev/null +++ b/application/models/User_options.php @@ -0,0 +1,22 @@ +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_array) { + $uid=$this->session->userdata('user_id'); + $sql='insert into user_options (user_id,option_type,option_key,option_value) values (?,?,?,?) ON DUPLICATE KEY UPDATE option_value=?'; + $query = $this->db->query($sql); + foreach ($option_array() as $one_option) { + $query = $this->db->query($sql, array($uid, $option_type, $option_key, $option_value, $option_value)); + } + } + +} + +?> From 1bf2840e27b6b9761692e4eef859708e3815bf6b Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 18 Aug 2023 13:16:01 +0000 Subject: [PATCH 03/17] Saving works now --- application/controllers/User_options.php | 19 +++++++++++++++++++ ...ser_options.php => User_options_model.php} | 5 ++--- assets/js/sections/qso.js | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100755 application/controllers/User_options.php rename application/models/{User_options.php => User_options_model.php} (82%) diff --git a/application/controllers/User_options.php b/application/controllers/User_options.php new file mode 100755 index 00000000..c021dfb0 --- /dev/null +++ b/application/controllers/User_options.php @@ -0,0 +1,19 @@ +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); + $this->user_options_model->set_option('Favourite',$obj); + } +} + + +?> diff --git a/application/models/User_options.php b/application/models/User_options_model.php similarity index 82% rename from application/models/User_options.php rename to application/models/User_options_model.php index ea375bc3..68e07816 100644 --- a/application/models/User_options.php +++ b/application/models/User_options_model.php @@ -1,6 +1,6 @@ db->where('user_id', $this->session->userdata('user_id')); @@ -11,8 +11,7 @@ class User_options extends CI_Model public function set_option($option_type, $option_array) { $uid=$this->session->userdata('user_id'); $sql='insert into user_options (user_id,option_type,option_key,option_value) values (?,?,?,?) ON DUPLICATE KEY UPDATE option_value=?'; - $query = $this->db->query($sql); - foreach ($option_array() as $one_option) { + foreach($option_array as $option_key => $option_value) { $query = $this->db->query($sql, array($uid, $option_type, $option_key, $option_value, $option_value)); } } diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 4e04d580..02acf4fc 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -15,7 +15,7 @@ $( document ).ready(function() { payload.prop_mode=$('#prop_mode').val(); payload.mode=$('#mode').val(); $.ajax({ - url: base_url+'index.php/user_options/set_options', + url: base_url+'index.php/user_options/add_edit_fav', method: 'POST', dataType: 'json', contentType: "application/json; charset=utf-8", From 59f81279e32ebbe33bd14edb30a1d27d23209188 Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 18 Aug 2023 13:30:04 +0000 Subject: [PATCH 04/17] Added option_name to table --- application/controllers/User_options.php | 7 ++++++- application/models/User_options_model.php | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/application/controllers/User_options.php b/application/controllers/User_options.php index c021dfb0..c5360590 100755 --- a/application/controllers/User_options.php +++ b/application/controllers/User_options.php @@ -11,7 +11,12 @@ class User_Options extends CI_Controller { public function add_edit_fav() { $obj = json_decode(file_get_contents("php://input"), true); - $this->user_options_model->set_option('Favourite',$obj); + if ($obj['sat_name'] ?? '' != '') { + $option_name=$obj['sat_name']; + } else { + $option_name=$obj['band'].'/'.$obj['mode']; + } + $this->user_options_model->set_option('Favourite',$option_name, $obj); } } diff --git a/application/models/User_options_model.php b/application/models/User_options_model.php index 68e07816..1304abd0 100644 --- a/application/models/User_options_model.php +++ b/application/models/User_options_model.php @@ -8,11 +8,11 @@ class User_options_model extends CI_Model return $this->db->get('user_options'); } - public function set_option($option_type, $option_array) { + 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_key,option_value) values (?,?,?,?) ON DUPLICATE KEY UPDATE option_value=?'; + $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_key, $option_value, $option_value)); + $query = $this->db->query($sql, array($uid, $option_type, $option_name, $option_key, $option_value, $option_value)); } } From e86b0a2f8673f1ba8142e56f6b977a95523bbddd Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 18 Aug 2023 14:42:04 +0000 Subject: [PATCH 05/17] get_fav implemented --- application/controllers/User_options.php | 11 ++++++++++- application/models/User_options_model.php | 14 ++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/application/controllers/User_options.php b/application/controllers/User_options.php index c5360590..1967349e 100755 --- a/application/controllers/User_options.php +++ b/application/controllers/User_options.php @@ -16,7 +16,16 @@ class User_Options extends CI_Controller { } else { $option_name=$obj['band'].'/'.$obj['mode']; } - $this->user_options_model->set_option('Favourite',$option_name, $obj); + return $this->user_options_model->set_option('Favourite',$option_name, $obj); + } + + public function get_favs() { + $result=$this->user_options_model->get_options('Favourite'); + foreach($result->result() as $options) { + $jsonout[$options->option_name][$options->option_key]=$options->option_value; + } + header('Content-Type: application/json'); + echo json_encode($jsonout); } } diff --git a/application/models/User_options_model.php b/application/models/User_options_model.php index 1304abd0..e37b8151 100644 --- a/application/models/User_options_model.php +++ b/application/models/User_options_model.php @@ -1,7 +1,7 @@ db->where('user_id', $this->session->userdata('user_id')); $this->db->where('option_type', $option_type); @@ -12,8 +12,14 @@ class User_options_model extends CI_Model $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)); - } + $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)); } } From baa3724da9051a499d89d6d74821aaf326ef4155 Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 18 Aug 2023 14:58:27 +0000 Subject: [PATCH 06/17] impemented del_fav --- application/controllers/User_options.php | 15 ++++++++++++++- application/models/User_options_model.php | 6 ++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/application/controllers/User_options.php b/application/controllers/User_options.php index 1967349e..864bc090 100755 --- a/application/controllers/User_options.php +++ b/application/controllers/User_options.php @@ -11,6 +11,9 @@ class User_Options extends CI_Controller { 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']; } else { @@ -19,7 +22,7 @@ class User_Options extends CI_Controller { return $this->user_options_model->set_option('Favourite',$option_name, $obj); } - public function get_favs() { + public function get_fav() { $result=$this->user_options_model->get_options('Favourite'); foreach($result->result() as $options) { $jsonout[$options->option_name][$options->option_key]=$options->option_value; @@ -27,6 +30,16 @@ class User_Options extends CI_Controller { 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); + } + return; + } } diff --git a/application/models/User_options_model.php b/application/models/User_options_model.php index e37b8151..9a383338 100644 --- a/application/models/User_options_model.php +++ b/application/models/User_options_model.php @@ -22,6 +22,12 @@ class User_options_model extends CI_Model { 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)); + } + } ?> From c29b1f3c802e5154baa092f8972957f1785ee267 Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 18 Aug 2023 15:00:40 +0000 Subject: [PATCH 07/17] example-calls for get/set/del Favs --- assets/js/sections/qso.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 02acf4fc..067d72a1 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -4,6 +4,34 @@ $( document ).ready(function() { save_fav(); }); + $('#start_date').click(function (event) { + get_fav(); + }); + + function del_fav(name) { + $.ajax({ + url: base_url+'index.php/user_options/del_fav', + method: 'GET', + dataType: 'json', + contentType: "application/json; charset=utf-8", + data: { "option_name": name }, + success: function(result) { + } + }); + } + + 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) { + console.log(result); + } + }); + } + function save_fav() { var payload={}; payload.sat_name=$('#sat_name').val(); From 8fc412a1af511179433f93257cb912a082974b3d Mon Sep 17 00:00:00 2001 From: int2001 Date: Fri, 18 Aug 2023 16:54:50 +0000 Subject: [PATCH 08/17] Added Prototype UI and Migrationscript --- application/config/migration.php | 2 +- application/controllers/User_options.php | 2 +- application/language/english/qso_lang.php | 1 + application/language/german/qso_lang.php | 2 ++ application/views/qso/index.php | 12 ++++++++- assets/js/sections/qso.js | 31 ++++++++++++++++++----- 6 files changed, 40 insertions(+), 10 deletions(-) diff --git a/application/config/migration.php b/application/config/migration.php index 70bc112e..51eebc64 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | */ -$config['migration_version'] = 137; +$config['migration_version'] = 138; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/User_options.php b/application/controllers/User_options.php index 864bc090..77fc477c 100755 --- a/application/controllers/User_options.php +++ b/application/controllers/User_options.php @@ -15,7 +15,7 @@ class User_Options extends CI_Controller { $obj[$option_key]=$this->security->xss_clean($option_value); } if ($obj['sat_name'] ?? '' != '') { - $option_name=$obj['sat_name']; + $option_name=$obj['sat_name'].'/'.$obj['mode']; } else { $option_name=$obj['band'].'/'.$obj['mode']; } diff --git a/application/language/english/qso_lang.php b/application/language/english/qso_lang.php index 3b27929f..c8acea22 100644 --- a/application/language/english/qso_lang.php +++ b/application/language/english/qso_lang.php @@ -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'; diff --git a/application/language/german/qso_lang.php b/application/language/german/qso_lang.php index 0f1b0949..d7dfd357 100644 --- a/application/language/german/qso_lang.php +++ b/application/language/german/qso_lang.php @@ -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'; diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 4a8ac031..3b5ae78c 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -34,7 +34,17 @@ - + + + +
diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 067d72a1..b914ee9a 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -1,13 +1,25 @@ $( document ).ready(function() { - $('#start_time').click(function (event) { +var favs={}; + get_fav(); + + $('#fav_add').click(function (event) { save_fav(); }); - $('#start_date').click(function (event) { - get_fav(); + $(document).on("click", "#fav_recall", function (event) { + console.log(favs[this.innerText]); + $('#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) { $.ajax({ url: base_url+'index.php/user_options/del_fav', @@ -27,7 +39,11 @@ $( document ).ready(function() { dataType: 'json', contentType: "application/json; charset=utf-8", success: function(result) { - console.log(result); + $("#fav_menu").empty(); + for (const key in result) { + $("#fav_menu").append(''+key+''); + } + favs=result; } }); } @@ -35,12 +51,12 @@ $( document ).ready(function() { function save_fav() { var payload={}; payload.sat_name=$('#sat_name').val(); - payload.sat_mode=$('#sat_name').val(); + payload.sat_mode=$('#sat_mode').val(); payload.band_rx=$('#band_rx').val(); payload.band=$('#band').val(); - payload.frequency_tx=$('#frequency_rx').val(); + payload.frequency_rx=$('#frequency_rx').val(); payload.frequency=$('#frequency').val(); - payload.prop_mode=$('#prop_mode').val(); + payload.prop_mode=$('#selectPropagation').val(); payload.mode=$('#mode').val(); $.ajax({ url: base_url+'index.php/user_options/add_edit_fav', @@ -49,6 +65,7 @@ $( document ).ready(function() { contentType: "application/json; charset=utf-8", data: JSON.stringify(payload), success: function(result) { + get_fav(); } }); } From a75257d70674eea4035f55699af9283a58f6a74c Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Fri, 18 Aug 2023 21:38:34 +0100 Subject: [PATCH 09/17] [LoTW] Remove unneeded margin at the bottom of the table --- assets/css/general.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/css/general.css b/assets/css/general.css index a4705e96..ac8ef98f 100644 --- a/assets/css/general.css +++ b/assets/css/general.css @@ -515,4 +515,8 @@ div#station_logbooks_linked_table_paginate { .previous-qsos table { margin-bottom: 0px; +} + +.lotw-cert-list table { + margin-bottom: 0px; } \ No newline at end of file From b56c39db6fa455e80aba6e4da5542429509d5d26 Mon Sep 17 00:00:00 2001 From: int2001 Date: Sat, 19 Aug 2023 04:11:41 +0000 Subject: [PATCH 10/17] Reload-favs after save --- application/controllers/User_options.php | 9 +++++++-- assets/js/sections/qso.js | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/application/controllers/User_options.php b/application/controllers/User_options.php index 77fc477c..46d1150d 100755 --- a/application/controllers/User_options.php +++ b/application/controllers/User_options.php @@ -19,7 +19,10 @@ class User_Options extends CI_Controller { } else { $option_name=$obj['band'].'/'.$obj['mode']; } - return $this->user_options_model->set_option('Favourite',$option_name, $obj); + $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() { @@ -38,7 +41,9 @@ class User_Options extends CI_Controller { $option_name=$this->security->xss_clean($obj['option_name']); $this->user_options_model->del_option('Favourite',$option_name); } - return; + $jsonout['success']=1; + header('Content-Type: application/json'); + echo json_encode($jsonout); } } diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index b914ee9a..dc2fa377 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -23,11 +23,12 @@ var favs={}; function del_fav(name) { $.ajax({ url: base_url+'index.php/user_options/del_fav', - method: 'GET', + method: 'POST', dataType: 'json', contentType: "application/json; charset=utf-8", data: { "option_name": name }, success: function(result) { + get_fav(); } }); } From aca01fabb5e5335b144e2bf47c21725a8da95e9e Mon Sep 17 00:00:00 2001 From: int2001 Date: Sat, 19 Aug 2023 04:50:18 +0000 Subject: [PATCH 11/17] Now delete is working, too --- assets/js/sections/qso.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index dc2fa377..24015e57 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -7,6 +7,10 @@ var favs={}; save_fav(); }); + $(document).on("click", "#fav_del", function (event) { + del_fav($(this).attr('name')); + }); + $(document).on("click", "#fav_recall", function (event) { console.log(favs[this.innerText]); $('#sat_name').val(favs[this.innerText].sat_name); @@ -26,7 +30,7 @@ var favs={}; method: 'POST', dataType: 'json', contentType: "application/json; charset=utf-8", - data: { "option_name": name }, + data: JSON.stringify({ "option_name": name }), success: function(result) { get_fav(); } @@ -42,7 +46,7 @@ var favs={}; success: function(result) { $("#fav_menu").empty(); for (const key in result) { - $("#fav_menu").append(''+key+''); + $("#fav_menu").append(''); } favs=result; } From 3a6d2d8a2a7c09c93d5e7d0593416dc8e73f8d86 Mon Sep 17 00:00:00 2001 From: int2001 Date: Sat, 19 Aug 2023 04:55:59 +0000 Subject: [PATCH 12/17] cosmetics: star-icon instead of "FAV" --- application/views/qso/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 3b5ae78c..05a55f52 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -36,7 +36,7 @@