From 3b5ebd0bf7f41cd772cb9e5d355f6a2deded4fc0 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Fri, 13 Dec 2019 11:46:44 +0100 Subject: [PATCH] Better quickshell integration and fixes --- pandora_console/extensions/quick_shell.php | 31 ++-------------------- pandora_console/godmode/menu.php | 7 +++++ pandora_console/godmode/setup/setup.php | 18 +++++++++++++ 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php index a8cce0b8de..08d002f55e 100644 --- a/pandora_console/extensions/quick_shell.php +++ b/pandora_console/extensions/quick_shell.php @@ -65,17 +65,13 @@ function quickShell() ui_require_css_file('discovery'); // Settings. - // WebSocket host, where to connect. - if (isset($config['ws_host']) === false) { - config_update_value('ws_host', $_SERVER['SERVER_ADDR']); - } - + // WebSocket host, where client should connect. if (isset($config['ws_port']) === false) { config_update_value('ws_port', 8080); } if (empty($config['ws_proxy_url']) === true) { - $ws_url = 'http://'.$config['ws_host'].':'.$config['ws_port']; + $ws_url = 'http://'.$_SERVER['SERVER_ADDR'].':'.$config['ws_port']; } else { preg_match('/\/\/(.*)/', $config['ws_proxy_url'], $matches); if (isset($_SERVER['HTTPS']) === true) { @@ -381,14 +377,6 @@ function quickShellSettings() } } - // Interface. - ui_print_page_header( - __('QuickShell settings'), - '', - false, - 'quickshell_settings' - ); - if ($changes > 0) { $msg = __('%d Updated', $changes); if ($critical > 0) { @@ -523,19 +511,4 @@ if (empty($agent_id) === false } } -extensions_add_godmode_menu_option( - // Name. - __('QuickShell settings'), - // Acl. - 'PM', - // FatherId. - 'gextensions', - // Icon. - 'images/ehorus/terminal.png', - // Version. - 'N/A', - // SubfatherId. - null -); - extensions_add_godmode_function('quickShellSettings'); diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index af09d9ff0d..b1f8685ada 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -316,6 +316,13 @@ if (check_acl($config['id_user'], 0, 'PM')) { $sub2['godmode/setup/setup&section=notifications']['text'] = __('Notifications'); $sub2['godmode/setup/setup&section=notifications']['refr'] = 0; + + // Enable only if quickshell is enabled. + if (function_exists('quickShellSettings') === true) { + $sub2['godmode/setup/setup&section=quickshell']['text'] = __('QuickShell'); + $sub2['godmode/setup/setup&section=quickshell']['refr'] = 0; + } + if ($config['activate_gis']) { $sub2['godmode/setup/gis']['text'] = __('Map conections GIS'); } diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index a46d7bc832..d396bbd953 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -133,6 +133,14 @@ $buttons['notifications'] = [ 'text' => ''.html_print_image('images/alerts_template.png', true, ['title' => __('Notifications')]).'', ]; +// Enable only if quickshell is enabled. +if (function_exists('quickShellSettings') === true) { + $buttons['quickshell'] = [ + 'active' => false, + 'text' => ''.html_print_image('images/ehorus/terminal.png', true, ['title' => __('Quickshell')]).'', + ]; +} + $help_header = ''; if (enterprise_installed()) { $subpage = setup_enterprise_add_subsection_main($section, $buttons, $help_header); @@ -183,6 +191,12 @@ switch ($section) { $subpage = ' » '.__('Notifications'); break; + case 'quickshell': + $buttons['quickshell']['active'] = true; + $subpage = ' » '.__('QuickShell'); + $help_header = 'quickshell_settings'; + break; + case 'enterprise': $buttons['enterprise']['active'] = true; $subpage = ' » '.__('Enterprise'); @@ -247,6 +261,10 @@ switch ($section) { include_once $config['homedir'].'/godmode/setup/setup_notifications.php'; break; + case 'quickshell': + quickShellSettings(); + break; + default: enterprise_hook('setup_enterprise_select_tab', [$section]); break;