Merge branch 'ent-9662-second-round' into 'develop'

Ent 9662 second round

See merge request artica/pandorafms!5631
This commit is contained in:
daniel 2023-03-28 15:30:54 +00:00
commit 2c0c213a01
19 changed files with 369 additions and 286 deletions

View File

@ -1455,18 +1455,18 @@ html_print_input_hidden('module_macro_count', $macro_count);
$table_new_relations = new stdClass(); $table_new_relations = new stdClass();
$table_new_relations->id = 'module_new_relations'; $table_new_relations->id = 'module_new_relations';
$table_new_relations->width = '100%'; $table_new_relations->width = '100%';
$table_new_relations->class = 'no-class filter-table-adv'; $table_new_relations->class = 'filter-table-adv';
$table_new_relations->data = []; $table_new_relations->data = [];
$table_new_relations->style = []; $table_new_relations->style = [];
$table_new_relations->size[0] = '25%'; $table_new_relations->size[0] = '33%';
$table_new_relations->size[1] = '25%'; $table_new_relations->size[1] = '33%';
$table_new_relations->size[2] = '25%'; $table_new_relations->size[2] = '33%';
$table_new_relations->size[3] = '25%';
$params = []; $params = [];
$params['return'] = true; $params['return'] = true;
$params['show_helptip'] = true; $params['show_helptip'] = true;
$params['input_name'] = 'autocomplete_agent_name'; $params['input_name'] = 'autocomplete_agent_name';
$params['helptip_text'] = '';
$params['use_hidden_input_idagent'] = true; $params['use_hidden_input_idagent'] = true;
$params['print_hidden_input_idagent'] = true; $params['print_hidden_input_idagent'] = true;
$params['hidden_input_idagent_id'] = 'hidden-autocomplete_id_agent'; $params['hidden_input_idagent_id'] = 'hidden-autocomplete_id_agent';
@ -1476,15 +1476,15 @@ $table_new_relations->data[0][0] = html_print_label_input_block(
ui_print_agent_autocomplete_input($params) ui_print_agent_autocomplete_input($params)
); );
$table_new_relations->data[0][1] = html_print_label_input_block( $table_new_relations->data[0][1] = html_print_label_input_block(
__('Module'), __('Module'),
"<div id='module_autocomplete'></div>" '<div id="module_autocomplete">'.html_print_input_text('', '', '', false, 255, true, true, false, '', 'w100p').'</div>'
); );
$array_rel_type = []; $array_rel_type = [];
$array_rel_type['direct'] = __('Direct'); $array_rel_type['direct'] = __('Direct');
$array_rel_type['failover'] = __('Failover'); $array_rel_type['failover'] = __('Failover');
$table_new_relations->data[0][2] = html_print_label_input_block( $table_new_relations->data[0][2] = html_print_label_input_block(
__('Rel. type'), __('Rel. type'),
html_print_select( html_print_select(
@ -1497,43 +1497,55 @@ $table_new_relations->data[0][2] = html_print_label_input_block(
true, true,
false, false,
true, true,
'' 'w100p',
false,
'width:100%'
) )
); );
$table_new_relations->data[0][3] = html_print_label_input_block( $table_new_relations->data[1][0] = ' ';
'&nbsp;', $table_new_relations->data[1][1] = ' ';
'<div class="inline_line">'.html_print_button( $table_new_relations->cellstyle[1][2] = 'width:100% !important;';
__('Add relationship'), $table_new_relations->cellclass[1][2] = 'flex flex-end';
$table_new_relations->data[1][2] = "<div id='add_relation_status' class='inline_line' style='margin-right:10px'></div>".html_print_button(
__('Add relationship')."<div id='add_relation_status'></div>",
'add_relation', 'add_relation',
false, false,
'javascript: add_new_relation();', 'add_new_relation();',
[ [
'class' => 'w150px secondary', 'class' => 'mini',
'icon' => 'plus', 'icon' => 'next',
'mode' => 'secondary',
'style' => 'margin-top: 10px; margin-right: 10px',
], ],
true true
)."<div id='add_relation_status' class='inline_line'></div></div>"
); );
// Relationship list. // Relationship list.
$table_relations = new stdClass(); $table_relations = new stdClass();
$table_relations->id = 'module_relations'; $table_relations->id = 'module_relations';
$table_relations->width = '100%'; $table_relations->width = '100%';
$table_relations->class = 'databox data'; $table_relations->class = 'info_table';
$table_relations->styleTable = 'border: none';
$table_relations->head = []; $table_relations->head = [];
$table_relations->data = []; $table_relations->data = [];
$table_relations->rowstyle = [];
$table_relations->rowstyle[-1] = 'display: none;'; $table_relations->rowstyle[-1] = 'display: none;';
$table_relations->style = [];
$table_relations->style[3] = 'width: 10%; text-align: center;';
$table_relations->style[4] = 'width: 10%; text-align: center;';
$table_relations->head[0] = __('Agent'); $table_relations->head[0] = __('Agent');
$table_relations->head[1] = __('Module'); $table_relations->head[1] = __('Module');
$table_relations->head[2] = __('Type'); $table_relations->head[2] = __('Type');
$table_relations->head[3] = __('Changes'); $table_relations->head[3] = __('Changes');
$table_relations->head[4] = __('Delete'); $table_relations->head[4] = __('Delete');
$table_relations->headclass[0] = 'w20p';
$table_relations->headclass[1] = 'w20p';
$table_relations->headclass[2] = 'w20p';
$table_relations->headclass[3] = 'w20p';
$table_relations->headclass[4] = 'w20p';
$table_relations->style[0] = 'width:20%';
$table_relations->style[1] = 'width:20%';
$table_relations->style[2] = 'width:20%';
$table_relations->style[3] = 'width:20%';
$table_relations->style[4] = 'width:20%';
// Create an invisible row to use their html to add new rows. // Create an invisible row to use their html to add new rows.
$table_relations->data[-1][0] = ''; $table_relations->data[-1][0] = '';
@ -1565,6 +1577,9 @@ if ($id_agent_module) {
$relations_count = 0; $relations_count = 0;
foreach ($module_relations as $key => $module_relation) { foreach ($module_relations as $key => $module_relation) {
// Styles.
$table_relations->cellclass[$relations_count][4] = 'table_action_buttons';
if ($module_relation['module_a'] == $id_agent_module) { if ($module_relation['module_a'] == $id_agent_module) {
$module_id = $module_relation['module_b']; $module_id = $module_relation['module_b'];
$agent_id = modules_give_agent_id_from_module_id( $agent_id = modules_give_agent_id_from_module_id(
@ -2047,6 +2062,7 @@ function change_modules_autocomplete_input () {
else { else {
module_autocomplete.html(error_icon); module_autocomplete.html(error_icon);
} }
$('#text-autocomplete_module_name').addClass('w90p');
}, },
error: function (data) { error: function (data) {
module_autocomplete.removeClass('working'); module_autocomplete.removeClass('working');
@ -2109,15 +2125,15 @@ function add_new_relation () {
} }
var rowHTML = '<tr id="module_relations-' + relationsCount + '" class="' + rowClass + '">' + var rowHTML = '<tr id="module_relations-' + relationsCount + '" class="' + rowClass + '">' +
'<td id="module_relations-' + relationsCount + '-0"><b>' + agent_b_name + '</b></td>' + '<td style="width:20%" id="module_relations-' + relationsCount + '-0"><b>' + agent_b_name + '</b></td>' +
'<td id="module_relations-' + relationsCount + '-1">' + module_b_name + '</td>' + '<td style="width:20%" id="module_relations-' + relationsCount + '-1">' + module_b_name + '</td>' +
'<td id="module_relations-' + relationsCount + '-2">' + relation_type + '</td>' + '<td style="width:20%" id="module_relations-' + relationsCount + '-2">' + relation_type + '</td>' +
'<td id="module_relations-' + relationsCount + '-3" class="w10p center">' + '<td style="width:20%" id="module_relations-' + relationsCount + '-3">' +
'<a id="disable_updates_button" class="alpha50" href="javascript: change_lock_relation(' + relationsCount + ', ' + data + ');">' + '<a id="disable_updates_button" class="alpha50" href="javascript: change_lock_relation(' + relationsCount + ', ' + data + ');">' +
'<?php echo html_print_image('images/policy@svg.svg', true, ['class' => 'main_menu_icon invert_filter']); ?>' + '<?php echo html_print_image('images/policy@svg.svg', true, ['class' => 'main_menu_icon invert_filter']); ?>' +
'</a>' + '</a>' +
'</td>' + '</td>' +
'<td id="module_relations-' + relationsCount + '-4" class="w10p center">' + '<td style="width:20%" id="module_relations-' + relationsCount + '-4" class="table_action_buttons">' +
'<a id="delete_relation_button" href="javascript: delete_relation(' + relationsCount + ', ' + data + ');">' + '<a id="delete_relation_button" href="javascript: delete_relation(' + relationsCount + ', ' + data + ');">' +
'<?php echo html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']); ?>' + '<?php echo html_print_image('images/delete.svg', true, ['class' => 'main_menu_icon invert_filter']); ?>' +
'</a>' + '</a>' +

View File

@ -71,11 +71,11 @@ $max_graph = $config['max_graph_container'];
$buttons['graph_list'] = [ $buttons['graph_list'] = [
'active' => false, 'active' => false,
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/graphs">'.html_print_image( 'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/graphs">'.html_print_image(
'images/list.png', 'images/logs@svg.svg',
true, true,
[ [
'title' => __('Graph list'), 'title' => __('Graph list'),
'class' => 'invert_filter', 'class' => 'main_menu_icon invert_filter',
] ]
).'</a>', ).'</a>',
]; ];

View File

@ -3557,7 +3557,7 @@ switch ($action) {
$buttons = [ $buttons = [
'list_reports' => [ 'list_reports' => [
'active' => false, 'active' => false,
'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'">'.html_print_image('images/report_list.png', true, ['title' => __('Reports list'), 'class' => 'invert_filter']).'</a>', 'text' => '<a href="index.php?sec=reporting&sec2=godmode/reporting/reporting_builder&pure='.$pure.'">'.html_print_image('images/logs@svg.svg', true, ['title' => __('Reports list'), 'class' => 'invert_filter main_menu_icon']).'</a>',
], ],
]; ];

View File

@ -1045,20 +1045,6 @@ if ($is_management_allowed === true) {
} else { } else {
echo '<i>'.__("The current authentication scheme doesn't support creating users on %s", get_product_name()).'</i>'; echo '<i>'.__("The current authentication scheme doesn't support creating users on %s", get_product_name()).'</i>';
} }
} else {
html_print_action_buttons(
html_print_submit_button(
__('Create user'),
'none',
true,
[ 'icon' => 'wand' ],
true
),
[
'type' => 'form_action',
'right_content' => $tablePagination,
],
);
} }
?> ?>

View File

@ -729,7 +729,9 @@ function load_form_filter() {
$("#current_filter").text($('#filter_id option:selected').text()); $("#current_filter").text($('#filter_id option:selected').text());
// Search. // Search.
dt_events.draw(false); $("#table_events")
.DataTable()
.draw(false);
} }
$(document).ready (function() { $(document).ready (function() {

View File

@ -2566,7 +2566,6 @@ function graphic_agentaccess(
} }
$options = [ $options = [
'width' => 350,
'height' => 125, 'height' => 125,
'colors' => $colors, 'colors' => $colors,
'legend' => ['display' => false], 'legend' => ['display' => false],
@ -4809,20 +4808,6 @@ function graph_nodata_image($options)
{ {
global $config; global $config;
$height = 200;
if (isset($options['height']) === true
&& empty($options['height']) === false
) {
$height = $options['height'];
}
$width_style = 'width: 200px';
if (isset($options['width']) === true
&& empty($options['width']) === false
) {
$width_style = 'width:'.$options['width'].'px';
}
if ($options['base64'] === true) { if ($options['base64'] === true) {
$dataImg = file_get_contents( $dataImg = file_get_contents(
$config['homedir'].'/images/image_problem_area_150.png' $config['homedir'].'/images/image_problem_area_150.png'
@ -4835,7 +4820,7 @@ function graph_nodata_image($options)
true, true,
[ [
'title' => __('No data'), 'title' => __('No data'),
'style' => $width_style, 'style' => 'width: 200px;',
] ]
); );
} }

View File

@ -836,13 +836,19 @@ function get_data_basic_info_sql($params, $count=false)
$order_condition = sprintf('ORDER BY %s', $params['order']); $order_condition = sprintf('ORDER BY %s', $params['order']);
} }
$table = 'tagente';
if (is_metaconsole() === true) {
$table = 'tmetaconsole_agent';
}
$sql = sprintf( $sql = sprintf(
'SELECT %s 'SELECT %s
FROM tagente FROM %s
%s %s
%s %s
%s', %s',
$fields, $fields,
$table,
$where, $where,
$order_condition, $order_condition,
$limit_condition $limit_condition

View File

@ -81,6 +81,12 @@ function menu_print_menu(&$menu)
$sec2 = 'godmode/setup/setup&section=gis'; $sec2 = 'godmode/setup/setup&section=gis';
} else if ($sec2 === 'enterprise/godmode/agentes/agent_autoconfiguration.definition') { } else if ($sec2 === 'enterprise/godmode/agentes/agent_autoconfiguration.definition') {
$sec2 = 'enterprise/godmode/agentes/agent_autoconfiguration'; $sec2 = 'enterprise/godmode/agentes/agent_autoconfiguration';
} else if ($sec2 === 'enterprise/godmode/reporting/graph_template_list') {
$sec2 = 'godmode/reporting/graphs';
} else if ($sec2 === 'enterprise/godmode/reporting/graph_template_wizard') {
$sec2 = 'godmode/reporting/graphs';
} else if ($sec2 === 'godmode/reporting/graph_container') {
$sec2 = 'godmode/reporting/graphs';
} else if ($sec2 === 'operation/gis_maps/render_view') { } else if ($sec2 === 'operation/gis_maps/render_view') {
$map_id = (int) get_parameter('map_id'); $map_id = (int) get_parameter('map_id');
if (empty($map_id) === false) { if (empty($map_id) === false) {

View File

@ -4577,3 +4577,81 @@ function getStatuses()
'normal', 'normal',
]; ];
} }
function policies_type_modules_availables(string $sec2): array
{
$network_available = db_get_sql(
'SELECT count(*)
FROM tserver
WHERE server_type = '.SERVER_TYPE_NETWORK
);
$wmi_available = db_get_sql(
'SELECT count(*)
FROM tserver
WHERE server_type = '.SERVER_TYPE_WMI
);
$plugin_available = db_get_sql(
'SELECT count(*)
FROM tserver
WHERE server_type = '.SERVER_TYPE_PLUGIN
);
$prediction_available = db_get_sql(
'SELECT count(*)
FROM tserver
WHERE server_type = '.SERVER_TYPE_PREDICTION
);
$web_available = db_get_sql(
'SELECT count(*)
FROM tserver
WHERE server_type = '.SERVER_TYPE_WEB
);
if (is_metaconsole()) {
$network_available = 1;
$wmi_available = 1;
$plugin_available = 1;
$prediction_available = 1;
}
$modules = [];
$modules['dataserver'] = __('Create a new data server module');
if ($network_available) {
$modules['networkserver'] = __('Create a new network server module');
}
if ($plugin_available) {
$modules['pluginserver'] = __('Create a new plugin server module');
}
if ($wmi_available) {
$modules['wmiserver'] = __('Create a new WMI server module');
}
if ($prediction_available) {
$modules['predictionserver'] = __('Create a new prediction server module');
}
if (is_metaconsole() === true || $web_available >= '1') {
$modules['webserver'] = __('Create a new web Server module');
}
if (enterprise_installed() === true) {
enterprise_include('godmode/agentes/module_manager.php');
set_enterprise_module_types($modules);
}
if (strstr($sec2, 'enterprise/godmode/policies/policies') !== false) {
// It is unset because the policies haven't a table tmodule_synth and the
// some part of code to apply this kind of modules in policy agents.
// But in the future maybe will be good to make this feature, but remember
// the modules to show in syntetic module policy form must be the policy
// modules from the same policy.
unset($modules['predictionserver']);
if (enterprise_installed() === true) {
unset($modules['webux']);
}
}
return $modules;
}

View File

@ -921,7 +921,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
false, false,
'', '',
'white-box-content mrgn_top_0 mrgn_btn_0px border-bottom-gray', 'white-box-content mrgn_top_0 mrgn_btn_0px border-bottom-gray',
'white_table_flex' 'white_table_flex margin-bottom-20'
); );
if (empty($server_data) === false && is_metaconsole() === true) { if (empty($server_data) === false && is_metaconsole() === true) {
@ -951,7 +951,7 @@ function treeview_printTable($id_agente, $server_data=[], $no_head=false)
type: 'hidden', type: 'hidden',
id: 'graph-counter', id: 'graph-counter',
value: 1 value: 1
}).appendTo('#container'); }).appendTo('body');
if ($('#graph-counter').val() == 1) { if ($('#graph-counter').val() == 1) {

View File

@ -3760,7 +3760,7 @@ function ui_print_datatable(array $parameters)
// Base table. // Base table.
$table = '<table id="'.$table_id.'" '; $table = '<table id="'.$table_id.'" ';
$table .= 'class="'.$parameters['class'].'"'; $table .= 'class="'.$parameters['class'].' invisible"';
$table .= 'style="'.$parameters['style'].'">'; $table .= 'style="'.$parameters['style'].'">';
$table .= '<thead><tr class="datatables_thead_tr">'; $table .= '<thead><tr class="datatables_thead_tr">';
@ -4027,6 +4027,7 @@ function ui_print_datatable(array $parameters)
$(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dataTables_length")); $(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dataTables_length"));
$(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dt-buttons")); $(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dt-buttons"));
$(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dataTables_filter")); $(".pagination-child-div").append($("#'.$table_id.'_wrapper > .dataTables_filter"));
$("div.spinner-fixed").hide();
}, },
columns: ['; columns: [';
@ -4070,6 +4071,15 @@ function ui_print_datatable(array $parameters)
} }
$js .= '});'; $js .= '});';
$js .= '
$(function() {
$(document).on("preInit.dt", function (ev, settings) {
// $("table#'.$table_id.'").hide();
$("div.dataTables_length").hide();
$("div.dt-buttons").hide();
});
});
';
$js .= '</script>'; $js .= '</script>';
@ -4078,9 +4088,11 @@ function ui_print_datatable(array $parameters)
$info_msg_arr['message'] = $emptyTable; $info_msg_arr['message'] = $emptyTable;
$info_msg_arr['div_class'] = 'info_box_container invisible_important datatable-msg-info-'.$table_id; $info_msg_arr['div_class'] = 'info_box_container invisible_important datatable-msg-info-'.$table_id;
$spinner = '<div class="spinner-fixed"><span></span><span></span><span></span><span></span></div>';
$info_msg = '<div>'.ui_print_info_message($info_msg_arr).'</div>'; $info_msg = '<div>'.ui_print_info_message($info_msg_arr).'</div>';
$err_msg = '<div id="error-'.$table_id.'"></div>'; $err_msg = '<div id="error-'.$table_id.'"></div>';
$output = $info_msg.$err_msg.$filter.$extra.$table.$js; $output = $info_msg.$err_msg.$filter.$extra.$spinner.$table.$js;
if (is_ajax() === false) { if (is_ajax() === false) {
ui_require_css_file('datatables.min', 'include/styles/js/'); ui_require_css_file('datatables.min', 'include/styles/js/');
ui_require_css_file('tables'); ui_require_css_file('tables');

View File

@ -652,13 +652,10 @@ var TreeController = {
typeof element.icon != "undefined" && typeof element.icon != "undefined" &&
element.icon.length > 0 element.icon.length > 0
) { ) {
console.log("a");
console.log(controller);
$content.append( $content.append(
'<div class="node-icon"><div class="node-icon-container"><img src="' + '<div class="node-icon"><div class="node-icon-container"><img src="' +
(controller.baseURL.length > 0 ? controller.baseURL : "") + (controller.baseURL.length > 0 ? controller.baseURL : "") +
(treeController.meta != undefined && (controller.meta != undefined && controller.meta == 1
treeController.meta == 1
? "../../images/" ? "../../images/"
: "images/") + : "images/") +
element.icon + element.icon +

View File

@ -54,11 +54,6 @@ form.flex-row div.filter_input.large {
max-width: 100%; max-width: 100%;
} }
div.filter_input > label,
div.filter_input_little > label {
width: 10em;
}
form.flex-row > ul, form.flex-row > ul,
form.flex-row > ul > li, form.flex-row > ul > li,
form.flex-row > .box-shadow.white_table_graph { form.flex-row > .box-shadow.white_table_graph {
@ -504,7 +499,7 @@ div.multi-response-buttons {
} }
.events-refr { .events-refr {
width: 350px; width: 300px;
display: flex; display: flex;
align-items: center; align-items: center;
flex-direction: row-reverse; flex-direction: row-reverse;
@ -529,3 +524,29 @@ td#save_filter_form-0-1 > input[type="radio"] {
.module-search > input[type="text"] { .module-search > input[type="text"] {
margin-bottom: 6px; margin-bottom: 6px;
} }
div.agent-min-w100p > span {
width: 400px;
}
.events-pure {
display: block;
position: initial;
border-radius: 0px;
}
.events-pure > .white_table_graph_header {
height: 45px;
}
div.menu_tab_pure {
margin-top: 0px !important;
}
div#main_pure:has(.events-pure) {
width: 99%;
}
.margn-b-50px {
margin-bottom: 50px !important;
}

View File

@ -11743,6 +11743,70 @@ div.relative > div > div#ui-datepicker-div {
width: 400px; width: 400px;
} }
#module_relations > thead > tr {
border: none !important;
border-bottom: 1px solid #e2e2e2 !important;
}
span.help_icon_15px > img { span.help_icon_15px > img {
height: 15px !important; height: 15px !important;
} }
.select2-dropdown {
z-index: 1116 !important;
}
/* ==== Spinner ==== */
.spinner-fixed {
position: fixed;
left: 50%;
bottom: 50%;
z-index: 1;
width: 100px;
height: 100px;
border-radius: 100%;
background: linear-gradient(#82b92e, #c1ccdc);
animation: animate 1.2s linear infinite;
margin: auto;
margin-bottom: 40px;
}
.spinner-fixed span {
position: absolute;
width: 100%;
height: 100%;
border-radius: 100%;
background: linear-gradient(#82b92e, #c1ccdc);
}
.spinner-fixed span:nth-child(1) {
filter: blur(4px);
}
.spinner-fixed span:nth-child(2) {
filter: blur(8px);
}
.spinner-fixed span:nth-child(3) {
filter: blur(12px);
}
.spinner-fixed span:nth-child(4) {
filter: blur(16px);
}
.spinner-fixed:after {
content: "";
position: absolute;
top: 10px;
left: 10px;
right: 10px;
bottom: 10px;
/* background: transparent; */
background: #f1f1f1;
border: solid #fff 10px;
border-radius: 50%;
}
@keyframes animate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

View File

@ -276,8 +276,8 @@ if ((bool) check_acl($config['id_user'], $id_group, 'AW') === true || (bool) che
['text' => 'Module'], ['text' => 'Module'],
['text' => 'Template'], ['text' => 'Template'],
[ [
'title' => __('Actions'), 'title' => __('Action'),
'text' => __('Actions'), 'text' => __('Action'),
'style' => 'min-width: 15%;', 'style' => 'min-width: 15%;',
], ],
['text' => 'Last fired'], ['text' => 'Last fired'],
@ -288,7 +288,7 @@ if ((bool) check_acl($config['id_user'], $id_group, 'AW') === true || (bool) che
$columns, $columns,
['agent_module_name'], ['agent_module_name'],
['template_name'], ['template_name'],
['actions'], ['action'],
['last_fired'], ['last_fired'],
['status'] ['status']
); );
@ -326,14 +326,14 @@ if (is_metaconsole() === true) {
1, 1,
2, 2,
3, 3,
7, -1,
]; ];
} else { } else {
$no_sortable_columns = [ $no_sortable_columns = [
0, 0,
1, 1,
2, 2,
6, -1,
]; ];
} }
} }

