From 9b4ced18891a7c219d5a1f703543cfb8b08e805d Mon Sep 17 00:00:00 2001 From: int2001 Date: Mon, 5 Feb 2024 09:37:52 +0000 Subject: [PATCH 01/19] Trying to convert the QSO-Post to an ajax call PHP/Part --- application/controllers/Qso.php | 28 ++++++++++++---------------- application/views/qso/index.php | 2 +- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 0463722be..56d914db8 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -18,18 +18,17 @@ class QSO extends CI_Controller { if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } } - public function index() - { + public function index() { $this->load->model('cat'); $this->load->model('stations'); $this->load->model('logbook_model'); $this->load->model('user_model'); $this->load->model('modes'); - $this->load->model('bands'); - if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + $this->load->model('bands'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } $data['active_station_profile'] = $this->stations->find_active(); - + $data['notice'] = false; $data['stations'] = $this->stations->all_of_user(); $data['radios'] = $this->cat->radios(); @@ -50,21 +49,18 @@ class QSO extends CI_Controller { $this->form_validation->set_rules('mode', 'Mode', 'required'); $this->form_validation->set_rules('locator', 'Locator', 'callback_check_locator'); - // [eQSL default msg] GET user options (option_type='eqsl_default_qslmsg'; option_name='key_station_id'; option_key=station_id) // + // [eQSL default msg] GET user options (option_type='eqsl_default_qslmsg'; option_name='key_station_id'; option_key=station_id) // $this->load->model('user_options_model'); $options_object = $this->user_options_model->get_options('eqsl_default_qslmsg',array('option_name'=>'key_station_id','option_key'=>$data['active_station_profile']))->result(); $data['qslmsg'] = (isset($options_object[0]->option_value))?$options_object[0]->option_value:''; - if ($this->form_validation->run() == FALSE) - { + if ($this->form_validation->run() == FALSE) { $data['page_title'] = "Add QSO"; $this->load->view('interface_assets/header', $data); $this->load->view('qso/index'); $this->load->view('interface_assets/footer'); - } - else - { + } else { // Store Basic QSO Info for reuse // Put data in an array first, then call set_userdata once. // This solves the problem of CI dumping out the session @@ -73,9 +69,9 @@ class QSO extends CI_Controller { // $qso_data = [ // 18-Jan-2016 - make php v5.3 friendly! $qso_data = array( - 'start_date' => $this->input->post('start_date'), - 'start_time' => $this->input->post('start_time'), - 'end_time' => $this->input->post('end_time'), + 'start_date' => $this->input->post('start_date'), + 'start_time' => $this->input->post('start_time'), + 'end_time' => $this->input->post('end_time'), 'time_stamp' => time(), 'band' => $this->input->post('band'), 'band_rx' => $this->input->post('band_rx'), @@ -99,8 +95,8 @@ class QSO extends CI_Controller { // If SAT name is set make it session set to sat if($this->input->post('sat_name')) { - $this->session->set_userdata('prop_mode', 'SAT'); - } + $this->session->set_userdata('prop_mode', 'SAT'); + } // Add QSO // $this->logbook_model->add(); diff --git a/application/views/qso/index.php b/application/views/qso/index.php index bd060c8fc..71e6ba3e8 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -558,7 +558,7 @@ - + From 19b20dee7f5ba389659a43f9760aa0afa3445674 Mon Sep 17 00:00:00 2001 From: int2001 Date: Mon, 5 Feb 2024 09:38:12 +0000 Subject: [PATCH 02/19] JS Part --- assets/js/sections/qso.js | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 69c010e43..c856f089f 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -7,6 +7,31 @@ $( document ).ready(function() { localStorage.removeItem("quicklogCallsign"); } }, 100); + $("#qso_input").off('submit').on('submit', function(e){ + var _submit = true; + if ((typeof qso_manual !== "undefined")&&(qso_manual == "1")) { + if ($('#qso_input input[name="end_time"]').length == 1) { _submit = testTimeOffConsistency(); } + } + if ( _submit) { + /* Trying to cnvert form to json + const data = new FormData(event.target); + const values = Object.fromEntries(data.entries()); + */ + e.preventDefault(); + $.ajax({ + url: base_url+'index.php/qso', + method: 'POST', + type: 'post', + contentType: "application/json; charset=utf-8", + data: $(this).serialize(), + // data: JSON.stringify(values), + success: function(result) { + alert("X"); + } + }); + } + return false; + }); $('#reset_time').click(function() { var now = new Date(); var localTime = now.getTime(); @@ -347,15 +372,7 @@ var favs={}; $('.satellite_names_list').append(items.join( "" )); }); - // Test Consistency value on submit form // - $("#qso_input").off('submit').on('submit', function(){ - var _submit = true; - if ((typeof qso_manual !== "undefined")&&(qso_manual == "1")) { - if ($('#qso_input input[name="end_time"]').length == 1) { _submit = testTimeOffConsistency(); } - } - return _submit; - }) -}); + }); var selected_sat; var selected_sat_mode; From 69e940af2bd65a935610f955121ccb145c29cf08 Mon Sep 17 00:00:00 2001 From: int2001 Date: Mon, 5 Feb 2024 09:46:17 +0000 Subject: [PATCH 03/19] First POC --- assets/js/sections/qso.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index c856f089f..3cc5888f5 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -13,18 +13,13 @@ $( document ).ready(function() { if ($('#qso_input input[name="end_time"]').length == 1) { _submit = testTimeOffConsistency(); } } if ( _submit) { - /* Trying to cnvert form to json - const data = new FormData(event.target); - const values = Object.fromEntries(data.entries()); - */ + manual_addon='?manual='+qso_manual; e.preventDefault(); $.ajax({ - url: base_url+'index.php/qso', + url: base_url+'index.php/qso'+manual_addon, method: 'POST', type: 'post', - contentType: "application/json; charset=utf-8", data: $(this).serialize(), - // data: JSON.stringify(values), success: function(result) { alert("X"); } From 5b447944a1d1abe56cf58229e80543238faf3b14 Mon Sep 17 00:00:00 2001 From: int2001 Date: Mon, 5 Feb 2024 10:00:48 +0000 Subject: [PATCH 04/19] Handling of AJAX result (started) --- assets/js/sections/qso.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 3cc5888f5..eb8297d0e 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -21,7 +21,9 @@ $( document ).ready(function() { type: 'post', data: $(this).serialize(), success: function(result) { - alert("X"); + if (result.message == 'success') { + // todo + } } }); } From a232b09e0f2156c3e1bb60827abecf6190fd0f4b Mon Sep 17 00:00:00 2001 From: int2001 Date: Mon, 5 Feb 2024 10:01:12 +0000 Subject: [PATCH 05/19] Change qso-save to ajax-return --- application/controllers/Qso.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 56d914db8..bdee0dc34 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -56,10 +56,7 @@ class QSO extends CI_Controller { if ($this->form_validation->run() == FALSE) { $data['page_title'] = "Add QSO"; - - $this->load->view('interface_assets/header', $data); - $this->load->view('qso/index'); - $this->load->view('interface_assets/footer'); + echo json_encode(array('message' => 'Error','errors' => validation_errors())); } else { // Store Basic QSO Info for reuse // Put data in an array first, then call set_userdata once. @@ -104,17 +101,7 @@ class QSO extends CI_Controller { $this->logbook_model->create_qso(); // Get last 5 qsos - $data['query'] = $this->logbook_model->last_custom('5'); - - // Set Any Notice Messages - $data['notice'] = "QSO Added"; - - // Load view to create another contact - $data['page_title'] = "Add QSO"; - - $this->load->view('interface_assets/header', $data); - $this->load->view('qso/index'); - $this->load->view('interface_assets/footer'); + echo json_encode(array('message' => 'success')); } } From 10a36920c8f5e02086e919e9222c0a508ce95e08 Mon Sep 17 00:00:00 2001 From: int2001 Date: Mon, 5 Feb 2024 10:34:00 +0000 Subject: [PATCH 06/19] Added notification and reloading of QSO-Table --- application/controllers/Qso.php | 9 ++++++++- application/views/qso/index.php | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index bdee0dc34..60068177f 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -56,7 +56,14 @@ class QSO extends CI_Controller { if ($this->form_validation->run() == FALSE) { $data['page_title'] = "Add QSO"; - echo json_encode(array('message' => 'Error','errors' => validation_errors())); + + if (validation_errors() != '') { // we're coming from a failed ajax-call + echo json_encode(array('message' => 'Error','errors' => validation_errors())); + } else { // we're not coming from a POST + $this->load->view('interface_assets/header', $data); + $this->load->view('qso/index'); + $this->load->view('interface_assets/footer'); + } } else { // Store Basic QSO Info for reuse // Put data in an array first, then call set_userdata once. diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 71e6ba3e8..251be9f18 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -568,6 +568,7 @@
+ From 53f3fecc164b42ff35b1be05eaff480c42a7fbc5 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Tue, 6 Feb 2024 12:50:18 +0100 Subject: [PATCH 19/19] [Logbook] Removed profiler --- application/controllers/Logbook.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 82a1e44cf..38c210ff6 100644 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -28,11 +28,6 @@ class Logbook extends CI_Controller { } $this->load->model('stations'); - // If environment is set to development then show the debug toolbar - if(ENVIRONMENT == 'development') { - $this->output->enable_profiler(TRUE); - } - $this->load->model('logbook_model'); $this->load->library('pagination');