Merge branch 'ent-6435-vista-de-nodo-en-mapas-de-red-open' into 'develop'

ticket 6435

See merge request artica/pandorafms!3512
This commit is contained in:
Daniel Rodriguez 2020-12-02 10:10:34 +01:00
commit 67cdd704c4
3 changed files with 199 additions and 156 deletions

View File

@ -2890,14 +2890,12 @@ class NetworkMap
$list_networkmaps = []; $list_networkmaps = [];
} }
$output .= '<div id="open_version_dialog" style="display: none;">'; $id = 'dialog_node_edit';
$output .= __( if (!enterprise_installed()) {
'In the Open version of %s can not be edited nodes or map', $id = 'open_version_dialog';
get_product_name() }
);
$output .= '</div>';
$output .= '<div id="dialog_node_edit" style="display: none;" title="'; $output .= '<div id="'.$id.'" style="display: none;" title="';
$output .= __('Edit node').'">'; $output .= __('Edit node').'">';
$output .= '<div style="text-align: left; width: 100%;">'; $output .= '<div style="text-align: left; width: 100%;">';
@ -3016,6 +3014,7 @@ class NetworkMap
true true
); );
if (enterprise_installed()) {
$output .= ui_toggle( $output .= ui_toggle(
html_print_table($table, true), html_print_table($table, true),
__('Node options'), __('Node options'),
@ -3024,6 +3023,7 @@ class NetworkMap
true, true,
true true
); );
}
$table = new StdClass(); $table = new StdClass();
$table->id = 'relations_table'; $table->id = 'relations_table';
@ -3077,6 +3077,7 @@ class NetworkMap
true true
); );
if (enterprise_installed()) {
$output .= ui_toggle( $output .= ui_toggle(
html_print_table($table, true), html_print_table($table, true),
__('Relations'), __('Relations'),
@ -3085,6 +3086,7 @@ class NetworkMap
true, true,
true true
); );
}
$output .= '</div></div>'; $output .= '</div></div>';

View File

