From d319aaa726a95e20773f71e17385eba2f42c74ab Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Fri, 18 Apr 2025 15:41:20 +0200 Subject: [PATCH] prepare controller for sat pass presets --- application/controllers/Satellite.php | 87 +++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/application/controllers/Satellite.php b/application/controllers/Satellite.php index 9c795660e..eaac5c4d1 100644 --- a/application/controllers/Satellite.php +++ b/application/controllers/Satellite.php @@ -292,6 +292,93 @@ class Satellite extends CI_Controller { } } + public function savePassSettings() { + + $settings = []; + $msg = []; + + $settings['name'] = $this->input->post('setting_name', true); + $settings['minelevation'] = $this->input->post('minelevation', true); + $settings['minazimuth'] = $this->input->post('minazimuth', true); + $settings['maxazimuth'] = $this->input->post('maxazimuth', true); + $settings['grid'] = $this->input->post('grid', true); + $settings['sat'] = $this->input->post('sat', true); + + $settings['sked_minelevation'] = $this->input->post('sked_minelevation', true) ?? ''; + $settings['sked_minazimuth'] = $this->input->post('sked_minazimuth', true) ?? ''; + $settings['sked_maxazimuth'] = $this->input->post('sked_maxazimuth', true) ?? ''; + $settings['sked_grid'] = $this->input->post('sked_grid', true) ?? ''; + + $settings_id = md5($settings['name']); + if(!$this->user_options_model->set_option('sat_pass_settings', $settings_id, array('data' => json_encode($settings)))) { + log_message('error', 'Failed to save pass settings; User: '.$this->session->userdata('user_id').'; Settings: '.json_encode($settings)); + $msg['ok'] = 'Error'; + $msg['message'] = __("Failed to save pass settings!"); + } else { + echo json_encode(array('ok' => 'OK', 'message' => __("Pass settings saved!"))); + $msg['ok'] = 'OK'; + $msg['message'] = __("Pass settings saved!"); + } + + header('Content-Type: application/json'); + echo json_encode($msg); + } + + public function loadPassSettings() { + + $settings_id = $this->input->post('settings_id', true) ?? ''; + $settings = $this->user_options_model->get_options('sat_pass_settings', array('option_name' => $settings_id))->row(); + + if ($settings == false) { + echo json_encode(array('ok' => 'Error', 'message' => __("No settings found!"))); + return; + } + + header('Content-Type: application/json'); + echo json_encode($settings->option_value); + } + + public function delPassSettings() { + + $settings_id = $this->input->post('settings_id', true); + + if(!$this->user_options_model->del_option('sat_pass_settings', $settings_id)) { + log_message('error', 'Failed to delete pass settings; User: '.$this->session->userdata('user_id').'; settings id: '.$settings_id); + echo json_encode(array('ok' => 'Error', 'message' => __("Failed to delete pass settings!"))); + } else { + echo json_encode(array('ok' => 'OK', 'message' => __("Pass settings deleted!"))); + } + } + + public function getPassSettingsList() { + + $sat_pass_settings = $this->user_options_model->get_options('sat_pass_settings', null, $this->session->userdata('user_id'))->result(); + + $r = ''; + if (!empty($sat_pass_settings)) { + $r .= ''; + foreach ($sat_pass_settings as $setting) { + $value = json_decode($setting->option_value); + $settings_id = $setting->option_name; + + $r .= '
  • + +
  • '; + } + } else { + $r .= '
  • '.__("No presets available").'

  • '; + } + + echo $r; + } + public function get_tle_for_predict() { $input_sat = $this->security->xss_clean($this->input->post('sat'));