Merge branch 'develop' of https://brutus.artica.lan:8081/artica/pandorafms into develop
This commit is contained in:
commit
0ab3983d87
|
@ -140,6 +140,7 @@ switch ($action) {
|
|||
case 'general':
|
||||
case 'network_interfaces_report':
|
||||
case 'availability':
|
||||
case 'agent_module':
|
||||
$get_data_editor = true;
|
||||
break;
|
||||
|
||||
|
@ -514,8 +515,18 @@ switch ($action) {
|
|||
break;
|
||||
case 'agent_module':
|
||||
$description = $item['description'];
|
||||
$es = json_decode($item['external_source'], true);
|
||||
$agents_id = get_parameter('id_agents');
|
||||
|
||||
if ((count($es['module']) == 1) && ($es['module'][0] == 0)) {
|
||||
$module = "";
|
||||
}
|
||||
else {
|
||||
$module = $es['module'];
|
||||
}
|
||||
$group = $item['id_group'];
|
||||
$modulegroup = $item['id_module_group'];
|
||||
$idAgentModule = $module;
|
||||
break;
|
||||
case 'inventory':
|
||||
$description = $item['description'];
|
||||
|
@ -982,6 +993,39 @@ You can of course remove the warnings, that's why we include the source and do n
|
|||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="agents_row" style="" class="datos">
|
||||
<td style="font-weight:bold;"><?php echo __('Agents'); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
$agents = agents_get_group_agents($group);
|
||||
if ((empty($agents)) || $agents == -1) $agents = array();
|
||||
|
||||
$agents_select = array();
|
||||
foreach ($id_agents as $id) {
|
||||
foreach ($agents as $key => $a) {
|
||||
if ($key == (int)$id) {
|
||||
$agents_select[$key] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
html_print_select($agents, 'id_agents[]', $agents_id, $script = '', "", 0, false, true, true, '', false, "min-width: 180px");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="modules_row" style="" class="datos">
|
||||
<td style="font-weight:bold;"><?php echo __('Modules'); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
$all_modules = array();
|
||||
foreach ($module as $id_modul) {
|
||||
$all_modules[] = modules_get_agentmodule_name($id_modul);
|
||||
}
|
||||
html_print_select($all_modules, 'module[]', $module, $script = '', __('None'), 0, false, true, true, '', false, "min-width: 180px");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr id="row_agent_multi" style="" class="datos">
|
||||
<td style="font-weight:bold;"><?php echo __('Agents'); ?></td>
|
||||
<td>
|
||||
|
@ -1790,6 +1834,78 @@ $(document).ready (function () {
|
|||
chooseType();
|
||||
chooseSQLquery();
|
||||
|
||||
$("#id_agents").change(agent_changed_by_multiple_agents);
|
||||
|
||||
$("#combo_group").change (
|
||||
function () {
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "operation/agentes/ver_agente",
|
||||
"get_agents_group_json" : 1,
|
||||
"id_group" : this.value,
|
||||
"privilege" : "AW",
|
||||
"keys_prefix" : "_"
|
||||
},
|
||||
function (data, status) {
|
||||
$("#id_agents").html('');
|
||||
jQuery.each (data, function (id, value) {
|
||||
// Remove keys_prefix from the index
|
||||
id = id.substring(1);
|
||||
|
||||
option = $("<option></option>")
|
||||
.attr ("value", value["id_agente"])
|
||||
.html (value["nombre"]);
|
||||
$("#id_agents").append (option);
|
||||
});
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
$("#combo_modulegroup").change (
|
||||
function () {
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "operation/agentes/ver_agente",
|
||||
"get_modules_group_json" : 1,
|
||||
"id_module_group" : this.value,
|
||||
"id_agents" : $("#id_agents").val()
|
||||
},
|
||||
function (data, status) {
|
||||
$("#module").html('');
|
||||
jQuery.each (data, function (id, value) {
|
||||
option = $("<option></option>")
|
||||
.attr ("value", value["id_agente_modulo"])
|
||||
.html (value["nombre"]);
|
||||
$("#module").append (option);
|
||||
});
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
$("#id_agents").change (
|
||||
function () {
|
||||
jQuery.post ("ajax.php",
|
||||
{"page" : "operation/agentes/ver_agente",
|
||||
"get_modules_group_json" : 1,
|
||||
"id_module_group" : $("#combo_modulegroup").val(),
|
||||
"id_agents" : $("#id_agents").val()
|
||||
},
|
||||
function (data, status) {
|
||||
$("#module").html('');
|
||||
jQuery.each (data, function (id, value) {
|
||||
option = $("<option></option>")
|
||||
.attr ("value", value["id_agente_modulo"])
|
||||
.html (value["nombre"]);
|
||||
$("#module").append (option);
|
||||
});
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
$("#text-time_to, #text-time_from").timepicker({
|
||||
showSecond: true,
|
||||
timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
|
||||
|
@ -1817,7 +1933,6 @@ $(document).ready (function () {
|
|||
async: false,
|
||||
timeout: 10000,
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
switch (data) {
|
||||
case 'boolean':
|
||||
case 'sparse':
|
||||
|
@ -1831,7 +1946,6 @@ $(document).ready (function () {
|
|||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function create_custom_graph() {
|
||||
|
@ -2328,6 +2442,8 @@ function chooseType() {
|
|||
$("#row_last_value").hide();
|
||||
$("#row_filter_search").hide();
|
||||
$("#row_percentil").hide();
|
||||
$("#agents_row").hide();
|
||||
$("#modules_row").hide();
|
||||
|
||||
// SLA list default state
|
||||
$("#sla_list").hide();
|
||||
|
@ -2717,6 +2833,8 @@ function chooseType() {
|
|||
$("#row_description").show();
|
||||
$("#row_group").show();
|
||||
$("#row_module_group").show();
|
||||
$("#agents_row").show();
|
||||
$("#modules_row").show();
|
||||
break;
|
||||
|
||||
case 'inventory_changes':
|
||||
|
|
|
@ -944,6 +944,12 @@ switch ($action) {
|
|||
$values['text'] = get_parameter('text');
|
||||
$values['show_graph'] = get_parameter('combo_graph_options');
|
||||
|
||||
$good_format = true;
|
||||
break;
|
||||
case 'agent_module':
|
||||
$es['id_agents'] = get_parameter('id_agents');
|
||||
$es['module'] = get_parameter('module', "");
|
||||
$values['external_source'] = json_encode($es);
|
||||
$good_format = true;
|
||||
break;
|
||||
case 'inventory':
|
||||
|
@ -1259,6 +1265,12 @@ switch ($action) {
|
|||
$values['external_source'] = json_encode($es);
|
||||
$good_format = true;
|
||||
break;
|
||||
case 'agent_module':
|
||||
$es['id_agents'] = get_parameter('id_agents');
|
||||
$es['module'] = get_parameter('module', "");
|
||||
$values['external_source'] = json_encode($es);
|
||||
$good_format = true;
|
||||
break;
|
||||
case 'inventory_changes':
|
||||
$values['period'] = get_parameter('period');
|
||||
$es['id_agents'] = get_parameter('id_agents');
|
||||
|
|
|
@ -1505,13 +1505,15 @@ function reporting_inventory($report, $content, $type) {
|
|||
|
||||
function reporting_agent_module($report, $content) {
|
||||
global $config;
|
||||
|
||||
$agents_and_modules = json_decode($content['external_source'], true);
|
||||
$agents = array();
|
||||
$agents = $agents_and_modules['id_agents'];
|
||||
$modules = $agents_and_modules['module'];
|
||||
$id_group = $content['id_group'];
|
||||
$id_module_group = $content['id_module_group'];
|
||||
|
||||
$return['type'] = 'agent_module';
|
||||
|
||||
|
||||
if (empty($content['name'])) {
|
||||
$content['name'] = __('Agent/Modules');
|
||||
}
|
||||
|
@ -1532,54 +1534,25 @@ function reporting_agent_module($report, $content) {
|
|||
|
||||
$return["data"] = array();
|
||||
|
||||
$agents = array();
|
||||
if ($id_group > 0) {
|
||||
$agents = agents_get_group_agents($id_group);
|
||||
$agents = array_keys($agents);
|
||||
}
|
||||
|
||||
$filter_module_groups = false;
|
||||
if ($id_module_group > 0) {
|
||||
$filter_module_groups['id_module_group'] = $id_module_group;
|
||||
}
|
||||
|
||||
$all_modules = agents_get_modules($agents, false,
|
||||
$filter_module_groups, true, false);
|
||||
|
||||
$modules_by_name = array();
|
||||
$name = '';
|
||||
$cont = 0;
|
||||
|
||||
foreach ($all_modules as $key => $module) {
|
||||
if ($module == $name) {
|
||||
$modules_by_name[$cont - 1]['id'][] = $key;
|
||||
}
|
||||
else {
|
||||
$name = $module;
|
||||
$modules_by_name[$cont]['name'] = $name;
|
||||
$modules_by_name[$cont]['id'][] = $key;
|
||||
foreach ($modules as $modul_id) {
|
||||
$modules_by_name[$cont]['name'] = io_safe_output(modules_get_agentmodule_name($modul_id));
|
||||
$modules_by_name[$cont]['id'][] = $modul_id;
|
||||
$cont ++;
|
||||
}
|
||||
}
|
||||
|
||||
$filter_groups = array();
|
||||
if ($id_group > 0) {
|
||||
$filter_groups['id_grupo'] = $id_group;
|
||||
}
|
||||
$agents = agents_get_agents ($filter_groups);
|
||||
$nagents = count($agents);
|
||||
|
||||
if ($all_modules == false || $agents == false) {
|
||||
if ($modules_by_name == false || $agents == false) {
|
||||
$return['failed'] = __('There are no agents with modules');
|
||||
}
|
||||
else {
|
||||
foreach ($agents as $agent) {
|
||||
$row = array();
|
||||
$row['agent_status'][$agent['id_agente']] =
|
||||
agents_get_status($agent['id_agente']);
|
||||
$row['agent_name'] = $agent['nombre'];
|
||||
$row['agent_status'][$agent] =
|
||||
agents_get_status($agent);
|
||||
$row['agent_name'] = agents_get_name($agent);
|
||||
|
||||
$agent_modules = agents_get_modules($agent['id_agente']);
|
||||
$agent_modules = agents_get_modules($agent);
|
||||
|
||||
$row['modules'] = array();
|
||||
foreach ($modules_by_name as $module) {
|
||||
|
|
|
@ -35,6 +35,7 @@ if (is_ajax ()) {
|
|||
$get_agent_modules_json = (bool) get_parameter ('get_agent_modules_json');
|
||||
$get_agent_status_tooltip = (bool) get_parameter ("get_agent_status_tooltip");
|
||||
$get_agents_group_json = (bool) get_parameter ("get_agents_group_json");
|
||||
$get_modules_group_json = (bool) get_parameter ("get_modules_group_json");
|
||||
$get_agent_modules_json_for_multiple_agents = (bool) get_parameter("get_agent_modules_json_for_multiple_agents");
|
||||
$get_agent_modules_alerts_json_for_multiple_agents = (bool) get_parameter("get_agent_modules_alerts_json_for_multiple_agents");
|
||||
$get_agents_json_for_multiple_modules = (bool) get_parameter("get_agents_json_for_multiple_modules");
|
||||
|
@ -104,10 +105,14 @@ if (is_ajax ()) {
|
|||
$agents = db_get_all_rows_filter('tagente', $filter, $fields);
|
||||
if (empty($agents)) $agents = array();
|
||||
|
||||
foreach ($agents as $k => $v) {
|
||||
$agents[$k] = io_safe_output($v);
|
||||
}
|
||||
|
||||
// Add keys prefix
|
||||
if ($keys_prefix !== '') {
|
||||
foreach ($agents as $k => $v) {
|
||||
$agents[$keys_prefix . $k] = $v;
|
||||
$agents[$keys_prefix . $k] = io_safe_output($v);
|
||||
unset($agents[$k]);
|
||||
}
|
||||
}
|
||||
|
@ -116,6 +121,34 @@ if (is_ajax ()) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ($get_modules_group_json) {
|
||||
$id_group = (int) get_parameter('id_module_group');
|
||||
$id_agents = get_parameter('id_agents');
|
||||
|
||||
$agents = implode(",", $id_agents);
|
||||
|
||||
$filter_group = "";
|
||||
$filter_agent = "";
|
||||
|
||||
if ($id_group != 0) {
|
||||
$filter_group = " AND id_module_group = ". $id_group;
|
||||
}
|
||||
if ($agents != null) {
|
||||
$filter_agent = " AND id_agente IN (" . $agents . ")";
|
||||
}
|
||||
|
||||
$modules = db_get_all_rows_sql("SELECT nombre, id_agente_modulo FROM tagente_modulo WHERE 1 = 1" . $filter_agent . $filter_group);
|
||||
|
||||
if (empty($modules)) $modules = array();
|
||||
|
||||
foreach ($modules as $k => $v) {
|
||||
$modules[$k] = io_safe_output($v);
|
||||
}
|
||||
|
||||
echo json_encode($modules);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_agent_json) {
|
||||
$id_agent = (int) get_parameter ('id_agent');
|
||||
|
||||
|
@ -135,7 +168,7 @@ if (is_ajax ()) {
|
|||
|
||||
$return = array();
|
||||
foreach ($modules as $module) {
|
||||
$return[$module['id_agente_modulo']] = $module['nombre'];
|
||||
$return[$module['id_agente_modulo']] = io_safe_output($module['nombre']);
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
|
|
Loading…
Reference in New Issue