From 9691a8bc3a476bbe96c85b510c81977b18383931 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Thu, 16 May 2024 13:58:58 +0100 Subject: [PATCH] [Dashboard] Reload the Logbook Table every 5 seconds This reloads the logbook table on the dashboard every 5 seconds as mentioned in #3105 --- application/controllers/Dashboard.php | 18 ++ .../components/dashboard_logbook_table.php | 211 ++++++++++++++++++ application/views/dashboard/index.php | 63 +----- 3 files changed, 230 insertions(+), 62 deletions(-) create mode 100644 application/views/components/dashboard_logbook_table.php diff --git a/application/controllers/Dashboard.php b/application/controllers/Dashboard.php index ef1f4015..b9182213 100644 --- a/application/controllers/Dashboard.php +++ b/application/controllers/Dashboard.php @@ -188,6 +188,24 @@ class Dashboard extends CI_Controller } } + public function logbook_display_component() { + $this->load->model('user_model'); + + if ($this->user_model->validate_session() == 0) { + // User is not logged in + } else { + $this->load->model('logbook_model'); + $this->load->model('logbooks_model'); + } + + // Get Logbook Locations + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + // Get the last 20 QSOs + $data['last_five_qsos'] = $this->logbook_model->get_last_qsos('20', $logbooks_locations_array); + $this->load->view('components/dashboard_logbook_table', $data); + } + function radio_display_component() { $this->load->model('cat'); diff --git a/application/views/components/dashboard_logbook_table.php b/application/views/components/dashboard_logbook_table.php new file mode 100644 index 00000000..e3dd96ed --- /dev/null +++ b/application/views/components/dashboard_logbook_table.php @@ -0,0 +1,211 @@ +' . $ctx->lang->line('gen_hamradio_mode') . ''; + break; + case 'RSTS': + echo '' . $ctx->lang->line('gen_hamradio_rsts') . ''; + break; + case 'RSTR': + echo '' . $ctx->lang->line('gen_hamradio_rstr') . ''; + break; + case 'Country': + echo '' . $ctx->lang->line('general_word_country') . ''; + break; + case 'IOTA': + echo '' . $ctx->lang->line('gen_hamradio_iota') . ''; + break; + case 'SOTA': + echo '' . $ctx->lang->line('gen_hamradio_sota') . ''; + break; + case 'WWFF': + echo '' . $ctx->lang->line('gen_hamradio_wwff') . ''; + break; + case 'POTA': + echo '' . $ctx->lang->line('gen_hamradio_pota') . ''; + break; + case 'State': + echo '' . $ctx->lang->line('gen_hamradio_state') . ''; + break; + case 'Grid': + echo '' . $ctx->lang->line('gen_hamradio_gridsquare') . ''; + break; + case 'Distance': + echo '' . $ctx->lang->line('gen_hamradio_distance') . ''; + break; + case 'Band': + echo '' . $ctx->lang->line('gen_hamradio_band') . ''; + break; + case 'Frequency': + echo '' . $ctx->lang->line('gen_hamradio_frequency') . ''; + break; + case 'Operator': + echo '' . $ctx->lang->line('gen_hamradio_operator') . ''; + break; + case 'Name': + echo '' . $ctx->lang->line('general_word_name') . ''; + break; + } +} + +function echo_table_col($row, $name) +{ + $ci = &get_instance(); + switch ($name) { + case 'Mode': + echo ''; + echo $row->COL_SUBMODE == null ? $row->COL_MODE : $row->COL_SUBMODE . ''; + break; + case 'RSTS': + echo '' . $row->COL_RST_SENT; + if ($row->COL_STX) { + echo ' COL_CONTEST_ID : "n/a") . '" class="badge text-bg-light">'; + printf("%03d", $row->COL_STX); + echo ''; + } + if ($row->COL_STX_STRING) { + echo ' COL_CONTEST_ID : "n/a") . '" class="badge text-bg-light">' . $row->COL_STX_STRING . ''; + } + echo ''; + break; + case 'RSTR': + echo '' . $row->COL_RST_RCVD; + if ($row->COL_SRX) { + echo ' COL_CONTEST_ID : "n/a") . '" class="badge text-bg-light">'; + printf("%03d", $row->COL_SRX); + echo ''; + } + if ($row->COL_SRX_STRING) { + echo ' COL_CONTEST_ID : "n/a") . '" class="badge text-bg-light">' . $row->COL_SRX_STRING . ''; + } + echo ''; + break; + case 'Country': + echo '' . ucwords(strtolower(($row->COL_COUNTRY))); + if ($row->end != NULL) echo ' ' . $ci->lang->line('gen_hamradio_deleted_dxcc') . '' . ''; + break; + case 'IOTA': + echo '' . ($row->COL_IOTA) . ''; + break; + case 'SOTA': + echo '' . ($row->COL_SOTA_REF) . ''; + break; + case 'WWFF': + echo '' . ($row->COL_WWFF_REF) . ''; + break; + case 'POTA': + echo '' . ($row->COL_POTA_REF) . ''; + break; + case 'Grid': + echo ''; + echoQrbCalcLink($row->station_gridsquare, $row->COL_VUCC_GRIDS, $row->COL_GRIDSQUARE); + echo ''; + break; + case 'Distance': + echo '' . ($row->COL_DISTANCE ? $row->COL_DISTANCE . ' km' : '') . ''; + break; + case 'Band': + echo ''; + if ($row->COL_SAT_NAME != null) { + echo '' . $row->COL_SAT_NAME . ''; + } else { + echo strtolower($row->COL_BAND); + } + echo ''; + break; + case 'Frequency': + echo ''; + if ($row->COL_SAT_NAME != null) { + echo '' . $row->COL_SAT_NAME . ''; + } else { + if ($row->COL_FREQ != null) { + echo $ci->frequency->hz_to_mhz($row->COL_FREQ); + } else { + echo strtolower($row->COL_BAND); + } + } + echo ''; + break; + case 'State': + echo '' . ($row->COL_STATE) . ''; + break; + case 'Operator': + echo '' . ($row->COL_OPERATOR) . ''; + break; + case 'Name': + echo '' . ($row->COL_NAME) . ''; + break; + } +} + +function echoQrbCalcLink($mygrid, $grid, $vucc) +{ + if (!empty($grid)) { + echo $grid . ' '; + } else if (!empty($vucc)) { + echo $vucc . ' '; + } +} +?> +
+ + + + + + + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> + + + + session->userdata('user_column1') == "" ? 'Mode' : $this->session->userdata('user_column1')); + echo_table_header_col($this, $this->session->userdata('user_column2') == "" ? 'RSTS' : $this->session->userdata('user_column2')); + echo_table_header_col($this, $this->session->userdata('user_column3') == "" ? 'RSTR' : $this->session->userdata('user_column3')); + echo_table_header_col($this, $this->session->userdata('user_column4') == "" ? 'Band' : $this->session->userdata('user_column4')); + ?> + + + + 0) { + foreach ($last_five_qsos->result() as $row) { ?> + COL_PRIMARY_KEY . '" class="tr' . ($i & 1) . '">'; ?> + + 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'); + } + + ?> + + + config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> + + + + + session->userdata('user_column1') == "" ? 'Mode' : $this->session->userdata('user_column1')); + echo_table_col($row, $this->session->userdata('user_column2') == "" ? 'RSTS' : $this->session->userdata('user_column2')); + echo_table_col($row, $this->session->userdata('user_column3') == "" ? 'RSTR' : $this->session->userdata('user_column3')); + echo_table_col($row, $this->session->userdata('user_column4') == "" ? 'Band' : $this->session->userdata('user_column4')); + ?> + + +
COL_TIME_ON); + echo date($custom_date_format, $timestamp); ?>COL_TIME_ON); + echo date('H:i', $timestamp); ?> + COL_CALL)); ?> +
\ No newline at end of file diff --git a/application/views/dashboard/index.php b/application/views/dashboard/index.php index 99b49f88..56e885ab 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -222,68 +222,7 @@ function echoQrbCalcLink($mygrid, $grid, $vucc)
- -
- - - - - - - config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> - - - - session->userdata('user_column1') == "" ? 'Mode' : $this->session->userdata('user_column1')); - echo_table_header_col($this, $this->session->userdata('user_column2') == "" ? 'RSTS' : $this->session->userdata('user_column2')); - echo_table_header_col($this, $this->session->userdata('user_column3') == "" ? 'RSTR' : $this->session->userdata('user_column3')); - echo_table_header_col($this, $this->session->userdata('user_column4') == "" ? 'Band' : $this->session->userdata('user_column4')); - ?> - - - - 0) { - foreach ($last_five_qsos->result() as $row) { ?> - COL_PRIMARY_KEY . '" class="tr' . ($i & 1) . '">'; ?> - - 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'); - } - - ?> - - - config->item('use_auth') && ($this->session->userdata('user_type') >= 2)) || $this->config->item('use_auth') === FALSE || ($this->config->item('show_time'))) { ?> - - - - - session->userdata('user_column1') == "" ? 'Mode' : $this->session->userdata('user_column1')); - echo_table_col($row, $this->session->userdata('user_column2') == "" ? 'RSTS' : $this->session->userdata('user_column2')); - echo_table_col($row, $this->session->userdata('user_column3') == "" ? 'RSTR' : $this->session->userdata('user_column3')); - echo_table_col($row, $this->session->userdata('user_column4') == "" ? 'Band' : $this->session->userdata('user_column4')); - ?> - - -
COL_TIME_ON); - echo date($custom_date_format, $timestamp); ?>COL_TIME_ON); - echo date('H:i', $timestamp); ?> - COL_CALL)); ?> -
-
+