View File

@ -1376,7 +1376,7 @@ if ($pure) {
// Floating menu - Start. // Floating menu - Start.
echo '<div id="vc-controls" class="zindex999"">'; echo '<div id="vc-controls" class="zindex999"">';
echo '<div id="menu_tab">'; echo '<div id="menu_tab" class="menu_tab_pure">';
echo '<ul class="mn">'; echo '<ul class="mn">';
// Quit fullscreen. // Quit fullscreen.
@ -1922,7 +1922,7 @@ if ($id_agent !== null) {
} }
$data = ui_print_agent_autocomplete_input($params); $data = ui_print_agent_autocomplete_input($params);
$in = '<div class="filter_input"><label>'.__('Agent search'); $in = '<div class="filter_input agent-min-w100p"><label>'.__('Agent search');
$in .= '</label>'.$data.'</div>'; $in .= '</label>'.$data.'</div>';
$adv_inputs[] = $in; $adv_inputs[] = $in;
@ -2490,7 +2490,7 @@ try {
'drawCallback' => 'process_datatables_callback(this, settings)', 'drawCallback' => 'process_datatables_callback(this, settings)',
'print' => false, 'print' => false,
'csv' => 0, 'csv' => 0,
'filter_main_class' => 'box-flat white_table_graph fixed_filter_bar '.$show_hide_filters, 'filter_main_class' => 'events-pure box-flat white_table_graph fixed_filter_bar '.$show_hide_filters,
], ],
), ),
] ]
@ -3119,6 +3119,7 @@ $(document).ready( function() {
//Autorefresh in fullscreen //Autorefresh in fullscreen
var pure = '<?php echo $pure; ?>'; var pure = '<?php echo $pure; ?>';
var pure = '<?php echo $pure; ?>';
if(pure == 1){ if(pure == 1){
var refresh_interval = parseInt('<?php echo($config['refr'] * 1000); ?>'); var refresh_interval = parseInt('<?php echo($config['refr'] * 1000); ?>');
var until_time=''; var until_time='';
@ -3138,7 +3139,9 @@ $(document).ready( function() {
layout: '(%M%nn%M:%S%nn%S <?php echo __('Until next'); ?>)', layout: '(%M%nn%M:%S%nn%S <?php echo __('Until next'); ?>)',
labels: ['', '', '', '', '', '', ''], labels: ['', '', '', '', '', '', ''],
onExpiry: function () { onExpiry: function () {
dt_events.draw(false); $("#table_events")
.DataTable()
.draw(false);
} }
}); });
} }
@ -3148,7 +3151,7 @@ $(document).ready( function() {
setInterval(events_refresh, refresh_interval); setInterval(events_refresh, refresh_interval);
$("select#refresh").change (function () { $("select#refresh").on('select2:select', function () {
var href = window.location.href; var href = window.location.href;
inputs = $("#events_form :input"); inputs = $("#events_form :input");
@ -3172,6 +3175,13 @@ $(document).ready( function() {
$(document).attr("location", href); $(document).attr("location", href);
}); });
$("div.events-pure").removeClass("fixed_filter_bar invisible");
$("div#principal_action_buttons").addClass("w100p");
$("table#table_events").addClass("margn-b-50px");
$('#refresh').val('<?php echo $config['refr']; ?>').trigger('change');
} }
}); });
@ -3213,10 +3223,6 @@ function show_instructions(id){
} }
$(document).ready(function () { $(document).ready(function () {
let agentLabel = $('#text-text_agent').prev();
let agentTip = $('#text-text_agent').next();
agentLabel.append(agentTip);
let moduleLabel = $('#text-module_search').prev(); let moduleLabel = $('#text-module_search').prev();
let moduleTip = $('#text-module_search').next().next(); let moduleTip = $('#text-module_search').next().next();
moduleLabel.append(moduleTip); moduleLabel.append(moduleTip);

View File

@ -26,6 +26,8 @@
* ============================================================================ * ============================================================================
*/ */
use PandoraFMS\Enterprise\Metaconsole\Node;
// Begin. // Begin.
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';
@ -131,7 +133,6 @@ if (is_ajax() === true) {
try { try {
ob_start(); ob_start();
$data = array_reduce( $data = array_reduce(
$data, $data,
function ($carry, $agent) { function ($carry, $agent) {
@ -139,9 +140,16 @@ if (is_ajax() === true) {
// of objects, making a post-process of certain fields. // of objects, making a post-process of certain fields.
$tmp = new stdClass(); $tmp = new stdClass();
$tmp->alias = '';
if (is_metaconsole() === true) {
$server = metaconsole_get_connection_by_id($agent['id_tmetaconsole_setup']);
metaconsole_connect($server);
$tmp->alias .= $server['server_name'].' &raquo; ';
}
$id = $agent['id_agente']; $id = $agent['id_agente'];
$tmp->alias = $agent['alias']; $tmp->alias .= $agent['alias'];
$ip = '<em>'.__('N/A').'</em>'; $ip = '<em>'.__('N/A').'</em>';
if (empty($agent['direccion']) === false) { if (empty($agent['direccion']) === false) {
$ip = $agent['direccion']; $ip = $agent['direccion'];
@ -225,6 +233,10 @@ if (is_ajax() === true) {
$tmp->customFields = $custom_fields_names; $tmp->customFields = $custom_fields_names;
$tmp->valuesCustomFields = $custom_fields_values; $tmp->valuesCustomFields = $custom_fields_values;
if (is_metaconsole() === true) {
metaconsole_restore_db();
}
$carry[] = $tmp; $carry[] = $tmp;
return $carry; return $carry;
}, },
@ -457,31 +469,6 @@ $agent_a = (bool) check_acl($config['id_user'], 0, 'AR');
$agent_w = (bool) check_acl($config['id_user'], 0, 'AW'); $agent_w = (bool) check_acl($config['id_user'], 0, 'AW');
$access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR'); $access = ($agent_a === true) ? 'AR' : (($agent_w === true) ? 'AW' : 'AR');
if (is_metaconsole() === true) {
$filteringFunction = 'active_inventory_submit()';
ui_print_info_message(['no_close' => true, 'message' => __('You must select at least one filter.'), 'force_class' => 'select_one_filter']);
?>
<script type="text/javascript">
function active_inventory_submit() {
if (
$("#id_group").val() == 0 &&
$("#id_server").val() == 0 &&
$("#module_inventory_general_view").val() == 0 &&
$("#text-search_string").val() === ''
) {
$("#submit-submit_filter").attr("disabled", true);
$(".select_one_filter").css("display", "table");
} else {
$("#submit-submit_filter").attr("disabled", false);
$(".select_one_filter").css("display", "none");
}
}
</script>
<?php
} else {
$filteringFunction = '';
}
$searchForm = '<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%';
@ -741,6 +728,31 @@ ui_toggle(
'box-flat white_table_graph fixed_filter_bar' 'box-flat white_table_graph fixed_filter_bar'
); );
if (is_metaconsole() === true) {
$filteringFunction = 'active_inventory_submit()';
ui_print_info_message(['no_close' => true, 'message' => __('You must select at least one filter.'), 'force_class' => 'select_one_filter']);
?>
<script type="text/javascript">
function active_inventory_submit() {
if (
$("#id_group").val() == 0 &&
$("#id_server").val() == 0 &&
$("#module_inventory_general_view").val() == 0 &&
$("#text-search_string").val() === ''
) {
$("#submit-submit_filter").attr("disabled", true);
$(".select_one_filter").css("display", "table");
} else {
$("#submit-submit_filter").attr("disabled", false);
$(".select_one_filter").css("display", "none");
}
}
</script>
<?php
} else {
$filteringFunction = '';
}
if ($is_metaconsole === false) { if ($is_metaconsole === false) {
// Single agent selected. // Single agent selected.
if ($inventory_id_agent > 0 && isset($agents[$inventory_id_agent]) === true) { if ($inventory_id_agent > 0 && isset($agents[$inventory_id_agent]) === true) {
@ -1073,8 +1085,8 @@ if ($is_metaconsole === false) {
$table = ui_print_datatable( $table = ui_print_datatable(
[ [
'id' => $id_table, 'id' => $id_table,
'class' => 'info_table w100p', 'class' => 'info_table',
'style' => 'width: 100%', 'style' => 'width: 99%',
'columns' => $columns, 'columns' => $columns,
'column_names' => $columns, 'column_names' => $columns,
'no_sortable_columns' => [], 'no_sortable_columns' => [],
@ -1184,8 +1196,8 @@ if ($is_metaconsole === false) {
$table = ui_print_datatable( $table = ui_print_datatable(
[ [
'id' => $id_table, 'id' => $id_table,
'class' => 'info_table w100p', 'class' => 'info_table',
'style' => 'width: 100%', 'style' => 'width: 99%',
'columns' => $columns, 'columns' => $columns,
'column_names' => $columns, 'column_names' => $columns,
'no_sortable_columns' => [], 'no_sortable_columns' => [],
@ -1257,12 +1269,27 @@ if ($is_metaconsole === false) {
$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'),
__('Secondary IP'), __('Secondary IP'),
@ -1277,162 +1304,34 @@ if ($is_metaconsole === false) {
__('Values Custom Fields'), __('Values Custom Fields'),
]; ];
if ($id_server === 0) { ui_print_datatable(
$servers_ids = array_column(metaconsole_get_servers(), 'id');
} else {
$servers_ids = [$id_server];
}
foreach ($servers_ids as $server_id) {
if (is_metaconsole()) {
$server = metaconsole_get_connection_by_id($server_id);
if ((int) $es_agent_server_filter !== 0
&& (int) $es_agent_server_filter !== (int) $server_id
) {
continue;
}
metaconsole_connect($server);
}
if ((int) $id_agente === 0) {
$class = 'databox info_table w100p';
$style = 'width: 99%';
$ordering = true;
$searching = true;
$dom = 'lftipB';
$sql_agentes = 'SELECT t.id_agente
FROM tagente t
LEFT JOIN tgrupo tg ON tg.id_grupo = t.id_grupo
WHERE (t.alias LIKE "%'.$inventory_search_string.'%")
OR (t.comentarios LIKE "%'.$inventory_search_string.'%")
OR (t.direccion LIKE "%'.$inventory_search_string.'%")
OR (t.os_version LIKE "%'.$inventory_search_string.'%")
OR (tg.nombre LIKE "%'.$inventory_search_string.'%")';
$agentes = db_get_all_rows_sql($sql_agentes);
} 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,
__('Secondary IP') => $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);
}
if (is_metaconsole()) {
metaconsole_restore_db();
}
}
$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; html_print_action_buttons(
} else { '',
echo '<div class="databox">'.$table.'</div>'; ['type' => 'form_action']
} );
} }
} }

View File

@ -168,6 +168,10 @@ if (!$strict_acl) {
$header_title = $header_title.' &raquo; '.$header_sub_title; $header_title = $header_title.' &raquo; '.$header_sub_title;
} }
if (is_metaconsole() === true) {
$tabs = [];
}
ui_print_standard_header( ui_print_standard_header(
$header_title, $header_title,
'images/extensions.png', 'images/extensions.png',

View File

@ -216,11 +216,12 @@ $enable_disable['text'] = html_print_div(
// New Widget. // New Widget.
$newWidget['text'] = '<a href="#" id="add-widget" class="invisible">'; $newWidget['text'] = '<a href="#" id="add-widget" class="invisible">';
$newWidget['text'] .= html_print_image( $newWidget['text'] .= html_print_image(
'images/add.png', 'images/plus@svg.svg',
true, true,
[ [
'title' => __('Add Cell'), 'title' => __('Add Cell'),
'class' => 'invert_filter', 'class' => 'main_menu_icon invert_filter',
'style' => 'margin-top:5px;',
] ]
); );
$newWidget['text'] .= '</a>'; $newWidget['text'] .= '</a>';