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.
$data[5] = '';
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]);
hd($module['statusImageHTML'], true);
// HTML of the server type image.
$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) {
$list[$id_group]['_name_'] = $agent_counter['name'];

View File

@ -718,7 +718,7 @@ function inventory_get_datatable(
}
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'
@ -732,75 +732,61 @@ function inventory_get_datatable(
array_push($where, "tagent_module_inventory.data LIKE '%".$inventory_search_string."%'");
}
$sql = 'SELECT *
FROM tmodule_inventory, tagent_module_inventory
WHERE
'.implode(' AND ', $where).'
ORDER BY tmodule_inventory.id_module_inventory LIMIT '.$offset.', '.$config['block_size'];
$sql_count = 'SELECT COUNT(*)
FROM tmodule_inventory, tagent_module_inventory
WHERE '.implode(' AND ', $where);
$sql = sprintf(
'SELECT tmodule_inventory.*,
tagent_module_inventory.*,
tagente.alias as name_agent
FROM tmodule_inventory
INNER JOIN tagent_module_inventory
ON tmodule_inventory.id_module_inventory = tagent_module_inventory.id_module_inventory
LEFT JOIN tagente
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);
$count = db_get_sql($sql_count);
if ($order_by_agent === false) {
$modules = [];
$module_rows = [];
foreach ($rows as $row) {
array_push($modules, $row['name']);
}
foreach ($modules as $module) {
$rows_tmp = [];
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;
$data_rows = explode(PHP_EOL, $row['data']);
foreach ($data_rows as $data_key => $data_value) {
if (empty($data_value) === false) {
$row['data'] = $data_value;
$modules[$row['name']][$row['name_agent'].'-'.$data_key.'-'.$data_value] = $row;
}
}
}
return $module_rows;
return $modules;
} else {
$agents_rows = [];
$agent_data = [];
$rows_tmp = [];
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;
}
foreach ($agent_data as $id_agent => $rows) {
$agent_name = db_get_value_sql(
'SELECT alias
FROM tagente
WHERE id_agente = '.$id_agent
);
$rows_tmp['agent'] = $agent_name;
$rows_tmp['agent'] = $row['name_agent'];
foreach ($rows as $row) {
if ($utimestamp > 0) {
$data_row = db_get_row_sql(
"SELECT data, timestamp
FROM tagente_datos_inventory
WHERE utimestamp <= '".$utimestamp."'
AND id_agent_module_inventory = ".$row['id_agent_module_inventory'].' ORDER BY utimestamp DESC'
sprintf(
'SELECT `data`,
`timestamp`
FROM tagente_datos_inventory
WHERE utimestamp <= "%s"
AND id_agent_module_inventory = %d
ORDER BY utimestamp DESC',
$utimestamp,
$row['id_agent_module_inventory']
)
);
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)
{
$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 {
// Only profiles that can be viewed by the user.
$group_um = users_get_groups_UM($config['id_user']);
hd($group_um, true);
if (isset($group_um[0]) === true) {
$group_um_string = implode(',', array_keys(users_get_groups($config['id_user'], 'um', true)));
} else {
@ -239,7 +238,6 @@ function profile_print_profile_table($id, $json_profile=false, $return=false, $c
$id,
$group_um_string
);
hd($sql, true);
$result = db_get_all_rows_sql($sql);
}

View File

@ -3728,11 +3728,6 @@ function ui_print_datatable(array $parameters)
$("#'.$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) {
console.error(json.error);
$("#error-'.$table_id.'").html(json.error);
@ -3904,6 +3899,13 @@ function ui_print_datatable(array $parameters)
{ bSortable: false, targets: '.$no_sortable_columns.' }
],
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: [';
foreach ($parameters['datacolumns'] as $data) {
@ -3926,8 +3928,6 @@ function ui_print_datatable(array $parameters)
$("#button-'.$form_id.'_search_bt").click(function (){
dt_'.$table_id.'.draw().page(0)
});
//$(".action_buttons_right_content").html($("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers"));
';
if (isset($parameters['caption']) === true
@ -4407,7 +4407,7 @@ function ui_toggle(
$class_table = '';
if ($id_table !== false) {
$class_table = ' $("#'.$id_table.'_wrapper").addClass("w100p");'."\n";
$class_table = '$("#'.$id_table.'_wrapper").addClass("w100p");'."\n";
}
if ($disableToggle === false) {

View File

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

View File

@ -184,35 +184,27 @@ if ($idAgent != 0) {
$print_agent = true;
if (is_metaconsole() === false) {
// Header.
ui_print_standard_header(
__('Alert detail'),
'images/op_alerts.png',
false,
'',
false,
[],
// Header.
ui_print_standard_header(
__('Alert detail'),
'images/op_alerts.png',
false,
'',
false,
[],
[
[
[
'link' => '',
'label' => __('Monitoring'),
],
[
'link' => '',
'label' => __('Views'),
],
]
);
} else {
ui_meta_print_header(__('Alerts view'));
}
'link' => '',
'label' => __('Monitoring'),
],
[
'link' => '',
'label' => __('Views'),
],
]
);
}
enterprise_hook('open_meta_frame');
$alerts = [];
if ($tab != null) {
@ -237,7 +229,6 @@ if (is_metaconsole() === false) {
[
'title' => __('Standby'),
'text' => __('Standby'),
'style' => 'max-width: 5%;',
],
);
@ -252,7 +243,6 @@ if (is_metaconsole() === false) {
[
'title' => __('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) {
array_push(
$column_names,
[
'text' => 'Module',
'style' => 'min-width: 15%;vertical-align: baseline;',
],
[
'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%;',
]
['text' => 'Module'],
['text' => 'Template'],
['text' => 'Operation'],
['text' => 'Last fired'],
['text' => 'Status']
);
$columns = array_merge(
@ -439,7 +414,7 @@ if ($agent_view_page === true) {
[
'id' => 'alerts_status_datatable',
'class' => 'info_table',
'style' => 'width: 99%',
'style' => 'width: 99%;',
'columns' => $columns,
'column_names' => $column_names,
'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());
echo '</div>';
enterprise_hook('close_meta_frame');
ui_require_css_file('cluetip', 'include/styles/js/');
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');
if (! defined('METACONSOLE')) {
$buttons = [];
$subpage = '';
if (is_metaconsole() === false) {
$section = (string) get_parameter('section', 'view');
$buttons['fields'] = [
@ -89,34 +91,36 @@ if (! defined('METACONSOLE')) {
$buttons['view']['active'] = true;
break;
}
}
// Header.
ui_print_standard_header(
__('Monitor detail').$subpage,
'images/agent.png',
false,
'',
true,
$buttons,
// Header.
ui_print_standard_header(
__('Monitor detail').$subpage,
'images/agent.png',
false,
'',
true,
$buttons,
[
[
[
'link' => '',
'label' => __('Monitoring'),
],
[
'link' => '',
'label' => __('Views'),
],
]
);
'link' => '',
'label' => __('Monitoring'),
],
[
'link' => '',
'label' => __('Views'),
],
]
);
if (is_metaconsole() === false) {
if ($section == 'fields') {
include_once $config['homedir'].'/godmode/agentes/status_monitor_custom_fields.php';
exit();
}
} else {
$section = (string) get_parameter('sec', 'estado');
ui_meta_print_header(__('Monitor view'));
}
$recursion = get_parameter_switch('recursion', false);
@ -191,8 +195,6 @@ if ($id_module) {
$ag_freestring = modules_get_agentmodule_agent_alias($id_module);
}
enterprise_hook('open_meta_frame');
// Get Groups and profiles from user.
$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="save-modal-filter" style="display:none"></div>';
enterprise_hook('close_meta_frame');
ui_require_javascript_file('pandora_modules');
?>

View File

@ -32,6 +32,7 @@ require_once $config['homedir'].'/include/functions_inventory.php';
if (is_ajax() === true) {
$get_csv_url = (bool) get_parameter('get_csv_url');
$get_data_basic_info = (bool) get_parameter('get_data_basic_info');
if ($get_csv_url) {
// $inventory_module = get_parameter ('module_inventory_general_view', 'all');
@ -109,6 +110,156 @@ if (is_ajax() === true) {
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;
}
@ -116,13 +267,8 @@ global $config;
check_login();
$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')) {
db_pandora_audit(
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_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.
ui_print_standard_header(
__('Inventory'),
@ -160,7 +309,7 @@ if (strlen($inventory_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_search_string = (string) get_parameter('search_string');
$order_by_agent = (bool) get_parameter('order_by_agent');
@ -333,17 +482,15 @@ if (is_metaconsole() === true) {
$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->width = '100%';
$table->class = 'databox filters';
$table->size = [];
$table->size[0] = '120px';
$table->cellpadding = 0;
$table->cellspacing = 0;
$table->size[0] = '33%';
$table->size[1] = '33%';
$table->size[2] = '33%';
$table->class = 'filter-table-adv';
$table->data = [];
$table->rowspan[0][4] = 2;
if ($is_metaconsole === true) {
// Node select.
@ -352,37 +499,61 @@ if ($is_metaconsole === true) {
$nodes[$row['id']] = $row['server_name'];
}
$table->data[-1][0] = '<strong>'.__('Server').'</strong>';
$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;');
$table->data[-1][0] = html_print_label_input_block(
__('Server'),
html_print_select(
$nodes,
'id_server',
$id_server,
$filteringFunction,
__('All'),
0,
true,
false,
true,
'',
false,
'width:100%;'
)
);
}
// Group select.
$table->data[0][0] = '<strong>'.__('Group').'</strong>';
$table->data[0][1] = '<div class="w250px">';
$table->data[0][1] .= html_print_select_groups(
$config['id_user'],
$access,
true,
'id_group',
$inventory_id_group,
$filteringFunction,
'',
'1',
true,
false,
true,
'',
false
$table->data[0][0] = html_print_label_input_block(
__('Group'),
html_print_select_groups(
$config['id_user'],
$access,
true,
'id_group',
$inventory_id_group,
$filteringFunction,
'',
'1',
true,
false,
true,
'',
false
)
);
$table->data[0][1] .= '</div>';
// Module selected.
$table->data[0][2] = '<strong>'.__('Module').'</strong>';
if ($is_metaconsole === true) {
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 {
$sql = 'SELECT name as indexname, name
FROM tmodule_inventory, tagent_module_inventory
@ -404,13 +575,22 @@ if ($is_metaconsole === true) {
}
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.
if ($is_metaconsole === false) {
$agents = [];
@ -436,8 +616,6 @@ if ($is_metaconsole === false) {
}
}
$table->data[1][0] = '<strong>'.__('Agent').'</strong>';
$params = [];
$params['return'] = true;
$params['show_helptip'] = true;
@ -459,27 +637,109 @@ if ($is_metaconsole === 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.
$table->data[1][2] = '<strong>'.__('Search').'</strong>';
$table->data[1][3] = html_print_input_text('search_string', $inventory_search_string, '', 25, 0, true, false, false, '', '', $filteringFunction, 'off', false, $filteringFunction);
$table->data[1][0] = html_print_label_input_block(
__('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.
if (is_metaconsole() === false) {
$table->data[2][0] = '<strong>'.__('Date').'</strong>';
$dates = inventory_get_dates($inventory_module, $inventory_agent, $inventory_id_group);
$table->data[2][1] = html_print_select($dates, 'utimestamp', $utimestamp, '', __('Last'), 0, true);
$dates = inventory_get_dates(
$inventory_module,
$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.
$table->data[2][2] = '<strong>'.__('Order by agent').'</strong>';
$searchForm .= html_print_table($table, true);
$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);
echo '</form>';
ui_toggle(
$searchForm,
'<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) {
// Single agent selected.
@ -507,9 +767,6 @@ if ($is_metaconsole === false) {
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>';
?>
<script type="text/javascript">
@ -544,9 +801,9 @@ if ($is_metaconsole === false) {
if ($inventory_module !== 'basic') {
if ($order_by_agent === true) {
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']));
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(
[
@ -582,7 +839,7 @@ if ($is_metaconsole === false) {
'no_sortable_columns' => [],
'data_element' => $data,
'searching' => true,
'dom_elements' => 'lftip',
'dom_elements' => 'ftip',
'order' => [
'field' => $columns[0],
'direction' => 'asc',
@ -629,106 +886,107 @@ if ($is_metaconsole === 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');
$data = [];
array_push($columns, 'Agent');
$data_explode = explode(PHP_EOL, $row['data']);
foreach ($data_explode as $values) {
// Exclude results don't match filter.
if ($inventory_search_string && preg_match('/'.io_safe_output($inventory_search_string).'/', ($values)) == 0) {
continue;
// 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 = [];
if ($values !== '') {
$values_explode = explode(';', io_safe_output($values));
foreach ($values_explode as $key => $value) {
$data_tmp[$columns[$key]] = $value;
}
$data_tmp['Timestamp'] = $row['timestamp'];
array_push($data, $data_tmp);
}
$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' => 'lftip',
'order' => [
'field' => $columns[0],
'direction' => 'asc',
],
'zeroRecords' => __('No inventory found'),
'emptyTable' => __('No inventory found'),
'return' => true,
'default_pagination' => 10,
'no_sortable_columns' => [-1],
]
);
$agent .= ui_toggle(
$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(
$agent,
$module_rows[0]['name'],
'',
'',
false,
false
$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 w100p';
$style = 'width: 100%';
$ordering = false;
$class = 'info_table';
$style = 'width: 99%';
$ordering = true;
$searching = false;
$dom = 't';
$columns = [
'alias',
'ip',
'secondoaryIp',
'group',
'secondaryGroups',
'description',
'os',
'interval',
'lastContact',
'lastStatusChange',
'customFields',
'valuesCustomFields',
];
$columns_names = [
__('Alias'),
__('IP'),
__("IP's Secondary"),
__('Secondary IP'),
__('Group'),
__('Secondary groups'),
__('Description'),
@ -739,134 +997,38 @@ if ($is_metaconsole === false) {
__('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) {
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(
ui_print_datatable(
[
'id' => 'basic_info',
'class' => $class,
'style' => $style,
'columns' => $columns,
'column_names' => $columns,
'ordering' => $ordering,
'data_element' => $data,
'searching' => $searching,
'dom_elements' => $dom,
'order' => [
'id' => 'basic_info',
'class' => $class,
'style' => $style,
'columns' => $columns,
'column_names' => $columns_names,
'ordering' => $ordering,
'searching' => $searching,
'order' => [
'field' => $columns[0],
'direction' => 'asc',
],
'zeroRecords' => __('Agent info not found'),
'emptyTable' => __('Agent info not found'),
'default_pagination' => 10,
'return' => true,
'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,
]
);
if ((int) $id_agente === 0) {
echo $table;
} else {
echo '<div class="databox">'.$table.'</div>';
}
}
// Metaconsole.
html_print_action_buttons(
'',
['type' => 'form_action']
);
}
} else {
// Metaconsole.
if ($inventory_module !== 'basic') {
if ($order_by_agent === true) {
$count_nodos_tmp = [];
@ -1103,7 +1265,7 @@ if ($is_metaconsole === false) {
$columns = [
__('Alias'),
__('IP'),
__("IP's Secondary"),
__('Secondary IP'),
__('Group'),
__('Secondary groups'),
__('Description'),
@ -1225,7 +1387,7 @@ if ($is_metaconsole === false) {
$data_tmp = [
__('Alias') => $agent['alias'],
__('IP') => $ip,
__("IP's Secondary") => $secondary_ips,
__('Secondary IP') => $secondary_ips,
__('Group') => $group,
__('Secondary groups') => $sec_group_data,
__('Description') => $agent['comentarios'],
@ -1272,8 +1434,6 @@ if ($is_metaconsole === false) {
echo '<div class="databox">'.$table.'</div>';
}
}
close_meta_frame();
}
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_sub_title = __('Sort the agents by %s');
switch ($tab) {
@ -206,16 +204,10 @@ $table->data = [];
$table->rowspan = [];
$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_status_arr = [];
$agent_status_arr[AGENT_STATUS_ALL] = __('All');
// Default.
$agent_status_arr[AGENT_STATUS_NORMAL] = __('Normal');
$agent_status_arr[AGENT_STATUS_WARNING] = __('Warning');
@ -360,23 +352,17 @@ $form_html .= html_print_div(
);
$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(
$form_html,
'<span class="subsection_header_title">'.__('Tree search').'</span>',
'tree_search',
false,
true,
false,
'',
'white-box-content',
'box-flat white_table_graph fixed_filter_bar'
);
}
ui_toggle(
$form_html,
'<span class="subsection_header_title">'.__('Tree search').'</span>',
'tree_search',
false,
true,
false,
'',
'white-box-content',
'box-flat white_table_graph fixed_filter_bar'
);
html_print_input_hidden('group-id', $group_id);
html_print_input_hidden('tag-id', $tag_id);
@ -392,16 +378,7 @@ if (is_metaconsole() === true) {
}
ui_print_spinner(__('Loading'));
/*
html_print_image(
'images/spinner.gif',
false,
[
'class' => 'loading_tree',
'style' => 'display: none;',
]
);
*/
html_print_div(
[
'id' => 'tree-controller-recipient',
@ -413,7 +390,6 @@ if (is_metaconsole() === true) {
echo '</div>';
}
enterprise_hook('close_meta_frame');
$infoHeadTitle = 'Sombra oscura';
?>