Added new option to networkmap, reset

This commit is contained in:
Arturo Gonzalez 2017-11-07 15:05:31 +01:00
parent 7e6cc539e8
commit 7b956e8ef6
4 changed files with 139 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

View File

@ -790,6 +790,12 @@ function networkmap_write_js_array($id, $nodes_and_relations = array(), $map_das
echo "var set_center_menu = '" . __('Set center') . "';\n";
echo "var refresh_menu = '" . __('Refresh') . "';\n";
echo "var refresh_holding_area_menu = '" . __('Refresh Holding area') . "';\n";
echo "var ok_button = '" . __('Proceed') . "';\n";
echo "var message_to_confirm = '" . __('Resetting the map will delete all customizations you have done, including manual relationships between elements, new items, etc.') . "';\n";
echo "var warning_message = '" . __('WARNING') . "';\n";
echo "var ok_button = '" . __('Proceed') . "';\n";
echo "var cancel_button = '" . __('Cancel') . "';\n";
echo "var restart_map_menu = '" . __('Restart map') . "';\n";
echo "var abort_relationship_interface = '" . __('Abort the interface relationship') . "';\n";
echo "var abort_relationship_menu = '" . __('Abort the action of set relationship') . "';\n";

View File

@ -1900,6 +1900,21 @@ function show_menu(item, data) {
refresh_holding_area();
}
};
items_list["restart_map"] = {
name: restart_map_menu,
icon: "restart_map",
disabled: function () {
if (enterprise_installed) {
return false;
}
else {
return true;
}
},
"callback": function (key, options) {
restart_map(networkmap_id);
}
};
if (flag_setting_relationship_running) {
items_list["cancel_set_parent"] = {
@ -2210,6 +2225,123 @@ function refresh_holding_area() {
}
}
function restart_map (map_id) {
$("<div id='restart_map_confirm' class='dialog ui-dialog-content' title='" + restart_map_menu + "'></div>").dialog ({
resizable: true,
draggable: true,
modal: true,
overlay: {
opacity: 0.5,
background: 'black'
},
width: 600,
height: 250,
buttons: [
{
text: ok_button,
click: function () {
$(this).dialog("close");
proceed_to_restart_map(map_id);
}
},
{
text:cancel_button,
click: function () {
$(this).dialog("close");
}
}
]
});
var dialog_confirm_text = "<div>";
dialog_confirm_text = dialog_confirm_text + "<div style='width:25%; float:left'><img style='padding-left:20px; padding-top:20px;' src='images/icono_info_mr.png'></div>";
dialog_confirm_text = dialog_confirm_text + "<div style='width:75%; float:left;'><h3><strong style='font-family:Verdana; font-size:13pt;'>" + warning_message + "</strong></h3>";
dialog_confirm_text = dialog_confirm_text + "<p style='font-family:Verdana; font-size:12pt;'>" + message_to_confirm + "</p></div>";
dialog_confirm_text = dialog_confirm_text + "</div>";
$('#restart_map_confirm').html(dialog_confirm_text);
$('#restart_map_confirm').dialog('open');
}
function proceed_to_restart_map (map_id) {
$("<div id='restart_map_form' class='dialog ui-dialog-content' title='" + restart_map_menu + "'></div>").dialog ({
resizable: true,
draggable: true,
modal: true,
overlay: {
opacity: 0.5,
background: 'black'
},
width: 600,
height: 450,
buttons: [
{
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();
reset_map_from_form(map_id, new_elements);
}
},
{
text:cancel_button,
click: function () {
$(this).dialog("close");
}
}
]
});
var params = [];
params.push("get_reset_map_form=1");
params.push("map_id=" + map_id);
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
jQuery.ajax({
data: params.join("&"),
dataType: 'html',
type: 'POST',
url: action = "ajax.php",
success: function (data) {
$('#restart_map_form').html(data);
$('#restart_map_form').dialog('open');
}
});
}
function reset_map_from_form (map_id, new_elements) {
var params = [];
params.push("reset_map=1");
params.push("map_id=" + map_id);
params.push("elems[]=" + new_elements)
params.push("page=enterprise/operation/agentes/pandora_networkmap.view");
jQuery.ajax({
data: params.join("&"),
dataType: 'json',
type: 'POST',
url: action = "ajax.php",
success: function (data) {
if (!data['error']) {
location.reload(true);
}
}
});
}
function set_parent(parent_data) {
if (enterprise_installed) {
var selection = d3.selectAll('.node_children');

View File

@ -117,6 +117,7 @@
.context-menu-item.icon-set_parent { background-image: url(../../images/father.png); }
.context-menu-item.icon-add_node { background-image: url(../../images/add.png); }
.context-menu-item.icon-refresh_holding_area { background-image: url(../../images/refresh_holding_area.png); }
.context-menu-item.icon-restart_map { background-image: url(../../images/reset.png); }
.context-menu-item.icon-interface_link_children { background-image: url(../../images/icono_link_hijo.png); }
.context-menu-item.icon-interface_link_parent { background-image: url(../../images/icono_link_padre.png); }
.context-menu-item.icon-interface_link_cancel { background-image: url(../../images/link_abortar.png); }