From 27e13c26c66d51ee249c8cd4866ae171101c660b Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 30 Mar 2023 11:40:32 +0200 Subject: [PATCH] fixed styles --- .../include/functions_inventory.php | 4 + .../operation/agentes/agent_inventory.php | 109 ++- .../operation/inventory/inventory.php | 637 ++++++++---------- 3 files changed, 369 insertions(+), 381 deletions(-) diff --git a/pandora_console/include/functions_inventory.php b/pandora_console/include/functions_inventory.php index f15f888bf6..dc0c23a31c 100644 --- a/pandora_console/include/functions_inventory.php +++ b/pandora_console/include/functions_inventory.php @@ -814,6 +814,10 @@ function get_data_basic_info_sql($params, $count=false) $where .= sprintf(' AND id_agente = %d', $params['id_agent']); } + if ($params['id_group'] > 0) { + $where .= sprintf(' AND id_grupo = %d', $params['id_group']); + } + if ($params['search'] > 0) { $where .= sprintf( ' AND ( alias LIKE "%%%s%%" )', diff --git a/pandora_console/operation/agentes/agent_inventory.php b/pandora_console/operation/agentes/agent_inventory.php index e1ba0a7d88..22db47b2fc 100644 --- a/pandora_console/operation/agentes/agent_inventory.php +++ b/pandora_console/operation/agentes/agent_inventory.php @@ -109,44 +109,93 @@ $utimestampSelectValues = array_reduce( // Inventory module select. $table = new stdClass(); $table->width = '100%'; -$table->class = 'databox filters'; $table->size = []; -$table->data = []; +$table->size[0] = '33%'; +$table->size[1] = '33%'; +$table->size[2] = '33%'; +$table->class = 'filter-table-adv'; -$table->data[0][0] = __('Module'); -$table->data[0][1] = html_print_select_from_sql( - $sqlModuleInventoryAgentView, - 'module_inventory_agent_view', - $module, - 'javascript:this.form.submit();', - __('All'), - 0, +$table->data[0][0] = html_print_label_input_block( + __('Module'), + html_print_select_from_sql( + $sqlModuleInventoryAgentView, + 'module_inventory_agent_view', + $module, + 'javascript:this.form.submit();', + __('All'), + 0, + true, + false, + true, + false, + 'width:100%;' + ) +); + +$table->data[0][1] = html_print_label_input_block( + __('Date'), + html_print_select( + $utimestampSelectValues, + 'utimestamp', + $utimestamp, + 'javascript:this.form.submit();', + __('Now'), + 0, + true, + false, + true, + '', + false, + 'width:100%;' + ) +); + +$table->data[0][2] = html_print_label_input_block( + __('Search'), + html_print_input_text( + 'search_string', + $search_string, + '', + 25, + 0, + true + ) +); + +$buttons = html_print_submit_button( + __('Filter'), + 'search_button', + false, + [ + 'icon' => 'search', + 'mode' => 'mini', + ], true ); -$table->data[0][2] = __('Date'); -$table->data[0][3] = html_print_select( - $utimestampSelectValues, - 'utimestamp', - $utimestamp, - 'javascript:this.form.submit();', - __('Now'), - 0, +$searchForm = '
'; +$searchForm .= html_print_table($table, true); +$searchForm .= html_print_div( + [ + 'class' => 'action-buttons', + 'content' => $buttons, + ], true ); +$searchForm .= '
'; -$table->data[0][4] = __('Search'); -$table->data[0][5] = html_print_input_text('search_string', $search_string, '', 25, 0, true); -$table->data[0][6] = html_print_submit_button(__('Search'), 'search_button', false, 'class="sub wand"', true); - -// Show filters table. -echo sprintf( - '
%s
', - $id_agente, - html_print_table($table, true) +ui_toggle( + $searchForm, + ''.__('Filters').'', + 'filter_form', + '', + true, + false, + '', + 'white-box-content', + 'box-flat white_table_graph fixed_filter_bar' ); -unset($table); $idModuleInventory = null; $rowTable = 1; @@ -181,7 +230,7 @@ foreach ($rows as $row) { $table->align = []; $table->cellpadding = 4; $table->cellspacing = 4; - $table->class = 'databox filters'; + $table->class = 'info_table'; $table->head = []; $table->head[0] = $row['name'].' - ('.date($config['date_format'], $row['utimestamp']).')'; @@ -210,7 +259,7 @@ foreach ($rows as $row) { foreach ($subHeadTitles as $titleData) { $table->data[0][$iterator] = $titleData; - $table->cellstyle[0][$iterator] = 'background: #373737; color: #FFF;'; + $table->cellstyle[0][$iterator] = 'background: var(--primary-color); color: #FFF;'; $iterator++; } diff --git a/pandora_console/operation/inventory/inventory.php b/pandora_console/operation/inventory/inventory.php index 8b846d9494..a373ad86ea 100755 --- a/pandora_console/operation/inventory/inventory.php +++ b/pandora_console/operation/inventory/inventory.php @@ -119,6 +119,7 @@ if (is_ajax() === true) { $length = (int) get_parameter('length', $config['block_size']); $order = get_datatable_order(); $id_agent = (int) get_parameter('id_agent', 0); + $id_group = (int) get_parameter('id_group', 0); $params = [ 'search' => $filter['value'], @@ -126,6 +127,7 @@ if (is_ajax() === true) { 'length' => $length, 'order' => $order, 'id_agent' => $id_agent, + 'id_group' => $id_group, ]; $data = get_data_basic_info_sql($params); @@ -753,295 +755,8 @@ if (is_metaconsole() === true) { $filteringFunction = ''; } -if ($is_metaconsole === false) { - // Single agent selected. - if ($inventory_id_agent > 0 && isset($agents[$inventory_id_agent]) === true) { - $agents = [$inventory_id_agent => $agents[$inventory_id_agent]]; - } - - $agents_ids = array_keys($agents); - if (count($agents_ids) > 0) { - $rows = inventory_get_datatable( - $agents_ids, - $inventory_module, - $utimestamp, - $inventory_search_string, - $export, - false, - $order_by_agent - ); - } - - if (count($agents_ids) === 0 || (int) $rows === ERR_NODATA) { - ui_print_info_message(['no_close' => true, 'message' => __('No data found.') ]); - echo ' '; - - return; - } - - echo "'; - ?> - - $row) { - $columns = explode(';', io_safe_output($row['data_format'])); - array_push($columns, 'Timestamp'); - - $data_rows = explode(PHP_EOL, $row['data']); - foreach ($data_rows as $data_row) { - // Exclude results don't match filter. - if ($inventory_search_string && preg_match('/'.io_safe_output($inventory_search_string).'/', ($data_row)) == 0) { - continue; - } - - $column_data = explode(';', io_safe_output($data_row)); - - if ($column_data[0] !== '') { - $row_tmp = []; - foreach ($column_data as $key => $value) { - $row_tmp[$columns[$key]] = $value; - } - - $row_tmp['Timestamp'] = $row['timestamp']; - array_push($data, (object) $row_tmp); - } - } - - $id_table = 'id_'.$key_row.'_'.$row['id_module_inventory'].'_'.$row['id_agente']; - - $table = ui_print_datatable( - [ - 'id' => $id_table, - 'class' => 'info_table w100p', - 'style' => 'width: 99%', - 'columns' => $columns, - 'column_names' => $columns, - 'no_sortable_columns' => [], - 'data_element' => $data, - 'searching' => true, - 'dom_elements' => 'ftip', - 'order' => [ - 'field' => $columns[0], - 'direction' => 'asc', - ], - 'zeroRecords' => __('No inventory found'), - 'emptyTable' => __('No inventory found'), - 'return' => true, - 'default_pagination' => 10, - 'no_sortable_columns' => [-1], - ] - ); - - $modules .= ui_toggle( - $table, - ''.$row['name'].'', - '', - '', - true, - true, - '', - 'white-box-content w100p', - 'box-shadow white_table_graph w100p', - 'images/arrow_down_green.png', - 'images/arrow_right_green.png', - false, - false, - false, - '', - '', - null, - null, - false, - $id_table - ); - } - - ui_toggle( - $modules, - $agent_rows['agent'], - '', - '', - false, - false - ); - } - } else { - $count_rows = count($rows); - foreach ($rows as $module_rows) { - $agent = ''; - $data = []; - - foreach ($module_rows as $row) { - $columns = explode(';', io_safe_output($row['data_format'])); - array_push($columns, 'Timestamp'); - array_push($columns, 'Agent'); - - // Exclude results don't match filter. - if ($inventory_search_string && preg_match('/'.io_safe_output($inventory_search_string).'/', ($row['data'])) == 0) { - continue; - } - - $data_tmp = []; - if ($row['data'] !== '') { - $values_explode = explode(';', io_safe_output($row['data'])); - - foreach ($values_explode as $key => $value) { - $data_tmp[$columns[$key]] = $value; - } - - $data_tmp['Timestamp'] = $row['timestamp']; - $data_tmp['Agent'] = $row['name_agent']; - array_push($data, $data_tmp); - } - - - $id_table = 'id_'.$row['id_module_inventory']; - } - - $table = ui_print_datatable( - [ - 'id' => $id_table, - 'class' => 'info_table w100p', - 'style' => 'width: 99%', - 'columns' => $columns, - 'column_names' => $columns, - 'no_sortable_columns' => [], - 'data_element' => $data, - 'searching' => true, - 'dom_elements' => 'ftip', - 'order' => [ - 'field' => $columns[0], - 'direction' => 'asc', - ], - 'zeroRecords' => __('No inventory found'), - 'emptyTable' => __('No inventory found'), - 'return' => true, - 'no_sortable_columns' => [], - ] - ); - - if ($count_rows > 1) { - ui_toggle( - $table, - array_shift($module_rows)['name'], - '', - '', - false, - false - ); - } else { - echo $table; - - html_print_action_buttons( - '', - ['type' => 'form_action'] - ); - } - } - } - } else { - $id_agente = $inventory_id_agent; - $agentes = []; - $data = []; - $class = 'info_table'; - $style = 'width: 99%'; - $ordering = true; - $searching = false; - - $columns = [ - 'alias', - 'ip', - 'secondoaryIp', - 'group', - 'secondaryGroups', - 'description', - 'os', - 'interval', - 'lastContact', - 'lastStatusChange', - 'customFields', - 'valuesCustomFields', - ]; - - $columns_names = [ - __('Alias'), - __('IP'), - __('Secondary IP'), - __('Group'), - __('Secondary groups'), - __('Description'), - __('OS'), - __('Interval'), - __('Last contact'), - __('Last status change'), - __('Custom fields'), - __('Values Custom Fields'), - ]; - - ui_print_datatable( - [ - 'id' => 'basic_info', - 'class' => $class, - 'style' => $style, - 'columns' => $columns, - 'column_names' => $columns_names, - 'ordering' => $ordering, - 'searching' => $searching, - 'order' => [ - 'field' => $columns[0], - 'direction' => 'asc', - ], - 'ajax_url' => 'operation/inventory/inventory', - 'ajax_data' => [ - 'get_data_basic_info' => 1, - 'id_agent' => $id_agente, - ], - 'zeroRecords' => __('Agent info not found'), - 'emptyTable' => __('Agent info not found'), - 'return' => false, - ] - ); - - html_print_action_buttons( - '', - ['type' => 'form_action'] - ); - } -} else { - // Metaconsole. - if ($inventory_module !== 'basic') { +if ($inventory_module !== 'basic') { + if (is_metaconsole() === true) { if ($order_by_agent === true) { $count_nodos_tmp = []; foreach ($nodos as $count_value) { @@ -1266,73 +981,293 @@ if ($is_metaconsole === false) { } } } else { - $id_agente = $inventory_id_agent; - $agentes = []; - $data = []; - $class = 'info_table'; - $style = 'width: 99%'; - $ordering = true; - $searching = false; + // Single agent selected. + if ($inventory_id_agent > 0 && isset($agents[$inventory_id_agent]) === true) { + $agents = [$inventory_id_agent => $agents[$inventory_id_agent]]; + } - $columns = [ - 'alias', - 'ip', - 'secondoaryIp', - 'group', - 'secondaryGroups', - 'description', - 'os', - 'interval', - 'lastContact', - 'lastStatusChange', - 'customFields', - 'valuesCustomFields', - ]; + $agents_ids = array_keys($agents); + if (count($agents_ids) > 0) { + $rows = inventory_get_datatable( + $agents_ids, + $inventory_module, + $utimestamp, + $inventory_search_string, + $export, + false, + $order_by_agent + ); + } - $columns_names = [ - __('Alias'), - __('IP'), - __('Secondary IP'), - __('Group'), - __('Secondary groups'), - __('Description'), - __('OS'), - __('Interval'), - __('Last contact'), - __('Last status change'), - __('Custom fields'), - __('Values Custom Fields'), - ]; + if (count($agents_ids) === 0 || (int) $rows === ERR_NODATA) { + ui_print_info_message( + [ + 'no_close' => true, + 'message' => __('No data found.'), + ] + ); + return; + } - ui_print_datatable( - [ - 'id' => 'basic_info', - 'class' => $class, - 'style' => $style, - 'columns' => $columns, - 'column_names' => $columns_names, - 'ordering' => $ordering, - 'searching' => $searching, - 'order' => [ - 'field' => $columns[0], - 'direction' => 'asc', - ], - 'ajax_url' => 'operation/inventory/inventory', - 'ajax_data' => [ - 'get_data_basic_info' => 1, - 'id_agent' => $id_agente, - ], - 'zeroRecords' => __('Agent info not found'), - 'emptyTable' => __('Agent info not found'), - 'return' => false, - ] - ); + echo "'; + ?> + + $row) { + $columns = explode(';', io_safe_output($row['data_format'])); + array_push($columns, 'Timestamp'); - html_print_action_buttons( - '', - ['type' => 'form_action'] - ); + $data_rows = explode(PHP_EOL, $row['data']); + foreach ($data_rows as $data_row) { + // Exclude results don't match filter. + if ($inventory_search_string && preg_match('/'.io_safe_output($inventory_search_string).'/', ($data_row)) == 0) { + continue; + } + + $column_data = explode(';', io_safe_output($data_row)); + + if ($column_data[0] !== '') { + $row_tmp = []; + foreach ($column_data as $key => $value) { + $row_tmp[$columns[$key]] = $value; + } + + $row_tmp['Timestamp'] = $row['timestamp']; + array_push($data, (object) $row_tmp); + } + } + + $id_table = 'id_'.$key_row.'_'.$row['id_module_inventory'].'_'.$row['id_agente']; + + $table = ui_print_datatable( + [ + 'id' => $id_table, + 'class' => 'info_table w100p', + 'style' => 'width: 99%', + 'columns' => $columns, + 'column_names' => $columns, + 'no_sortable_columns' => [], + 'data_element' => $data, + 'searching' => true, + 'dom_elements' => 'ftip', + 'order' => [ + 'field' => $columns[0], + 'direction' => 'asc', + ], + 'zeroRecords' => __('No inventory found'), + 'emptyTable' => __('No inventory found'), + 'return' => true, + 'default_pagination' => 10, + 'no_sortable_columns' => [-1], + ] + ); + + $modules .= ui_toggle( + $table, + ''.$row['name'].'', + '', + '', + true, + true, + '', + 'white-box-content w100p', + 'box-shadow white_table_graph w100p', + 'images/arrow_down_green.png', + 'images/arrow_right_green.png', + false, + false, + false, + '', + '', + null, + null, + false, + $id_table + ); + } + + ui_toggle( + $modules, + $agent_rows['agent'], + '', + '', + false, + false + ); + } + } else { + $count_rows = count($rows); + foreach ($rows as $module_rows) { + $agent = ''; + $data = []; + + foreach ($module_rows as $row) { + $columns = explode(';', io_safe_output($row['data_format'])); + array_push($columns, 'Timestamp'); + array_push($columns, 'Agent'); + + // Exclude results don't match filter. + if ($inventory_search_string && preg_match('/'.io_safe_output($inventory_search_string).'/', ($row['data'])) == 0) { + continue; + } + + $data_tmp = []; + if ($row['data'] !== '') { + $values_explode = explode(';', io_safe_output($row['data'])); + + foreach ($values_explode as $key => $value) { + $data_tmp[$columns[$key]] = $value; + } + + $data_tmp['Timestamp'] = $row['timestamp']; + $data_tmp['Agent'] = $row['name_agent']; + array_push($data, $data_tmp); + } + + + $id_table = 'id_'.$row['id_module_inventory']; + } + + $table = ui_print_datatable( + [ + 'id' => $id_table, + 'class' => 'info_table w100p', + 'style' => 'width: 99%', + 'columns' => $columns, + 'column_names' => $columns, + 'no_sortable_columns' => [], + 'data_element' => $data, + 'searching' => true, + 'dom_elements' => 'ftip', + 'order' => [ + 'field' => $columns[0], + 'direction' => 'asc', + ], + 'zeroRecords' => __('No inventory found'), + 'emptyTable' => __('No inventory found'), + 'return' => true, + 'no_sortable_columns' => [], + ] + ); + + if ($count_rows > 1) { + ui_toggle( + $table, + array_shift($module_rows)['name'], + '', + '', + false, + false + ); + } else { + echo $table; + + html_print_action_buttons( + '', + ['type' => 'form_action'] + ); + } + } + } } +} else { + $id_agente = $inventory_id_agent; + $agentes = []; + $data = []; + $class = 'info_table'; + $style = 'width: 99%'; + $ordering = true; + $searching = false; + + $columns = [ + 'alias', + 'ip', + 'secondoaryIp', + 'group', + 'secondaryGroups', + 'description', + 'os', + 'interval', + 'lastContact', + 'lastStatusChange', + 'customFields', + 'valuesCustomFields', + ]; + + $columns_names = [ + __('Alias'), + __('IP'), + __('Secondary IP'), + __('Group'), + __('Secondary groups'), + __('Description'), + __('OS'), + __('Interval'), + __('Last contact'), + __('Last status change'), + __('Custom fields'), + __('Values Custom Fields'), + ]; + + ui_print_datatable( + [ + 'id' => 'basic_info', + 'class' => $class, + 'style' => $style, + 'columns' => $columns, + 'column_names' => $columns_names, + 'ordering' => $ordering, + 'searching' => $searching, + 'order' => [ + 'field' => $columns[0], + 'direction' => 'asc', + ], + 'ajax_url' => 'operation/inventory/inventory', + 'ajax_data' => [ + 'get_data_basic_info' => 1, + 'id_agent' => $id_agente, + 'id_group' => $inventory_id_group, + ], + 'zeroRecords' => __('Agent info not found'), + 'emptyTable' => __('Agent info not found'), + 'return' => false, + ] + ); + + html_print_action_buttons( + '', + ['type' => 'form_action'] + ); } ui_require_jquery_file('pandora.controls');