@ -771,7 +771,6 @@ function move_to_networkmap(node) {
} }
function edit_node(data_node, dblClick) { function edit_node(data_node, dblClick) {
if (enterprise_installed) {
var flag_edit_node = true; var flag_edit_node = true;
var edit_node = null; var edit_node = null;
@ -805,9 +804,10 @@ function edit_node(data_node, dblClick) {
var node_selected = graph.nodes[index_node]; var node_selected = graph.nodes[index_node];
var selected_links = get_relations(node_selected); var selected_links = get_relations(node_selected);
$( $("select[name='shape'] option[value='" + node_selected.shape + "']").prop(
"select[name='shape'] option[value='" + node_selected.shape + "']" "selected",
).prop("selected", true); true
);
$("select[name='shape']").attr( $("select[name='shape']").attr(
"onchange", "onchange",
"javascript: change_shape(" + node_selected.id_db + ");" "javascript: change_shape(" + node_selected.id_db + ");"
@ -827,6 +827,10 @@ function edit_node(data_node, dblClick) {
params.push("id_agent=" + node_selected["id_agent"]); params.push("id_agent=" + node_selected["id_agent"]);
params.push("page=enterprise/operation/agentes/pandora_networkmap.view"); params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
if (!enterprise_installed) {
params.push("page=operation/agentes/pandora_networkmap.view");
}
jQuery.ajax({ jQuery.ajax({
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
@ -871,12 +875,10 @@ function edit_node(data_node, dblClick) {
$("#dialog_node_edit").dialog( $("#dialog_node_edit").dialog(
"option", "option",
"title", "title",
dialog_node_edit_title.replace( dialog_node_edit_title.replace("%s", ellipsize(node_selected["text"], 40))
"%s",
ellipsize(node_selected["text"], 40)
)
); // It doesn't eval the possible XSS so it's ok ); // It doesn't eval the possible XSS so it's ok
$("#dialog_node_edit").dialog("open"); $("#dialog_node_edit").dialog("open");
$("#open_version_dialog").dialog();
if (node_selected.id_agent == undefined || node_selected.type == 3) { if (node_selected.id_agent == undefined || node_selected.type == 3) {
//Fictional node //Fictional node
@ -890,10 +892,7 @@ function edit_node(data_node, dblClick) {
} else { } else {
$("input[name='edit_name_node']").val(node_selected.text); // It doesn't eval the possible XSS so it's ok $("input[name='edit_name_node']").val(node_selected.text); // It doesn't eval the possible XSS so it's ok
$("#node_options-fictional_node_name").css("display", "none"); $("#node_options-fictional_node_name").css("display", "none");
$("#node_options-fictional_node_networkmap_link").css( $("#node_options-fictional_node_networkmap_link").css("display", "none");
"display",
"none"
);
$("#node_options-fictional_node_update_button").css("display", "none"); $("#node_options-fictional_node_update_button").css("display", "none");
$("#node_options-node_name").css("display", ""); $("#node_options-node_name").css("display", "");
} }
@ -905,7 +904,6 @@ function edit_node(data_node, dblClick) {
$("#relations_table-no_relations").css("display", ""); $("#relations_table-no_relations").css("display", "");
} }
} }
}
function get_interface_data_to_table(node_selected, selected_links) { function get_interface_data_to_table(node_selected, selected_links) {
$("#interface_information") $("#interface_information")
@ -2871,18 +2869,35 @@ function init_drag_and_drop() {
}); });
}); });
} else { } else {
var params = [];
params.push("update_node_alert=1");
params.push("map_id=" + networkmap_id);
params.push("page=operation/agentes/pandora_networkmap.view");
jQuery.ajax({ jQuery.ajax({
data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: window.base_url_homedir + "/ajax.php", url: window.base_url_homedir + "/ajax.php",
data: {
node: JSON.stringify(d),
update_node: 1,
page: "operation/agentes/pandora_networkmap.view"
},
success: function(data) { success: function(data) {
if (data["correct"]) { if (d.state == "holding_area") {
$("#open_version_dialog").dialog(); //It is out the holding area
if (data["state"] == "") {
//Remove the style of nodes and links
//in holding area
d3.select("#id_node_" + d.id + networkmap_id).classed(
"holding_area",
false
);
d3.select(".source_" + d.id + networkmap_id).classed(
"holding_area_link",
false
);
d3.select(".target_" + d.id + networkmap_id).classed(
"holding_area_link",
false
);
graph.nodes[d.id].state = "";
}
} }
} }
}); });

View File

@ -53,6 +53,32 @@ if (is_ajax()) {
$module_get_status = (bool) get_parameter('module_get_status', false); $module_get_status = (bool) get_parameter('module_get_status', false);
$update_node_alert = (bool) get_parameter('update_node_alert', false); $update_node_alert = (bool) get_parameter('update_node_alert', false);
$process_migration = (bool) get_parameter('process_migration', false); $process_migration = (bool) get_parameter('process_migration', false);
$get_agent_info = (bool) get_parameter('get_agent_info', false);
$update_node = (bool) get_parameter('update_node', false);
if ($update_node) {
$node_json = io_safe_output(get_parameter('node', ''));
$node = json_decode($node_json, true);
echo json_encode($node);
return;
}
if ($get_agent_info) {
$id_agent = (int) get_parameter('id_agent');
$return = [];
$return['alias'] = agents_get_alias($id_agent);
$return['adressess'] = agents_get_addresses($id_agent);
$id_group = agents_get_agent_group($id_agent);
$return['group'] = db_get_value('nombre', 'tgrupo', 'id_grupo', $id_group);
$id_os = agents_get_os($id_agent);
$return['os'] = ui_print_os_icon($id_os, true, true);
echo json_encode($return);
return;
}
if ($module_get_status) { if ($module_get_status) {
$id = (int) get_parameter('id', 0); $id = (int) get_parameter('id', 0);