#8307 Added contextmenu in supernet map

This commit is contained in:
Daniel Maya 2021-11-29 15:54:45 +01:00
parent 75699cb8fc
commit c289f67395
3 changed files with 62 additions and 1 deletions

View File

@ -3409,6 +3409,15 @@ class NetworkMap
$output .= '<link rel="stylesheet" type="text/css" href="'.ui_get_full_url(
'include/styles/tooltipster.bundle.min.css'
).'" />'."\n";
ui_require_css_file('jquery.contextMenu', 'include/styles/js/');
$output .= '<script type="text/javascript" src="';
$output .= ui_get_full_url(
'include/javascript/jquery.contextMenu.js',
false,
false,
false
);
$output .= '" charset="utf-8"></script>';
$output .= '<div id="simple_map" data-id="'.$this->idMap.'" ';
$output .= 'class="border_1px_dd" style="';

View File

@ -381,6 +381,52 @@ SimpleMapController.prototype.paint_nodes = function() {
});
}
});
if (
typeof node["type_net"] !== "undefined" &&
node["type_net"] === "supernet"
) {
var items_list = {};
items_list["details"] = {
name: "Show/hide subnets",
icon: "show",
disabled: false,
callback: function(key, options) {
self.nodes.forEach(function(subnode) {
if (
subnode.id != node["id"] &&
subnode.id_parent != null &&
subnode.id_parent == node["id"]
) {
if ($("#node_" + subnode.id).css("display") == "none") {
$("#node_" + subnode.id).show();
} else {
$("#node_" + subnode.id).hide();
}
}
});
self.arrows.forEach(function(arrow) {
if (arrow.source == node["id"] || arrow.target == node["id"]) {
if (
$("#arrow_" + arrow.source + "_" + arrow.target).css(
"display"
) == "none"
) {
$("#arrow_" + arrow.source + "_" + arrow.target).show();
} else {
$("#arrow_" + arrow.source + "_" + arrow.target).hide();
}
}
});
}
};
$.contextMenu({
selector: "#node_" + node["id"],
items: items_list
});
}
}
});
};
@ -416,6 +462,9 @@ SimpleMapController.prototype.paint_arrows = function() {
})
.attr("y2", function(d) {
return self.center_y + self.getSecondPoint(d["dest"], "y");
})
.attr("id", function(d) {
return "arrow_" + d["source"] + "_" + d["target"];
});
}
};

View File

@ -104,7 +104,7 @@
.context-menu-item.icon {
min-height: 18px;
background-repeat: no-repeat;
background-position: 4px 2px;
background-position: 4px center;
}
.context-menu-item.icon-edit {
background-image: url(../../../images/page_white_edit.png);
@ -163,6 +163,9 @@
.context-menu-item.icon-interface_link_cancel {
background-image: url(../../../images/link_abortar.png);
}
.context-menu-item.icon-show {
background-image: url(../../../images/eye_show.png);
}
/* vertically align inside labels */
.context-menu-input > label > * {