From 3a2cbb7a6294db3b48eb4639775c94f7107653fe Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Thu, 30 Mar 2023 16:50:30 +0200 Subject: [PATCH] Datatables & styles fix --- .../godmode/users/user_management.php | 7 +- pandora_console/include/ajax/audit_log.php | 19 +- pandora_console/include/functions_ui.php | 522 +++++++++--------- .../lib/Dashboard/Widgets/ModulesByStatus.php | 1 + pandora_console/include/styles/tables.css | 14 +- .../operation/agentes/alerts_status.php | 50 +- 6 files changed, 328 insertions(+), 285 deletions(-) diff --git a/pandora_console/godmode/users/user_management.php b/pandora_console/godmode/users/user_management.php index 43e41745de..9e648a7a03 100644 --- a/pandora_console/godmode/users/user_management.php +++ b/pandora_console/godmode/users/user_management.php @@ -764,10 +764,9 @@ html_print_table($userManagementTable); $vcard_data = []; $vcard_data['version'] = '3.0'; -$vcard_data['firstName'] = $user_info['firstname']; -$vcard_data['lastName'] = $user_info['lastname']; -$vcard_data['middleName'] = ($user_info['middlename'] === '1') ? '' : $user_info['middlename']; -$vcard_data['nickname'] = $user_info['fullname']; +$vcard_data['firstName'] = $user_info['fullname']; +$vcard_data['lastName'] = ''; +$vcard_data['middleName'] = ''; $vcard_data['workPhone'] = $user_info['phone']; $vcard_data['email'] = $user_info['email']; $vcard_data['organization'] = io_safe_output(get_product_name()); diff --git a/pandora_console/include/ajax/audit_log.php b/pandora_console/include/ajax/audit_log.php index 4d92704852..dbb842047c 100644 --- a/pandora_console/include/ajax/audit_log.php +++ b/pandora_console/include/ajax/audit_log.php @@ -160,7 +160,7 @@ if ($load_filter_modal) { true, '', false, - 'margin-left:5px; width:'.$filter_id_width.';' + 'width:'.$filter_id_width.';' ); $table->rowclass[] = 'display-grid'; @@ -169,8 +169,9 @@ if ($load_filter_modal) { 'load_filter', false, [ - 'class' => 'mini w25p', - 'style' => 'margin-left: 73%', + 'class' => 'mini w30p', + 'icon' => 'load', + 'style' => 'margin-left: 208px; width: 130px;', 'onclick' => 'load_filter_values();', ], true @@ -189,7 +190,7 @@ function show_filter() { draggable: true, modal: false, closeOnEscape: true, - width: 500 + width: 380 }); } @@ -293,8 +294,9 @@ if ($save_filter_modal) { 'save_filter', false, [ - 'class' => 'mini w25p', - 'style' => 'margin-left: 56%', + 'class' => 'mini ', + 'icon' => 'save', + 'style' => 'margin-left: 175px; width: 125px;', 'onclick' => 'save_new_filter();', ], true @@ -330,8 +332,9 @@ if ($save_filter_modal) { 'update_filter', false, [ - 'class' => 'mini w25p', - 'style' => 'margin-left: 56%', + 'class' => 'mini ', + 'icon' => 'save', + 'style' => 'margin-left: 155px; width: 145px;', 'onclick' => 'save_update_filter();', ], true diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index da2c86f941..1ad803be44 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -3628,6 +3628,11 @@ function ui_print_datatable(array $parameters) $parameters['csv'] = 1; } + $dom_elements = '"plfrtiB"'; + if (isset($parameters['dom_elements'])) { + $dom_elements = '"'.$parameters['dom_elements'].'"'; + } + $filter = ''; // Datatable filter. if (isset($parameters['form']) && is_array($parameters['form'])) { @@ -3790,6 +3795,34 @@ function ui_print_datatable(array $parameters) } $table .= ''; + + if (isset($parameters['data_element']) === true) { + $table .= ''; + foreach ($parameters['data_element'] as $row) { + $table .= ''; + foreach ($row as $td_data) { + $table .= ''.$td_data.''; + } + + $table .= ''; + } + + $table .= ''; + + $js = ''; + } + $table .= ''; $pagination_class = 'pandora_pagination'; @@ -3813,279 +3846,276 @@ function ui_print_datatable(array $parameters) $export_columns = ',columns: \'th:not(:last-child)\''; } - if (isset($parameters['ajax_url'])) { - $type_data = 'ajax: { - url: "'.ui_get_full_url('ajax.php', false, false, false).'", - type: "POST", - dataSrc: function (json) { - if($("#'.$form_id.'_search_bt") != undefined) { - $("#'.$form_id.'_loading").remove(); - } + if (isset($parameters['data_element']) === false) { + if (isset($parameters['ajax_url'])) { + $type_data = 'ajax: { + url: "'.ui_get_full_url('ajax.php', false, false, false).'", + type: "POST", + dataSrc: function (json) { + if($("#'.$form_id.'_search_bt") != undefined) { + $("#'.$form_id.'_loading").remove(); + } - if (json.error) { - console.error(json.error); - $("#error-'.$table_id.'").html(json.error); - $("#error-'.$table_id.'").dialog({ - title: "Filter failed", - width: 630, - resizable: true, - draggable: true, - modal: false, - closeOnEscape: true, - buttons: { - "Ok" : function () { - $(this).dialog("close"); + if (json.error) { + console.error(json.error); + $("#error-'.$table_id.'").html(json.error); + $("#error-'.$table_id.'").dialog({ + title: "Filter failed", + width: 630, + resizable: true, + draggable: true, + modal: false, + closeOnEscape: true, + buttons: { + "Ok" : function () { + $(this).dialog("close"); + } } - } - }).parent().addClass("ui-state-error"); - } else {'; + }).parent().addClass("ui-state-error"); + } else {'; - if (isset($parameters['ajax_return_operation']) === true - && empty($parameters['ajax_return_operation']) === false - && isset($parameters['ajax_return_operation_function']) === true - && empty($parameters['ajax_return_operation_function']) === false - ) { - $type_data .= ' - if (json.'.$parameters['ajax_return_operation'].' !== undefined) { - '.$parameters['ajax_return_operation_function'].'(json.'.$parameters['ajax_return_operation'].'); - } - '; - } + if (isset($parameters['ajax_return_operation']) === true + && empty($parameters['ajax_return_operation']) === false + && isset($parameters['ajax_return_operation_function']) === true + && empty($parameters['ajax_return_operation_function']) === false + ) { + $type_data .= ' + if (json.'.$parameters['ajax_return_operation'].' !== undefined) { + '.$parameters['ajax_return_operation_function'].'(json.'.$parameters['ajax_return_operation'].'); + } + '; + } + + if (isset($parameters['ajax_postprocess'])) { + $type_data .= ' + if (json.data) { + json.data.forEach(function(item) { + '.$parameters['ajax_postprocess'].' + }); + } else { + json.data = {}; + }'; + } - if (isset($parameters['ajax_postprocess'])) { $type_data .= ' - if (json.data) { - json.data.forEach(function(item) { - '.$parameters['ajax_postprocess'].' + return json.data; + } + }, + data: function (data) { + if($("#button-'.$form_id.'_search_bt") != undefined) { + var loading = \''.html_print_image( + 'images/spinner.gif', + true, + [ + 'id' => $form_id.'_loading', + 'class' => 'loading-search-datatables-button', + ] + ).'\'; + $("#button-'.$form_id.'_search_bt").parent().append(loading); + } + + inputs = $("#'.$form_id.' :input"); + + values = {}; + inputs.each(function() { + values[this.name] = $(this).val(); + }) + + $.extend(data, { + filter: values,'."\n"; + + if (is_array($parameters['ajax_data'])) { + foreach ($parameters['ajax_data'] as $k => $v) { + $type_data .= $k.':'.json_encode($v).",\n"; + } + } + + $type_data .= 'page: "'.$parameters['ajax_url'].'" }); - } else { - json.data = {}; - }'; + + return data; + } + },'; + } else { + $type_data = 'data: '.json_encode($parameters['data_element']).','; } - $type_data .= ' - return json.data; - } - }, - data: function (data) { - if($("#button-'.$form_id.'_search_bt") != undefined) { - var loading = \''.html_print_image( - 'images/spinner.gif', - true, - [ - 'id' => $form_id.'_loading', - 'class' => 'loading-search-datatables-button', - ] - ).'\'; - $("#button-'.$form_id.'_search_bt").parent().append(loading); - } + $serverside = 'true'; + if (isset($parameters['data_element'])) { + $serverside = 'false'; + } - inputs = $("#'.$form_id.' :input"); + // Javascript controller. + $js = ''; } - if (isset($parameters['csv']) === true) { - $js."'$('#".$table_id."').on( 'buttons-processing', function ( e, indicator ) { - if ( indicator ) { - console.log('a'); - } - else { - console.log('b'); - }"; - } - - $js .= '$("table#'.$table_id.'").removeClass("invisible"); - });'; - $js .= ' - $(function() { - $(document).on("preInit.dt", function (ev, settings) { - $("div.dataTables_length").hide(); - $("div.dt-buttons").hide(); - }); - }); - - '; - - $js .= ''; - // Order. $info_msg_arr = []; $info_msg_arr['message'] = $emptyTable; diff --git a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php index 53d996607c..01a8781606 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php +++ b/pandora_console/include/lib/Dashboard/Widgets/ModulesByStatus.php @@ -453,6 +453,7 @@ class ModulesByStatus extends Widget 1000, ], ], + 'dom_elements' => 'frtilp', ] ); } catch (\Exception $e) { diff --git a/pandora_console/include/styles/tables.css b/pandora_console/include/styles/tables.css index eea7815b59..fc421444d5 100644 --- a/pandora_console/include/styles/tables.css +++ b/pandora_console/include/styles/tables.css @@ -816,10 +816,6 @@ div[id^="auto-os-"] > img { height: 20px; } -.dataTables_paginate { - margin-right: 10px; -} - .w22px { width: 22px; } @@ -838,3 +834,13 @@ td.FF-thresholds-pdd { padding: 0px !important; padding-left: 13px !important; } + +div.grid-stack-item-content a.pandora_pagination, +a.mini-pandora-pagination { + padding: 7px; + font-size: 9pt; +} + +input.mini-search-input { + height: 30px; +} diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php index d970c5aa65..f0ae9b033d 100755 --- a/pandora_console/operation/agentes/alerts_status.php +++ b/pandora_console/operation/agentes/alerts_status.php @@ -434,35 +434,39 @@ if ($agent_view_page === true) { ); } -if (((bool) check_acl($config['id_user'], $id_group, 'AW') === true || (bool) check_acl($config['id_user'], $id_group, 'LM') === true)) { - if ($agent_view_page === true) { - html_print_div( - [ - 'class' => 'action-buttons pdd_b_10px pdd_r_5px w100p', - 'content' => html_print_submit_button( +if (is_metaconsole() === false) { + if (((bool) check_acl($config['id_user'], $id_group, 'AW') === true || (bool) check_acl($config['id_user'], $id_group, 'LM') === true)) { + if ($agent_view_page === true) { + html_print_div( + [ + 'class' => 'action-buttons pdd_b_10px pdd_r_5px w100p', + 'content' => html_print_submit_button( + __('Validate'), + 'alert_validate', + false, + [ + 'icon' => 'wand', + 'mode' => 'secondary mini', + ], + true + ), + ] + ); + } else { + html_print_action_buttons( + html_print_submit_button( __('Validate'), 'alert_validate', false, - [ - 'icon' => 'wand', - 'mode' => 'secondary mini', - ], + [ 'icon' => 'wand' ], true ), - ] - ); - } else { - html_print_action_buttons( - html_print_submit_button( - __('Validate'), - 'alert_validate', - false, - [ 'icon' => 'wand' ], - true - ), - ['type' => 'form_action'] - ); + ['type' => 'form_action'] + ); + } } +} else { + html_print_action_buttons(''); } $html_content = ob_get_clean();