reset-map fixed
Former-commit-id: b89cf24a88f5e190cae0d2e55a55a8d988d94458
This commit is contained in:
parent
091e2db13a
commit
face622e9e
|
@ -753,9 +753,25 @@ class NetworkMap
|
|||
// Empty map returns no data.
|
||||
$nodes = [];
|
||||
} else {
|
||||
if ($this->mapOptions['map_filter']['dont_show_subgroups'] == 'true') {
|
||||
// Show only current selected group.
|
||||
$filter['id_grupo'] = $this->idGroup;
|
||||
} else {
|
||||
// Show current group and children.
|
||||
$childrens = groups_get_childrens($this->idGroup, null, true);
|
||||
if (!empty($childrens)) {
|
||||
$childrens = array_keys($childrens);
|
||||
|
||||
$filter['id_grupo'] = $childrens;
|
||||
$filter['id_grupo'][] = $this->idGroup;
|
||||
} else {
|
||||
$filter['id_grupo'] = $this->idGroup;
|
||||
}
|
||||
}
|
||||
|
||||
// Group map.
|
||||
$nodes = agents_get_agents(
|
||||
['id_grupo' => $this->idGroup],
|
||||
$filter,
|
||||
['*'],
|
||||
'AR',
|
||||
[
|
||||
|
@ -764,14 +780,18 @@ class NetworkMap
|
|||
]
|
||||
);
|
||||
|
||||
// Remap ids.
|
||||
$nodes = array_reduce(
|
||||
$nodes,
|
||||
function ($carry, $item) {
|
||||
$carry[$item['id_agente']] = $item;
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
if (is_array($nodes)) {
|
||||
// Remap ids.
|
||||
$nodes = array_reduce(
|
||||
$nodes,
|
||||
function ($carry, $item) {
|
||||
$carry[$item['id_agente']] = $item;
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
} else {
|
||||
$nodes = [];
|
||||
}
|
||||
}
|
||||
|
||||
return $nodes;
|
||||
|
|
|
@ -434,15 +434,15 @@ function agents_get_agents(
|
|||
$filter_nogroup = $filter;
|
||||
|
||||
// Get user groups
|
||||
$groups = array_keys(users_get_groups($config['id_user'], $access, false));
|
||||
$groups = array_keys(users_get_groups($config['id_user'], $access, true));
|
||||
|
||||
// If no group specified, get all user groups
|
||||
if (empty($filter['id_grupo'])) {
|
||||
if (isset($filter['id_grupo']) === false) {
|
||||
$all_groups = true;
|
||||
$filter['id_grupo'] = $groups;
|
||||
} else if (! is_array($filter['id_grupo'])) {
|
||||
$all_groups = false;
|
||||
// If group is specified but not allowed, return false
|
||||
// If group is specified but not allowed, return false.
|
||||
if (! in_array($filter['id_grupo'], $groups)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -466,11 +466,6 @@ function agents_get_agents(
|
|||
|
||||
$filter['id_group'] = $filter['id_grupo'];
|
||||
|
||||
if (in_array(0, $filter['id_grupo'])) {
|
||||
unset($filter['id_grupo']);
|
||||
unset($filter['id_group']);
|
||||
}
|
||||
|
||||
if (!is_array($fields)) {
|
||||
$fields = [];
|
||||
$fields[0] = 'id_agente';
|
||||
|
@ -578,6 +573,7 @@ function agents_get_agents(
|
|||
}
|
||||
|
||||
$sql = sprintf('%s %s', $sql, $limit_sql);
|
||||
|
||||
if ($return) {
|
||||
return $sql;
|
||||
} else {
|
||||
|
|
|
@ -2551,28 +2551,29 @@ function proceed_to_restart_map() {
|
|||
text: ok_button,
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
var new_elements = [];
|
||||
new_elements[0] = $("#text-name").val();
|
||||
new_elements[1] = $("#id_group").val();
|
||||
new_elements[2] = $("#text-node_radius").val();
|
||||
new_elements[3] = $("#textarea_description").val();
|
||||
new_elements[4] = $("input[name=source]:checked").val();
|
||||
if (new_elements[4] == "group") {
|
||||
new_elements[5] = $("#checkbox-dont_show_subgroups").is(":checked");
|
||||
} else if (new_elements[4] == "recon_task") {
|
||||
new_elements[5] = $("#recon_task_id").val();
|
||||
} else {
|
||||
new_elements[5] = $("#text-ip_mask").val();
|
||||
}
|
||||
new_elements[6] = $("#method").val();
|
||||
new_elements[7] = $("#text-pos_x").val();
|
||||
new_elements[8] = $("#text-pos_y").val();
|
||||
new_elements[9] = $("#text-scale_z").val();
|
||||
new_elements[10] = $("#text-node_sep").val();
|
||||
new_elements[11] = $("#text-mindist").val();
|
||||
new_elements[12] = $("#text-rank_sep").val();
|
||||
new_elements[13] = $("#text-kval").val();
|
||||
reset_map_from_form(new_elements);
|
||||
var data = {
|
||||
params: {
|
||||
name: $("#text-name").val(),
|
||||
id_group: $("#id_group").val(),
|
||||
node_radius: $("#text-node_radius").val(),
|
||||
description: $("#textarea_description").val(),
|
||||
source: $("input[name=source]:checked").val(),
|
||||
dont_show_subgroups: $("#checkbox-dont_show_subgroups").is(
|
||||
":checked"
|
||||
),
|
||||
recon_task_id: $("#recon_task_id").val(),
|
||||
ip_mask: $("#text-ip_mask").val(),
|
||||
generation_method: $("#method").val(),
|
||||
pos_x: $("#text-pos_x").val(),
|
||||
pos_y: $("#text-pos_y").val(),
|
||||
scale_z: $("#text-scale_z").val(),
|
||||
node_sep: $("#text-node_sep").val(),
|
||||
mindist: $("#text-mindist").val(),
|
||||
rank_sep: $("#text-rank_sep").val(),
|
||||
kval: $("#text-kval").val()
|
||||
}
|
||||
};
|
||||
reset_map_from_form(data);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -2601,17 +2602,16 @@ function proceed_to_restart_map() {
|
|||
}
|
||||
|
||||
function reset_map_from_form(new_elements) {
|
||||
var params = [];
|
||||
params.push("reset_map=1");
|
||||
params.push("map_id=" + networkmap_id);
|
||||
params.push("elems[]=" + new_elements);
|
||||
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
|
||||
var data = new_elements;
|
||||
data.map_id = networkmap_id;
|
||||
data.reset_map = 1;
|
||||
data.page = "enterprise/operation/agentes/pandora_networkmap.view";
|
||||
jQuery.ajax({
|
||||
data: params.join("&"),
|
||||
data: data,
|
||||
dataType: "json",
|
||||
type: "POST",
|
||||
url: "ajax.php",
|
||||
success: function(data) {
|
||||
success: function(d) {
|
||||
window.location =
|
||||
"index.php?sec=network&sec2=operation/agentes/pandora_networkmap&tab=view&id_networkmap=" +
|
||||
networkmap_id;
|
||||
|
|
Loading…
Reference in New Issue