fixed styles

This commit is contained in:
daniel 2023-02-28 19:01:37 +01:00
parent fa354ff8e6
commit 8ac9df14ab
11 changed files with 587 additions and 436 deletions

View File

@ -1158,7 +1158,6 @@ if (check_login()) {
} }
} }
hd($data[4], true);
// Module thresholds. // Module thresholds.
$data[5] = ''; $data[5] = '';
if ((int) $module['id_tipo_modulo'] !== 25) { if ((int) $module['id_tipo_modulo'] !== 25) {

View File

@ -669,7 +669,6 @@ class Tree
} }
$module['statusImageHTML'] = ui_print_status_image($statusType, htmlspecialchars($statusTitle), true, ['is_tree_view' => true]); $module['statusImageHTML'] = ui_print_status_image($statusType, htmlspecialchars($statusTitle), true, ['is_tree_view' => true]);
hd($module['statusImageHTML'], true);
// HTML of the server type image. // HTML of the server type image.
$module['serverTypeHTML'] = ui_print_servertype_icon((int) $module['server_type']); $module['serverTypeHTML'] = ui_print_servertype_icon((int) $module['server_type']);

View File

@ -176,7 +176,7 @@ function groupview_get_groups_list($id_user=false, $access='AR', $is_not_paginat
[] []
); );
$total_counters = []; $list = [];
foreach ($agents_counters as $id_group => $agent_counter) { foreach ($agents_counters as $id_group => $agent_counter) {
$list[$id_group]['_name_'] = $agent_counter['name']; $list[$id_group]['_name_'] = $agent_counter['name'];

View File

@ -718,7 +718,7 @@ function inventory_get_datatable(
} }
if (array_search(-1, $agents_ids) === false) { if (array_search(-1, $agents_ids) === false) {
array_push($where, 'id_agente IN ('.implode(',', $agents_ids).')'); array_push($where, 'tagent_module_inventory.id_agente IN ('.implode(',', $agents_ids).')');
} }
if ($inventory_module_name[0] !== '0' if ($inventory_module_name[0] !== '0'
@ -732,75 +732,61 @@ function inventory_get_datatable(
array_push($where, "tagent_module_inventory.data LIKE '%".$inventory_search_string."%'"); array_push($where, "tagent_module_inventory.data LIKE '%".$inventory_search_string."%'");
} }
$sql = 'SELECT * $sql = sprintf(
FROM tmodule_inventory, tagent_module_inventory 'SELECT tmodule_inventory.*,
WHERE tagent_module_inventory.*,
'.implode(' AND ', $where).' tagente.alias as name_agent
ORDER BY tmodule_inventory.id_module_inventory LIMIT '.$offset.', '.$config['block_size']; FROM tmodule_inventory
INNER JOIN tagent_module_inventory
$sql_count = 'SELECT COUNT(*) ON tmodule_inventory.id_module_inventory = tagent_module_inventory.id_module_inventory
FROM tmodule_inventory, tagent_module_inventory LEFT JOIN tagente
WHERE '.implode(' AND ', $where); ON tagente.id_agente = tagent_module_inventory.id_agente
WHERE %s
ORDER BY tmodule_inventory.id_module_inventory
LIMIT %d, %d',
implode(' AND ', $where),
$offset,
$config['block_size']
);
$rows = db_get_all_rows_sql($sql); $rows = db_get_all_rows_sql($sql);
$count = db_get_sql($sql_count);
if ($order_by_agent === false) { if ($order_by_agent === false) {
$modules = []; $modules = [];
$module_rows = [];
foreach ($rows as $row) { foreach ($rows as $row) {
array_push($modules, $row['name']); $data_rows = explode(PHP_EOL, $row['data']);
} foreach ($data_rows as $data_key => $data_value) {
if (empty($data_value) === false) {
foreach ($modules as $module) { $row['data'] = $data_value;
$rows_tmp = []; $modules[$row['name']][$row['name_agent'].'-'.$data_key.'-'.$data_value] = $row;
foreach ($rows as $row) {
if ($row['name'] === $module) {
$agent_name = db_get_value_sql(
'SELECT alias
FROM tagente
WHERE id_agente = '.$row['id_agente']
);
$row['name_agent'] = $agent_name;
array_push($rows_tmp, $row);
$module_rows[$module] = $rows_tmp;
} }
} }
} }
return $module_rows; return $modules;
} else { } else {
$agents_rows = []; $agents_rows = [];
$agent_data = []; $agent_data = [];
$rows_tmp = []; $rows_tmp = [];
foreach ($rows as $row) { foreach ($rows as $row) {
$agent_name = db_get_value_sql(
'SELECT alias
FROM tagente
WHERE id_agente = '.$row['id_agente']
);
$row['name_agent'] = $agent_name;
$agent_data[$row['id_agente']][] = $row; $agent_data[$row['id_agente']][] = $row;
} }
foreach ($agent_data as $id_agent => $rows) { foreach ($agent_data as $id_agent => $rows) {
$agent_name = db_get_value_sql( $rows_tmp['agent'] = $row['name_agent'];
'SELECT alias
FROM tagente
WHERE id_agente = '.$id_agent
);
$rows_tmp['agent'] = $agent_name;
foreach ($rows as $row) { foreach ($rows as $row) {
if ($utimestamp > 0) { if ($utimestamp > 0) {
$data_row = db_get_row_sql( $data_row = db_get_row_sql(
"SELECT data, timestamp sprintf(
'SELECT `data`,
`timestamp`
FROM tagente_datos_inventory FROM tagente_datos_inventory
WHERE utimestamp <= '".$utimestamp."' WHERE utimestamp <= "%s"
AND id_agent_module_inventory = ".$row['id_agent_module_inventory'].' ORDER BY utimestamp DESC' AND id_agent_module_inventory = %d
ORDER BY utimestamp DESC',
$utimestamp,
$row['id_agent_module_inventory']
)
); );
if ($data_row !== false) { if ($data_row !== false) {
@ -821,6 +807,63 @@ function inventory_get_datatable(
} }
function get_data_basic_info_sql($params, $count=false)
{
$where = 'WHERE 1=1 ';
if ($params['id_agent'] > 0) {
$where .= sprintf(' AND id_agente = %d', $params['id_agent']);
}
if ($params['search'] > 0) {
$where .= sprintf(
' AND ( alias LIKE "%%%s%%" )',
$params['search']
);
}
$limit_condition = '';
$order_condition = '';
$fields = 'count(*)';
if ($count !== true) {
$fields = '*';
$limit_condition = sprintf(
'LIMIT %d, %d',
$params['start'],
$params['length']
);
$order_condition = sprintf('ORDER BY %s', $params['order']);
}
$sql = sprintf(
'SELECT %s
FROM tagente
%s
%s
%s',
$fields,
$where,
$order_condition,
$limit_condition
);
if ($count !== true) {
$result = db_get_all_rows_sql($sql);
if ($result === false) {
$result = [];
}
} else {
$result = db_get_sql($sql);
if ($result === false) {
$result = 0;
}
}
return $result;
}
function inventory_get_dates($module_inventory_name, $inventory_agent, $inventory_id_group) function inventory_get_dates($module_inventory_name, $inventory_agent, $inventory_id_group)
{ {
$sql = 'SELECT tagente_datos_inventory.utimestamp, $sql = 'SELECT tagente_datos_inventory.utimestamp,

View File

@ -225,7 +225,6 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c
} else { } else {
// Only profiles that can be viewed by the user. // Only profiles that can be viewed by the user.
$group_um = users_get_groups_UM($config['id_user']); $group_um = users_get_groups_UM($config['id_user']);
hd($group_um, true);
if (isset($group_um[0]) === true) { if (isset($group_um[0]) === true) {
$group_um_string = implode(',', array_keys(users_get_groups($config['id_user'], 'um', true))); $group_um_string = implode(',', array_keys(users_get_groups($config['id_user'], 'um', true)));
} else { } else {
@ -239,7 +238,6 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c
$id, $id,
$group_um_string $group_um_string
); );
hd($sql, true);
$result = db_get_all_rows_sql($sql); $result = db_get_all_rows_sql($sql);
} }

View File

@ -3728,11 +3728,6 @@ function ui_print_datatable(array $parameters)
$("#'.$form_id.'_loading").remove(); $("#'.$form_id.'_loading").remove();
} }
// Move elements to table_action_buttons bar.
$(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers"));
$(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dataTables_length"));
$(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dt-buttons"));
if (json.error) { if (json.error) {
console.error(json.error); console.error(json.error);
$("#error-'.$table_id.'").html(json.error); $("#error-'.$table_id.'").html(json.error);
@ -3904,6 +3899,13 @@ function ui_print_datatable(array $parameters)
{ bSortable: false, targets: '.$no_sortable_columns.' } { bSortable: false, targets: '.$no_sortable_columns.' }
], ],
ordering: '.$ordering.', ordering: '.$ordering.',
initComplete: function(settings, json) {
// Move elements to table_action_buttons bar.
$(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers"));
$(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dataTables_length"));
$(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dt-buttons"));
$(".action_buttons_right_content").append($("#'.$table_id.'_wrapper > .dataTables_filter"));
},
columns: ['; columns: [';
foreach ($parameters['datacolumns'] as $data) { foreach ($parameters['datacolumns'] as $data) {
@ -3926,8 +3928,6 @@ function ui_print_datatable(array $parameters)
$("#button-'.$form_id.'_search_bt").click(function (){ $("#button-'.$form_id.'_search_bt").click(function (){
dt_'.$table_id.'.draw().page(0) dt_'.$table_id.'.draw().page(0)
}); });
//$(".action_buttons_right_content").html($("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers"));
'; ';
if (isset($parameters['caption']) === true if (isset($parameters['caption']) === true

View File

@ -727,3 +727,7 @@ tr.datos2 > td.datos2 > div > div {
.mgn_tp_0_imp { .mgn_tp_0_imp {
margin-top: 0px !important; margin-top: 0px !important;
} }
.dataTables_wrapper .dataTables_filter input {
margin: 0.5em;
}

View File

@ -184,7 +184,6 @@ if ($idAgent != 0) {
$print_agent = true; $print_agent = true;
if (is_metaconsole() === false) {
// Header. // Header.
ui_print_standard_header( ui_print_standard_header(
__('Alert detail'), __('Alert detail'),
@ -204,14 +203,7 @@ if ($idAgent != 0) {
], ],
] ]
); );
} else {
ui_meta_print_header(__('Alerts view'));
} }
}
enterprise_hook('open_meta_frame');
$alerts = []; $alerts = [];
@ -237,7 +229,6 @@ if (is_metaconsole() === false) {
[ [
'title' => __('Standby'), 'title' => __('Standby'),
'text' => __('Standby'), 'text' => __('Standby'),
'style' => 'max-width: 5%;',
], ],
); );
@ -252,7 +243,6 @@ if (is_metaconsole() === false) {
[ [
'title' => __('Policy'), 'title' => __('Policy'),
'text' => __('Policy'), 'text' => __('Policy'),
'style' => 'max-width: 5%;vertical-align: baseline;',
] ]
); );
@ -278,26 +268,11 @@ 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 ((bool) check_acl($config['id_user'], $id_group, 'AW') === true || (bool) check_acl($config['id_user'], $id_group, 'LM') === true) {
array_push( array_push(
$column_names, $column_names,
[ ['text' => 'Module'],
'text' => 'Module', ['text' => 'Template'],
'style' => 'min-width: 15%;vertical-align: baseline;', ['text' => 'Operation'],
], ['text' => 'Last fired'],
[ ['text' => 'Status']
'text' => 'Template',
'style' => 'min-width: 10%;vertical-align: baseline;',
],
[
'text' => 'Operation',
'style' => 'min-width: 15%;vertical-align: baseline;',
],
[
'text' => 'Last fired',
'style' => 'min-width: 15%;',
],
[
'text' => 'Status',
'style' => 'width: 5%;',
]
); );
$columns = array_merge( $columns = array_merge(
@ -439,7 +414,7 @@ if ($agent_view_page === true) {
[ [
'id' => 'alerts_status_datatable', 'id' => 'alerts_status_datatable',
'class' => 'info_table', 'class' => 'info_table',
'style' => 'width: 99%', 'style' => 'width: 99%;',
'columns' => $columns, 'columns' => $columns,
'column_names' => $column_names, 'column_names' => $column_names,
'no_sortable_columns' => $no_sortable_columns, 'no_sortable_columns' => $no_sortable_columns,
@ -538,9 +513,6 @@ html_print_input_text('strict_user_hidden', $strict_user);
html_print_input_text('is_meta_hidden', (int) is_metaconsole()); html_print_input_text('is_meta_hidden', (int) is_metaconsole());
echo '</div>'; echo '</div>';
enterprise_hook('close_meta_frame');
ui_require_css_file('cluetip', 'include/styles/js/'); ui_require_css_file('cluetip', 'include/styles/js/');
ui_require_jquery_file('cluetip'); ui_require_jquery_file('cluetip');
?> ?>

View File

@ -50,7 +50,9 @@ enterprise_include_once('include/functions_metaconsole.php');
$isFunctionPolicies = enterprise_include_once('include/functions_policies.php'); $isFunctionPolicies = enterprise_include_once('include/functions_policies.php');
if (! defined('METACONSOLE')) { $buttons = [];
$subpage = '';
if (is_metaconsole() === false) {
$section = (string) get_parameter('section', 'view'); $section = (string) get_parameter('section', 'view');
$buttons['fields'] = [ $buttons['fields'] = [
@ -89,6 +91,7 @@ if (! defined('METACONSOLE')) {
$buttons['view']['active'] = true; $buttons['view']['active'] = true;
break; break;
} }
}
// Header. // Header.
ui_print_standard_header( ui_print_standard_header(
@ -110,13 +113,14 @@ if (! defined('METACONSOLE')) {
] ]
); );
if (is_metaconsole() === false) {
if ($section == 'fields') { if ($section == 'fields') {
include_once $config['homedir'].'/godmode/agentes/status_monitor_custom_fields.php'; include_once $config['homedir'].'/godmode/agentes/status_monitor_custom_fields.php';
exit(); exit();
} }
} else { } else {
$section = (string) get_parameter('sec', 'estado'); $section = (string) get_parameter('sec', 'estado');
ui_meta_print_header(__('Monitor view'));
} }
$recursion = get_parameter_switch('recursion', false); $recursion = get_parameter_switch('recursion', false);
@ -191,8 +195,6 @@ if ($id_module) {
$ag_freestring = modules_get_agentmodule_agent_alias($id_module); $ag_freestring = modules_get_agentmodule_agent_alias($id_module);
} }
enterprise_hook('open_meta_frame');
// Get Groups and profiles from user. // Get Groups and profiles from user.
$user_groups = implode(',', array_keys(users_get_groups(false, 'AR', false))); $user_groups = implode(',', array_keys(users_get_groups(false, 'AR', false)));
@ -2240,8 +2242,6 @@ echo "<div id='monitor_details_window'></div>";
echo '<div id="load-modal-filter" style="display:none"></div>'; echo '<div id="load-modal-filter" style="display:none"></div>';
echo '<div id="save-modal-filter" style="display:none"></div>'; echo '<div id="save-modal-filter" style="display:none"></div>';
enterprise_hook('close_meta_frame');
ui_require_javascript_file('pandora_modules'); ui_require_javascript_file('pandora_modules');
?> ?>

View File

@ -32,6 +32,7 @@ require_once $config['homedir'].'/include/functions_inventory.php';
if (is_ajax() === true) { if (is_ajax() === true) {
$get_csv_url = (bool) get_parameter('get_csv_url'); $get_csv_url = (bool) get_parameter('get_csv_url');
$get_data_basic_info = (bool) get_parameter('get_data_basic_info');
if ($get_csv_url) { if ($get_csv_url) {
// $inventory_module = get_parameter ('module_inventory_general_view', 'all'); // $inventory_module = get_parameter ('module_inventory_general_view', 'all');
@ -109,6 +110,156 @@ if (is_ajax() === true) {
return; return;
} }
if ($get_data_basic_info === true) {
// Datatables offset, limit and order.
$filter = get_parameter('search', []);
$start = (int) get_parameter('start', 0);
$length = (int) get_parameter('length', $config['block_size']);
$order = get_datatable_order();
$id_agent = (int) get_parameter('id_agent', 0);
$params = [
'search' => $filter['value'],
'start' => $start,
'length' => $length,
'order' => $order,
'id_agent' => $id_agent,
];
$data = get_data_basic_info_sql($params);
$count = get_data_basic_info_sql($params, true);
try {
ob_start();
$data = array_reduce(
$data,
function ($carry, $agent) {
// Transforms array of arrays $data into an array
// of objects, making a post-process of certain fields.
$tmp = new stdClass();
$id = $agent['id_agente'];
$tmp->alias = $agent['alias'];
$ip = '<em>'.__('N/A').'</em>';
if (empty($agent['direccion']) === false) {
$ip = $agent['direccion'];
}
$tmp->ip = $ip;
$secondary_ips = '';
foreach (agents_get_addresses($id) as $ip) {
if ($ip !== $agent['direccion']) {
$secondary_ips .= '<span class="left" style="height: 1.3em !important">'.$ip.'</span>';
}
}
$tmp->secondaryIp = $secondary_ips;
$tmp->group = groups_get_name($agent['id_grupo']);
$secondary_groups = enterprise_hook('agents_get_secondary_groups', [$id]);
if (empty($secondary_groups['for_select']) === true) {
$sec_group_data = '<em>'.__('N/A').'</em>';
} else {
$sec_group = [];
foreach ($secondary_groups['for_select'] as $name) {
$sec_group[] = $name;
}
$sec_group_data = implode(', ', $sec_group);
}
$tmp->secondaryGroups = $sec_group_data;
$tmp->os = ui_print_os_icon(
$agent['id_os'],
false,
true,
true,
false,
false,
false,
['class' => 'main_menu_icon invert_filter']
);
$interval = human_time_description_raw($agent['intervalo'], false, 'large');
$last_contact = ui_print_timestamp($agent['ultimo_contacto'], true);
// $last_contact .= ' / '.date_w_fixed_tz($agent['ultimo_contacto_remoto']);
$last_status_change_agent = agents_get_last_status_change($agent['id_agente']);
$time_elapsed = !empty($last_status_change_agent) ? human_time_comparation($last_status_change_agent) : '<em>'.__('N/A').'</em>';
$sql_fields = 'SELECT tcf.name, tcd.description, tcf.is_password_type
FROM tagent_custom_fields tcf
INNER JOIN tagent_custom_data tcd ON tcd.id_field=tcf.id_field
WHERE tcd.id_agent='.$id.' AND tcd.description!=""';
$field_result = db_get_all_rows_sql($sql_fields);
$custom_fields_names = '';
$custom_fields_values = '';
foreach ($field_result as $field) {
$field_name = str_replace(' ', '&nbsp;', io_safe_output($field['name']));
$custom_fields_names .= '<span class="right" style="height: 1.3em !important">'.$field_name.'</span>';
$description = $field['description'];
$password_length = strlen(io_safe_output($field['description']));
$asterisks = '';
if ((int) $field['is_password_type'] === 1) {
for ($i = 0; $i < $password_length; $i++) {
$asterisks .= '&#9679;';
}
$description = $asterisks;
}
$custom_fields_values .= '<span class="left" style="height: 1.3em !important">'.$description.'</span>';
}
$tmp->description = $agent['comentarios'];
$tmp->interval = $interval;
$tmp->lastContact = $last_contact;
$tmp->lastStatusChange = $time_elapsed;
$tmp->customFields = $custom_fields_names;
$tmp->valuesCustomFields = $custom_fields_values;
$carry[] = $tmp;
return $carry;
},
[]
);
// Datatables format: RecordsTotal && recordsfiltered.
echo json_encode(
[
'data' => $data,
'recordsTotal' => $count,
'recordsFiltered' => $count,
]
);
// Capture output.
$response = ob_get_clean();
} catch (\Exception $e) {
echo json_encode(['error' => $e->getMessage()]);
exit;
}
// If not valid, show error with issue.
json_decode($response);
if (json_last_error() == JSON_ERROR_NONE) {
// If valid dump.
echo $response;
} else {
echo json_encode(
['error' => $response]
);
}
return;
}
return; return;
} }
@ -116,13 +267,8 @@ global $config;
check_login(); check_login();
$is_metaconsole = is_metaconsole(); $is_metaconsole = is_metaconsole();
if ($is_metaconsole === true) {
open_meta_frame();
}
if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'], 0, 'AW')) { if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'], 0, 'AW')) {
db_pandora_audit( db_pandora_audit(
AUDIT_LOG_ACL_VIOLATION, AUDIT_LOG_ACL_VIOLATION,
@ -135,6 +281,9 @@ if (! check_acl($config['id_user'], 0, 'AR') && ! check_acl($config['id_user'],
require_once $config['homedir'].'/include/functions_users.php'; require_once $config['homedir'].'/include/functions_users.php';
require_once $config['homedir'].'/include/functions_inventory.php'; require_once $config['homedir'].'/include/functions_inventory.php';
// TODO: Button
// echo "<a href='javascript: get_csv_url(\"".$inventory_module.'",'.$inventory_id_group.','.'"'.$inventory_search_string.'",'.$utimestamp.','.'"'.$inventory_agent.'",'.$order_by_agent.")'><span>".__('Export this list to CSV').'</span>'.html_print_image('images/csv.png', true, ['title' => __('Export this list to CSV')]).'</a>';
// Header. // Header.
ui_print_standard_header( ui_print_standard_header(
__('Inventory'), __('Inventory'),
@ -160,7 +309,7 @@ if (strlen($inventory_agent) == 0) {
$inventory_id_agent = 0; $inventory_id_agent = 0;
} }
$inventory_module = get_parameter('module_inventory_general_view'); $inventory_module = get_parameter('module_inventory_general_view', 'basic');
$inventory_id_group = (int) get_parameter('id_group'); $inventory_id_group = (int) get_parameter('id_group');
$inventory_search_string = (string) get_parameter('search_string'); $inventory_search_string = (string) get_parameter('search_string');
$order_by_agent = (bool) get_parameter('order_by_agent'); $order_by_agent = (bool) get_parameter('order_by_agent');
@ -333,17 +482,15 @@ if (is_metaconsole() === true) {
$filteringFunction = ''; $filteringFunction = '';
} }
echo '<form method="POST" action="index.php?sec=estado&sec2=operation/inventory/inventory" name="form_inventory">'; $searchForm = '<form method="post" action="index.php?sec=estado&sec2=operation/inventory/inventory" name="form_inventory">';
$table = new stdClass(); $table = new stdClass();
$table->width = '100%'; $table->width = '100%';
$table->class = 'databox filters';
$table->size = []; $table->size = [];
$table->size[0] = '120px'; $table->size[0] = '33%';
$table->cellpadding = 0; $table->size[1] = '33%';
$table->cellspacing = 0; $table->size[2] = '33%';
$table->class = 'filter-table-adv';
$table->data = []; $table->data = [];
$table->rowspan[0][4] = 2;
if ($is_metaconsole === true) { if ($is_metaconsole === true) {
// Node select. // Node select.
@ -352,15 +499,29 @@ if ($is_metaconsole === true) {
$nodes[$row['id']] = $row['server_name']; $nodes[$row['id']] = $row['server_name'];
} }
$table->data[-1][0] = '<strong>'.__('Server').'</strong>'; $table->data[-1][0] = html_print_label_input_block(
$table->data[-1][1] = html_print_select($nodes, 'id_server', $id_server, $filteringFunction, __('All'), 0, true, false, true, '', false, 'min-width: 250px; max-width: 300px;'); __('Server'),
html_print_select(
$nodes,
'id_server',
$id_server,
$filteringFunction,
__('All'),
0,
true,
false,
true,
'',
false,
'width:100%;'
)
);
} }
// Group select. // Group select.
$table->data[0][0] = '<strong>'.__('Group').'</strong>'; $table->data[0][0] = html_print_label_input_block(
__('Group'),
$table->data[0][1] = '<div class="w250px">'; html_print_select_groups(
$table->data[0][1] .= html_print_select_groups(
$config['id_user'], $config['id_user'],
$access, $access,
true, true,
@ -374,15 +535,25 @@ $table->data[0][1] .= html_print_select_groups(
true, true,
'', '',
false false
)
); );
$table->data[0][1] .= '</div>';
// Module selected.
$table->data[0][2] = '<strong>'.__('Module').'</strong>';
if ($is_metaconsole === true) { if ($is_metaconsole === true) {
array_unshift($fields, __('All')); array_unshift($fields, __('All'));
$table->data[0][3] = html_print_select($fields, 'module_inventory_general_view', $inventory_module, $filteringFunction, __('Basic info'), 'basic', true, false, true, '', false, 'min-width: 194px; max-width: 200px;'); $module_input = html_print_select(
$fields,
'module_inventory_general_view',
$inventory_module,
$filteringFunction,
__('Basic info'),
'basic',
true,
false,
true,
'',
false,
'width:100%;'
);
} else { } else {
$sql = 'SELECT name as indexname, name $sql = 'SELECT name as indexname, name
FROM tmodule_inventory, tagent_module_inventory FROM tmodule_inventory, tagent_module_inventory
@ -404,13 +575,22 @@ if ($is_metaconsole === true) {
} }
array_unshift($fields, __('All')); array_unshift($fields, __('All'));
$table->data[0][3] = html_print_select($fields, 'module_inventory_general_view', $inventory_module, '', __('Basic info'), 'basic', true, false, false); $module_input = html_print_select(
$fields,
'module_inventory_general_view',
$inventory_module,
'',
__('Basic info'),
'basic',
true,
false,
false,
'',
false,
'width:100%;'
);
} }
// Button of submit.
$table->data[0][4] = html_print_submit_button(__('Search'), 'submit_filter', $noFilterSelected, "class='sub search'", true);
// Agent select. // Agent select.
if ($is_metaconsole === false) { if ($is_metaconsole === false) {
$agents = []; $agents = [];
@ -436,8 +616,6 @@ if ($is_metaconsole === false) {
} }
} }
$table->data[1][0] = '<strong>'.__('Agent').'</strong>';
$params = []; $params = [];
$params['return'] = true; $params['return'] = true;
$params['show_helptip'] = true; $params['show_helptip'] = true;
@ -459,27 +637,109 @@ if ($is_metaconsole === true) {
$params['metaconsole_enabled'] = true; $params['metaconsole_enabled'] = true;
} }
$table->data[1][1] = ui_print_agent_autocomplete_input($params); $table->data[0][1] = html_print_label_input_block(
__('Agent'),
ui_print_agent_autocomplete_input($params)
);
// Module selected.
$table->data[0][2] = html_print_label_input_block(
__('Module'),
$module_input
);
// String search_string. // String search_string.
$table->data[1][2] = '<strong>'.__('Search').'</strong>'; $table->data[1][0] = html_print_label_input_block(
$table->data[1][3] = html_print_input_text('search_string', $inventory_search_string, '', 25, 0, true, false, false, '', '', $filteringFunction, 'off', false, $filteringFunction); __('Search'),
html_print_input_text(
'search_string',
$inventory_search_string,
'',
25,
0,
true,
false,
false,
'',
'',
$filteringFunction,
'off',
false,
$filteringFunction
)
);
// Order by agent filter.
$table->data[1][1] = html_print_label_input_block(
__('Order by agent'),
html_print_checkbox(
'order_by_agent',
1,
$order_by_agent,
true,
false,
''
)
);
// Date filter. In Metaconsole has not reason for show. // Date filter. In Metaconsole has not reason for show.
if (is_metaconsole() === false) { if (is_metaconsole() === false) {
$table->data[2][0] = '<strong>'.__('Date').'</strong>'; $dates = inventory_get_dates(
$dates = inventory_get_dates($inventory_module, $inventory_agent, $inventory_id_group); $inventory_module,
$table->data[2][1] = html_print_select($dates, 'utimestamp', $utimestamp, '', __('Last'), 0, true); $inventory_agent,
$inventory_id_group
);
$table->data[1][2] = html_print_label_input_block(
__('Date'),
html_print_select(
$dates,
'utimestamp',
$utimestamp,
'',
__('Last'),
0,
true,
false,
true,
'',
false,
'width:100%;'
)
);
} }
// Order by agent filter. $searchForm .= html_print_table($table, true);
$table->data[2][2] = '<strong>'.__('Order by agent').'</strong>'; $searchForm .= html_print_div(
[
'class' => 'action-buttons',
'content' => html_print_submit_button(
__('Filter'),
'srcbutton',
false,
[
'icon' => 'search',
'mode' => 'mini',
],
true
),
],
true
);
$table->data[2][3] = html_print_checkbox('order_by_agent', 1, $order_by_agent, true, false, ''); $searchForm .= '</form>';
html_print_table($table); ui_toggle(
$searchForm,
echo '</form>'; '<span class="subsection_header_title">'.__('Filters').'</span>',
'filter_form',
'',
true,
false,
'',
'white-box-content',
'box-flat white_table_graph fixed_filter_bar'
);
if ($is_metaconsole === false) { if ($is_metaconsole === false) {
// Single agent selected. // Single agent selected.
@ -507,9 +767,6 @@ if ($is_metaconsole === false) {
return; return;
} }
echo "<div id='url_csv' style='width: ".$table->width.";' class='inventory_table_buttons'>";
echo "<a href='javascript: get_csv_url(\"".$inventory_module.'",'.$inventory_id_group.','.'"'.$inventory_search_string.'",'.$utimestamp.','.'"'.$inventory_agent.'",'.$order_by_agent.")'><span>".__('Export this list to CSV').'</span>'.html_print_image('images/csv.png', true, ['title' => __('Export this list to CSV')]).'</a>';
echo '</div>';
echo "<div id='loading_url' style='display: none; width: ".$table->width."; text-align: right;'>".html_print_image('images/spinner.gif', true).'</div>'; echo "<div id='loading_url' style='display: none; width: ".$table->width."; text-align: right;'>".html_print_image('images/spinner.gif', true).'</div>';
?> ?>
<script type="text/javascript"> <script type="text/javascript">
@ -544,9 +801,9 @@ if ($is_metaconsole === false) {
if ($inventory_module !== 'basic') { if ($inventory_module !== 'basic') {
if ($order_by_agent === true) { if ($order_by_agent === true) {
foreach ($rows as $agent_rows) { foreach ($rows as $agent_rows) {
foreach ($agent_rows['row'] as $row) {
$data = []; $data = [];
$modules = '';
foreach ($agent_rows['row'] as $key_row => $row) {
$columns = explode(';', io_safe_output($row['data_format'])); $columns = explode(';', io_safe_output($row['data_format']));
array_push($columns, 'Timestamp'); array_push($columns, 'Timestamp');
@ -570,7 +827,7 @@ if ($is_metaconsole === false) {
} }
} }
$id_table = 'id_'.$row['id_module_inventory']; $id_table = 'id_'.$key_row.'_'.$row['id_module_inventory'].'_'.$row['id_agente'];
$table = ui_print_datatable( $table = ui_print_datatable(
[ [
@ -582,7 +839,7 @@ if ($is_metaconsole === false) {
'no_sortable_columns' => [], 'no_sortable_columns' => [],
'data_element' => $data, 'data_element' => $data,
'searching' => true, 'searching' => true,
'dom_elements' => 'lftip', 'dom_elements' => 'ftip',
'order' => [ 'order' => [
'field' => $columns[0], 'field' => $columns[0],
'direction' => 'asc', 'direction' => 'asc',
@ -629,35 +886,37 @@ if ($is_metaconsole === false) {
); );
} }
} else { } else {
$count_rows = count($rows);
foreach ($rows as $module_rows) { foreach ($rows as $module_rows) {
$agent = ''; $agent = '';
$data = [];
foreach ($module_rows as $row) { foreach ($module_rows as $row) {
$columns = explode(';', io_safe_output($row['data_format'])); $columns = explode(';', io_safe_output($row['data_format']));
array_push($columns, 'Timestamp'); array_push($columns, 'Timestamp');
$data = []; array_push($columns, 'Agent');
$data_explode = explode(PHP_EOL, $row['data']);
foreach ($data_explode as $values) {
// Exclude results don't match filter. // Exclude results don't match filter.
if ($inventory_search_string && preg_match('/'.io_safe_output($inventory_search_string).'/', ($values)) == 0) { if ($inventory_search_string && preg_match('/'.io_safe_output($inventory_search_string).'/', ($row['data'])) == 0) {
continue; continue;
} }
$data_tmp = []; $data_tmp = [];
if ($values !== '') { if ($row['data'] !== '') {
$values_explode = explode(';', io_safe_output($values)); $values_explode = explode(';', io_safe_output($row['data']));
foreach ($values_explode as $key => $value) { foreach ($values_explode as $key => $value) {
$data_tmp[$columns[$key]] = $value; $data_tmp[$columns[$key]] = $value;
} }
$data_tmp['Timestamp'] = $row['timestamp']; $data_tmp['Timestamp'] = $row['timestamp'];
$data_tmp['Agent'] = $row['name_agent'];
array_push($data, $data_tmp); array_push($data, $data_tmp);
} }
}
$id_table = 'id_'.$row['id_module_inventory']; $id_table = 'id_'.$row['id_module_inventory'];
}
$table = ui_print_datatable( $table = ui_print_datatable(
[ [
@ -669,7 +928,7 @@ if ($is_metaconsole === false) {
'no_sortable_columns' => [], 'no_sortable_columns' => [],
'data_element' => $data, 'data_element' => $data,
'searching' => true, 'searching' => true,
'dom_elements' => 'lftip', 'dom_elements' => 'ftip',
'order' => [ 'order' => [
'field' => $columns[0], 'field' => $columns[0],
'direction' => 'asc', 'direction' => 'asc',
@ -677,58 +936,57 @@ if ($is_metaconsole === false) {
'zeroRecords' => __('No inventory found'), 'zeroRecords' => __('No inventory found'),
'emptyTable' => __('No inventory found'), 'emptyTable' => __('No inventory found'),
'return' => true, 'return' => true,
'default_pagination' => 10, 'no_sortable_columns' => [],
'no_sortable_columns' => [-1],
] ]
); );
$agent .= ui_toggle( if ($count_rows > 1) {
$table,
'<span class="title-blue">'.$row['name_agent'].'</span>',
'',
'',
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( ui_toggle(
$agent, $table,
$module_rows[0]['name'], array_shift($module_rows)['name'],
'', '',
'', '',
false, false,
false false
); );
} else {
echo $table;
html_print_action_buttons(
'',
['type' => 'form_action']
);
}
} }
} }
} else { } else {
$id_agente = $inventory_id_agent; $id_agente = $inventory_id_agent;
$agentes = []; $agentes = [];
$data = []; $data = [];
$class = 'info_table w100p'; $class = 'info_table';
$style = 'width: 100%'; $style = 'width: 99%';
$ordering = false; $ordering = true;
$searching = false; $searching = false;
$dom = 't';
$columns = [ $columns = [
'alias',
'ip',
'secondoaryIp',
'group',
'secondaryGroups',
'description',
'os',
'interval',
'lastContact',
'lastStatusChange',
'customFields',
'valuesCustomFields',
];
$columns_names = [
__('Alias'), __('Alias'),
__('IP'), __('IP'),
__("IP's Secondary"), __('Secondary IP'),
__('Group'), __('Group'),
__('Secondary groups'), __('Secondary groups'),
__('Description'), __('Description'),
@ -739,134 +997,38 @@ if ($is_metaconsole === false) {
__('Custom fields'), __('Custom fields'),
__('Values Custom Fields'), __('Values Custom Fields'),
]; ];
if ((int) $id_agente === 0) {
$class = 'databox info_table w100p';
$style = 'width: 99%';
$ordering = true;
$searching = true;
$dom = 'lftipB';
$agentes = db_get_all_rows_sql('SELECT id_agente FROM tagente');
} else {
array_push($agentes, $id_agente);
}
foreach ($agentes as $id) { ui_print_datatable(
if ((int) $id_agente === 0) {
$id = $id['id_agente'];
}
$agent = db_get_row('tagente', 'id_agente', $id);
$ip = '<em>'.__('N/A').'</em>';
if (empty($agent['direccion']) === false) {
$ip = $agent['direccion'];
}
$secondary_ips = '';
foreach (agents_get_addresses($id) as $ip) {
if ($ip !== $agent['direccion']) {
$secondary_ips .= '<span class="left" style="height: 1.3em !important">'.$ip.'</span>';
}
}
$group = groups_get_name($agent['id_grupo']);
$secondary_groups = enterprise_hook('agents_get_secondary_groups', [$id]);
if (empty($secondary_groups['for_select']) === true) {
$sec_group_data = '<em>'.__('N/A').'</em>';
} else {
$sec_group = [];
foreach ($secondary_groups['for_select'] as $name) {
$sec_group[] = $name;
}
$sec_group_data = implode(', ', $sec_group);
}
$os = ui_print_os_icon($agent['id_os'], false, true).' ';
$os .= io_safe_output(get_os_name($agent['id_os'])).' '.io_safe_output($agent['os_version']);
$interval = human_time_description_raw($agent['intervalo'], false, 'large');
$last_contact = ui_print_timestamp($agent['ultimo_contacto'], true);
// $last_contact .= ' / '.date_w_fixed_tz($agent['ultimo_contacto_remoto']);
$last_status_change_agent = agents_get_last_status_change($agent['id_agente']);
$time_elapsed = !empty($last_status_change_agent) ? human_time_comparation($last_status_change_agent) : '<em>'.__('N/A').'</em>';
$sql_fields = 'SELECT tcf.name, tcd.description, tcf.is_password_type
FROM tagent_custom_fields tcf
INNER JOIN tagent_custom_data tcd ON tcd.id_field=tcf.id_field
WHERE tcd.id_agent='.$id.' AND tcd.description!=""';
$field_result = db_get_all_rows_sql($sql_fields);
$custom_fields_names = '';
$custom_fields_values = '';
foreach ($field_result as $field) {
$field_name = str_replace(' ', '&nbsp;', io_safe_output($field['name']));
$custom_fields_names .= '<span class="right" style="height: 1.3em !important">'.$field_name.'</span>';
$description = $field['description'];
$password_length = strlen(io_safe_output($field['description']));
$asterisks = '';
if ((int) $field['is_password_type'] === 1) {
for ($i = 0; $i < $password_length; $i++) {
$asterisks .= '&#9679;';
}
$description = $asterisks;
}
$custom_fields_values .= '<span class="left" style="height: 1.3em !important">'.$description.'</span>';
}
$data_tmp = [
__('Alias') => $agent['alias'],
__('IP') => $ip,
__("IP's Secondary") => $secondary_ips,
__('Group') => $group,
__('Secondary groups') => $sec_group_data,
__('Description') => $agent['comentarios'],
__('OS') => $os,
__('Interval') => $interval,
__('Last contact') => $last_contact,
__('Last status change') => $time_elapsed,
__('Custom fields') => $custom_fields_names,
__('Values Custom Fields') => $custom_fields_values,
];
array_push($data, $data_tmp);
}
$table = ui_print_datatable(
[ [
'id' => 'basic_info', 'id' => 'basic_info',
'class' => $class, 'class' => $class,
'style' => $style, 'style' => $style,
'columns' => $columns, 'columns' => $columns,
'column_names' => $columns, 'column_names' => $columns_names,
'ordering' => $ordering, 'ordering' => $ordering,
'data_element' => $data,
'searching' => $searching, 'searching' => $searching,
'dom_elements' => $dom,
'order' => [ 'order' => [
'field' => $columns[0], 'field' => $columns[0],
'direction' => 'asc', 'direction' => 'asc',
], ],
'ajax_url' => 'operation/inventory/inventory',
'ajax_data' => [
'get_data_basic_info' => 1,
'id_agent' => $id_agente,
],
'zeroRecords' => __('Agent info not found'), 'zeroRecords' => __('Agent info not found'),
'emptyTable' => __('Agent info not found'), 'emptyTable' => __('Agent info not found'),
'default_pagination' => 10, 'return' => false,
'return' => true,
] ]
); );
if ((int) $id_agente === 0) {
echo $table;
} else {
echo '<div class="databox">'.$table.'</div>';
}
}
// Metaconsole. html_print_action_buttons(
'',
['type' => 'form_action']
);
}
} else { } else {
// Metaconsole.
if ($inventory_module !== 'basic') { if ($inventory_module !== 'basic') {
if ($order_by_agent === true) { if ($order_by_agent === true) {
$count_nodos_tmp = []; $count_nodos_tmp = [];
@ -1103,7 +1265,7 @@ if ($is_metaconsole === false) {
$columns = [ $columns = [
__('Alias'), __('Alias'),
__('IP'), __('IP'),
__("IP's Secondary"), __('Secondary IP'),
__('Group'), __('Group'),
__('Secondary groups'), __('Secondary groups'),
__('Description'), __('Description'),
@ -1225,7 +1387,7 @@ if ($is_metaconsole === false) {
$data_tmp = [ $data_tmp = [
__('Alias') => $agent['alias'], __('Alias') => $agent['alias'],
__('IP') => $ip, __('IP') => $ip,
__("IP's Secondary") => $secondary_ips, __('Secondary IP') => $secondary_ips,
__('Group') => $group, __('Group') => $group,
__('Secondary groups') => $sec_group_data, __('Secondary groups') => $sec_group_data,
__('Description') => $agent['comentarios'], __('Description') => $agent['comentarios'],
@ -1272,8 +1434,6 @@ if ($is_metaconsole === false) {
echo '<div class="databox">'.$table.'</div>'; echo '<div class="databox">'.$table.'</div>';
} }
} }
close_meta_frame();
} }
ui_require_jquery_file('pandora.controls'); ui_require_jquery_file('pandora.controls');

View File

@ -138,8 +138,6 @@ if ($strict_acl === false) {
} }
} }
enterprise_hook('open_meta_frame');
$header_title = __('Tree view'); $header_title = __('Tree view');
$header_sub_title = __('Sort the agents by %s'); $header_sub_title = __('Sort the agents by %s');
switch ($tab) { switch ($tab) {
@ -206,16 +204,10 @@ $table->data = [];
$table->rowspan = []; $table->rowspan = [];
$table->size = []; $table->size = [];
// if (is_metaconsole() === true) {
// $table->width = '96%';
// $table->cellpadding = '0';
// $table->cellspacing = '0';
// $table->class = 'databox_filters';
// $table->styleTable = 'padding:0px;margin-bottom:0px; ';
// }
// Agent filter. // Agent filter.
$agent_status_arr = []; $agent_status_arr = [];
$agent_status_arr[AGENT_STATUS_ALL] = __('All'); $agent_status_arr[AGENT_STATUS_ALL] = __('All');
// Default. // Default.
$agent_status_arr[AGENT_STATUS_NORMAL] = __('Normal'); $agent_status_arr[AGENT_STATUS_NORMAL] = __('Normal');
$agent_status_arr[AGENT_STATUS_WARNING] = __('Warning'); $agent_status_arr[AGENT_STATUS_WARNING] = __('Warning');
@ -360,11 +352,6 @@ $form_html .= html_print_div(
); );
$form_html .= '</form>'; $form_html .= '</form>';
if (is_metaconsole() === true) {
echo "<div class='view_tree'>";
ui_toggle($form_html, '<span class="subsection_header_title">'.__('Show Options').'</span>');
echo '<br>';
} else {
ui_toggle( ui_toggle(
$form_html, $form_html,
'<span class="subsection_header_title">'.__('Tree search').'</span>', '<span class="subsection_header_title">'.__('Tree search').'</span>',
@ -376,7 +363,6 @@ if (is_metaconsole() === true) {
'white-box-content', 'white-box-content',
'box-flat white_table_graph fixed_filter_bar' 'box-flat white_table_graph fixed_filter_bar'
); );
}
html_print_input_hidden('group-id', $group_id); html_print_input_hidden('group-id', $group_id);
html_print_input_hidden('tag-id', $tag_id); html_print_input_hidden('tag-id', $tag_id);
@ -392,16 +378,7 @@ if (is_metaconsole() === true) {
} }
ui_print_spinner(__('Loading')); ui_print_spinner(__('Loading'));
/*
html_print_image(
'images/spinner.gif',
false,
[
'class' => 'loading_tree',
'style' => 'display: none;',
]
);
*/
html_print_div( html_print_div(
[ [
'id' => 'tree-controller-recipient', 'id' => 'tree-controller-recipient',
@ -413,7 +390,6 @@ if (is_metaconsole() === true) {
echo '</div>'; echo '</div>';
} }
enterprise_hook('close_meta_frame');
$infoHeadTitle = 'Sombra oscura'; $infoHeadTitle = 'Sombra oscura';
?> ?>