From 6eb9319a7a0342fc046c109323a0bc4ee80801d1 Mon Sep 17 00:00:00 2001 From: "jose.gonzalez@pandorafms.com" Date: Wed, 23 Nov 2022 17:42:53 +0100 Subject: [PATCH] Minor fixes --- .../godmode/agentes/module_manager.php | 298 +++++++++++------- pandora_console/index.php | 2 +- 2 files changed, 177 insertions(+), 123 deletions(-) diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index a58f013cd2..26b82cf7fc 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -44,16 +44,20 @@ $search_string = get_parameter('search_string'); global $policy_page; -if (!isset($policy_page)) { +if (isset($policy_page) === false) { $policy_page = false; } +$checked = (bool) get_parameter('checked'); +$sec2 = (string) get_parameter('sec2'); -echo '
'; - -echo ''; -echo "'; -echo "'; -echo ""; -echo ''; + +// Print filter table. +html_print_table($filterTable); // Check if there is at least one server of each type available to assign that // kind of modules. If not, do not show server type in combo. $network_available = db_get_sql( @@ -122,7 +134,7 @@ if ($develop_bypass || is_metaconsole()) { $plugin_available = 1; // FIXME when prediction predictions server modules can be configured. // on metaconsole. - $prediction_available = is_metaconsole() ? 0 : 1; + $prediction_available = (is_metaconsole() === true) ? 0 : 1; } $modules = []; @@ -147,11 +159,10 @@ if (is_metaconsole() === true || $web_available >= '1') { $modules['webserver'] = __('Create a new web Server module'); } -if (enterprise_installed()) { +if (enterprise_installed() === true) { set_enterprise_module_types($modules); } -$sec2 = get_parameter('sec2', ''); if (strstr($sec2, 'enterprise/godmode/policies/policies') !== false) { // It is unset because the policies haven't a table tmodule_synth and the // some part of code to apply this kind of modules in policy agents. @@ -159,16 +170,13 @@ if (strstr($sec2, 'enterprise/godmode/policies/policies') !== false) { // the modules to show in syntetic module policy form must be the policy // modules from the same policy. unset($modules['predictionserver']); - if (enterprise_installed()) { + if (enterprise_installed() === true) { unset($modules['webux']); } } -$show_creation = false; -$checked = get_parameter('checked'); - -if (($policy_page) || (isset($agent))) { - if ($policy_page) { +if (($policy_page === true) || (isset($agent) === true)) { + if ($policy_page === true) { $show_creation = is_management_allowed(); } else { if (isset($all_groups) === false) { @@ -178,79 +186,64 @@ if (($policy_page) || (isset($agent))) { ); } - if (check_acl_one_of_groups($config['id_user'], $all_groups, 'AW')) { - $show_creation = true; - } - } - - if ($show_creation === true) { - // Create module/type combo. - echo ''; - if (!$policy_page) { - echo ''; - } - - echo ''; - echo ''; - echo ''; - echo ''; + $show_creation = check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true; } +} else { + $show_creation = false; } -echo '
"; -echo __('Search').' '.html_print_input_text( +// Table for filter bar. +$filterTable = new stdClass(); +$filterTable->class = 'fixed_filter_bar'; +$filterTable->data = []; +$filterTable->cellstyle[0][0] = 'flex: 0 1 20%;'; +$filterTable->data[0][0] = ''.__('Search').''; +$filterTable->data[0][0] .= html_print_input_text( 'search_string', $search_string, '', @@ -61,28 +65,36 @@ echo __('Search').' '.html_print_input_text( 255, true ); -html_print_input_hidden('search', 1); -// Search string filter form. -if (($policy_page !== false) || (isset($agent) === true)) { - echo ''; -} else { - echo ''; +$filterTable->data[0][0] .= html_print_input_hidden('search', 1, true); + +if ((bool) $policy_page === false) { + $filterTable->cellstyle[0][1] = 'flex: 0 1 20%'; + $filterTable->data[0][1] = ''.__('Show in hierachy mode').''; + $filterTable->data[0][1] .= html_print_checkbox_switch( + 'status_hierachy_mode', + '', + ((string) $checked === 'true'), + true, + false, + 'onChange=change_mod_filter();' + ); } -echo '"; -html_print_submit_button( +$filterTable->cellstyle[0][2] = 'flex: 0 1 60%; justify-content: flex-end;'; +$filterTable->data[0][2] .= html_print_submit_button( __('Filter'), 'filter', false, [ - 'icon' => 'search', - 'mode' => 'secondary mini', - ] + 'icon' => 'search', + 'class' => 'float-right', + 'mode' => 'secondary mini', + ], + true ); -echo '
'; - echo __('Show in hierachy mode'); - if ($checked == 'true') { - $checked = true; - } else { - $checked = false; - } - - html_print_checkbox( - 'status_hierachy_mode', - '', - $checked, - false, - false, - 'onChange=change_mod_filter();' - ); - echo ''; - echo __('

Type

'); - html_print_select( - $modules, - 'moduletype', - '', - '', - '', - '', - false, - false, - false, - '', - false, - 'max-width:300px;' - ); - html_print_input_hidden('edit_module', 1); - echo '
'; - html_print_submit_button( - __('Create'), - 'updbutton', - false, - [ - 'icon' => 'next', - 'mode' => 'mini secondary', - ] - ); - echo '
'; +if ($show_creation === true) { + // Create module/type combo. + $tableCreateModule = new stdClass(); + $tableCreateModule->id = 'create'; + $tableCreateModule->width = '100%'; + $tableCreateModule->data = []; + $tableCreateModule->style = []; -if (!$config['disable_help']) { + $tableCreateModule->data['caption_type'] = '
'; + $tableCreateModule->data['caption_type'] .= html_print_input_hidden('edit_module', 1); + $tableCreateModule->data['caption_type'] .= __('Type'); + $tableCreateModule->data['type'] = html_print_select( + $modules, + 'moduletype', + '', + '', + '', + '', + true, + false, + false, + '', + false, + 'max-width:400px;' + ); + + $tableCreateModule->data['submitButton'] = html_print_submit_button( + __('Create'), + 'updbutton', + false, + [ + 'icon' => 'next', + 'mode' => 'mini secondary', + ], + true + ); + + $tableCreateModule->data['submitButton'] .= '
'; +} + +// echo ''; +/* + if (!$config['disable_help']) { echo '
'; echo ''; echo "".__('Get more modules on Monitoring Library').''; echo ''; echo '
'; -} + } +*/ -if (! isset($id_agente)) { +if (isset($id_agente) === false) { return; } @@ -1285,59 +1278,120 @@ html_print_table($table); if ((bool) check_acl_one_of_groups($config['id_user'], $all_groups, 'AW') === true) { html_print_input_hidden('submit_modules_action', 1); - html_print_div( + $actionButtons = html_print_button( + __('Create module'), + 'create_module', + false, + 'create_module_dialog()', + [ 'icon' => 'wand' ], + true + ); + + $actionButtons .= html_print_submit_button( + __('Execute action'), + 'submit_modules_action', + false, + [ + 'icon' => 'next', + 'mode' => 'link', + ], + true + ); + + $actionButtons .= html_print_select( + [ + 'disable' => 'Disable selected modules', + 'delete' => 'Delete selected modules', + ], + 'module_action', + '', + '', + '', + 0, + true, + false, + false, + '', + false, + false, + false, + 300 + ); + + html_print_action_buttons( + $actionButtons, + [ 'type' => 'data_table' ] + ); + echo ''; + + + $modalCreateModule = '
'; + $modalCreateModule .= html_print_table($tableCreateModule, true); + $modalCreateModule .= html_print_div( [ 'class' => 'action-buttons', 'content' => html_print_submit_button( - __('Execute action'), - 'submit_modules_action', + __('Add'), + 'create_module_dialog', false, [ - 'icon' => 'next', - 'mode' => 'link', + 'icon' => 'add', + 'mode' => 'secondary mini', ], true - ).html_print_select( - [ - 'disable' => 'Disable selected modules', - 'delete' => 'Delete selected modules', - ], - 'module_action', - '', - '', - '', - 0, - true, - false, - false, - '', - false, - false, - false, - 300 ), + ], + true + ); + $modalCreateModule .= '
'; + + html_print_div( + [ + 'id' => 'modal', + 'style' => 'display: none', + 'content' => $modalCreateModule, ] ); - - echo ''; } ?>