Merge branch 'ent-8381-Bug-interfaces-view' into 'develop'
Fixed issues with interfaces view and limited to show only agents with ifaces See merge request artica/pandorafms!4712
This commit is contained in:
commit
c1dd265085
|
@ -1243,6 +1243,11 @@ function agents_get_group_agents(
|
|||
unset($search['string']);
|
||||
}
|
||||
|
||||
if (isset($search['matchIds']) === true && is_array($search['matchIds']) === true) {
|
||||
$filter[] = sprintf('id_agente IN (%s)', implode(', ', $search['matchIds']));
|
||||
unset($search['matchIds']);
|
||||
}
|
||||
|
||||
if (isset($search['name']) === true) {
|
||||
$name = io_safe_input($search['name']);
|
||||
$filter[] = "nombre LIKE '$name'";
|
||||
|
@ -3223,8 +3228,8 @@ function agents_get_network_interfaces($agents=false, $agents_filter=false)
|
|||
$ni_by_agents = [];
|
||||
foreach ($agents as $agent) {
|
||||
$agent_id = (isset($agent['id_agente'])) ? $agent['id_agente'] : $agent;
|
||||
$agent_group_id = $agent['id_grupo'];
|
||||
$agent_name = $agent['alias'];
|
||||
$agent_group_id = (isset($agent['id_grupo']) === true) ? $agent['id_grupo'] : '';
|
||||
$agent_name = (isset($agent['alias']) === true) ? $agent['alias'] : '';
|
||||
$agent_interfaces = [];
|
||||
|
||||
$accepted_module_types = [];
|
||||
|
|
|
@ -176,6 +176,7 @@ function load_agents_selector(group) {
|
|||
{
|
||||
"page" : "operation/agentes/ver_agente",
|
||||
"get_agents_group_json" : 1,
|
||||
"get_agents_also_interfaces" : 1,
|
||||
"id_group" : group,
|
||||
"privilege" : "AW",
|
||||
"keys_prefix" : "_",
|
||||
|
@ -216,6 +217,7 @@ $("#checkbox-recursion").change (function () {
|
|||
jQuery.post ("ajax.php",
|
||||
{"page" : "operation/agentes/ver_agente",
|
||||
"get_agents_group_json" : 1,
|
||||
"get_agents_also_interfaces" : 1,
|
||||
"id_group" : $("#group_id").val(),
|
||||
"privilege" : "AW",
|
||||
"keys_prefix" : "_",
|
||||
|
@ -226,7 +228,6 @@ $("#checkbox-recursion").change (function () {
|
|||
$("#module").html('');
|
||||
jQuery.each (data, function (id, value) {
|
||||
id = id.substring(1);
|
||||
|
||||
option = $("<option></option>")
|
||||
.attr ("value", value["id_agente"])
|
||||
.html (value["alias"]);
|
||||
|
|
|
@ -49,6 +49,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_agents_also_interfaces = (bool) get_parameter('get_agents_also_interfaces');
|
||||
$get_modules_group_json = (bool) get_parameter('get_modules_group_json');
|
||||
$filter_modules_group_json = (bool) get_parameter('filter_modules_group_json');
|
||||
$get_modules_group_value_name_json = (bool) get_parameter('get_modules_group_value_name_json');
|
||||
|
@ -103,15 +104,15 @@ if (is_ajax()) {
|
|||
// Build filter.
|
||||
$filter = [];
|
||||
|
||||
if (!empty($id_os)) {
|
||||
if (empty($id_os) === false) {
|
||||
$filter['id_os'] = $id_os;
|
||||
}
|
||||
|
||||
if (!empty($agent_name)) {
|
||||
if (empty($agent_name) === false) {
|
||||
$filter['nombre'] = '%'.$agent_name.'%';
|
||||
}
|
||||
|
||||
if (!empty($agent_alias)) {
|
||||
if (empty($agent_alias) === false) {
|
||||
$filter['alias'] = '%'.$agent_alias.'%';
|
||||
}
|
||||
|
||||
|
@ -147,6 +148,20 @@ if (is_ajax()) {
|
|||
}
|
||||
}
|
||||
|
||||
if ($get_agents_also_interfaces === true) {
|
||||
$listAgentsWithIface = db_get_all_rows_sql("SELECT DISTINCT id_agente FROM tagente_modulo WHERE nombre LIKE '%_ifOperStatus'");
|
||||
if (empty($listAgentsWithIface) === false) {
|
||||
$filter['matchIds'] = array_reduce(
|
||||
$listAgentsWithIface,
|
||||
function ($carry, $item) {
|
||||
$carry[] = $item['id_agente'];
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Perform search.
|
||||
$agents = agents_get_group_agents(
|
||||
// Id_group.
|
||||
|
@ -171,7 +186,7 @@ if (is_ajax()) {
|
|||
(bool) is_metaconsole()
|
||||
);
|
||||
|
||||
if (empty($agents)) {
|
||||
if (empty($agents) === true) {
|
||||
$agents = [];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue