Some fixes.

This commit is contained in:
mdtrooper 2016-05-09 09:51:20 +02:00
parent 4c2336e7b7
commit 08d1cece5c
4 changed files with 39 additions and 32 deletions

View File

@ -353,9 +353,11 @@ MapController.prototype.get_node_type = function(id_graph) {
* This function returns the edges of a node
*/
MapController.prototype.get_edges_from_node = function(id_graph) {
var self = this;
var return_edges = [];
$.each(edges, function(i, edge) {
$.each(self.get_edges_map(), function(i, edge) {
if ((edge['to'] == id_graph) || (edge['from'] == id_graph)) {
return_edges.push(edge);
}
@ -370,11 +372,14 @@ MapController.prototype.get_edges_from_node = function(id_graph) {
* This function updates the graph id of the edges
*/
MapController.prototype.update_edges_from_clean_arrows = function(clean_arrows) {
var self = this;
newEdges = [];
clean_arrows.forEach(function(arrow, index) {
newEdges[index] = arrow;
});
edges = newEdges;
self.set_edges_map(newEdges);
}
/**
@ -385,7 +390,7 @@ MapController.prototype.update_edges_from_clean_arrows = function(clean_arrows)
MapController.prototype.get_arrow_from_id = function(id) {
var self = this;
var arrow = $.grep(edges, function(e) {
var arrow = $.grep(self.get_edges_map(), function(e) {
if (e['graph_id'] == id) {
return true;
}
@ -411,7 +416,7 @@ MapController.prototype.get_arrows_from_edges = function() {
var return_var = [];
$.each(edges, function(i, e) {
$.each(self.get_edges_map(), function(i, e) {
return_var.push(self.get_arrow_from_id(e['graph_id']));
});
@ -795,9 +800,11 @@ MapController.prototype.zoom_minimap = function() {
* This function returns the node with the specific id_graph
*/
MapController.prototype.node_from_edge = function(id_graph) {
var self = this;
var exists = null;
$.each(edges, function(i, e) {
$.each(self.get_edges_map(), function(i, e) {
if (e.graph_id == id_graph) {
exists = i;
return false; // jquery.each break;
@ -805,7 +812,7 @@ MapController.prototype.node_from_edge = function(id_graph) {
});
if (exists !== null)
return edges[exists];
return self.get_edges_map()[exists];
else
return null;
}
@ -816,9 +823,11 @@ MapController.prototype.node_from_edge = function(id_graph) {
* This function returns if the node exist
*/
MapController.prototype.exists_edge = function(id_graph) {
var self = this;
var exists = false;
$.each(edges, function(i, e) {
$.each(self.get_edges_map(), function(i, e) {
if (e.graph_id == id_graph) {
exists = true;
return false; // jquery.each break;
@ -872,7 +881,7 @@ MapController.prototype.paint_arrows = function() {
arrow_layouts.each(function(d) {
var arrow_layout = this;
var node_arrow = edges.filter(function(d2) {
var node_arrow = self.get_edges_map().filter(function(d2) {
if (d2['graph_id'] == d['graph_id'])
return true;
else
@ -2774,12 +2783,12 @@ MapController.prototype.deleteEdgesAndNode = function(arrowsToDelete, id_node) {
arrowsToDelete.forEach(function(arrow) {
temp = [];
edges.forEach(function(edge) {
self.get_edges_map().forEach(function(edge) {
if (edge["graph_id"] != arrow['graph_id']) {
temp.push(edge);
}
});
edges = temp;
self.set_edges_map(temp);
});
arrowsToDelete.forEach(function(arrow) {
@ -2813,9 +2822,11 @@ MapController.prototype.deleteEdgesAndNode = function(arrowsToDelete, id_node) {
* This function returns the edges of a node to delete them
*/
MapController.prototype.get_edges_to_del = function(id_graph) {
var self = this;
var return_edges = [];
$.each(edges, function(i, edge) {
$.each(self.get_edges_map(), function(i, edge) {
if ((edge['to']['graph_id'] == id_graph) || (edge['from']['graph_id'] == id_graph)) {
return_edges.push(edge);
}
@ -2835,7 +2846,7 @@ MapController.prototype.getArrows = function(id_node) {
var edgesToDel = [];
var j = 0;
edges.forEach(function(edge, index) {
self.get_edges_map().forEach(function(edge, index) {
var nodeTo = "node_" + edge["to"];
var nodeFrom = "node_" + edge["from"];
if (nodeTo == id_node || nodeFrom == id_node) {

View File

@ -155,7 +155,7 @@ NetworkmapController.prototype.init_map = function() {
});
clean_arrows = new_clean_arrows;
MapController.prototype.update_edges_from_clean_arrows(clean_arrows);
self.update_edges_from_clean_arrows(clean_arrows);
MapController.prototype.init_map.call(this);
};
@ -485,7 +485,7 @@ NetworkmapController.prototype.get_arrow_AG = function(id_to, id_from) {
var arrow_AG;
var found = false;
$.each(edges, function(i, edge) {
$.each(self.get_edges_map(), function(i, edge) {
if (self.get_node_type(id_to) == ITEM_TYPE_AGENT_NETWORKMAP ||
self.get_node_type(id_from) == ITEM_TYPE_AGENT_NETWORKMAP) {
if (self.get_node_type(id_to) == ITEM_TYPE_GROUP_NETWORKMAP ||
@ -529,7 +529,7 @@ NetworkmapController.prototype.get_arrow_PA = function(id_to, id_from) {
var arrow_PA;
var found = false;
$.each(edges, function(i, edge) {
$.each(self.get_edges_map(), function(i, edge) {
if (self.get_node_type(id_to) == ITEM_TYPE_AGENT_NETWORKMAP ||
self.get_node_type(id_from) == ITEM_TYPE_AGENT_NETWORKMAP) {
if (self.get_node_type(id_to) == ITEM_TYPE_POLICY_NETWORKMAP ||
@ -573,7 +573,7 @@ NetworkmapController.prototype.get_arrow_GG = function(id_to, id_from) {
var arrow_GG;
var found = false;
$.each(edges, function(i, edge) {
$.each(self.get_edges_map(), function(i, edge) {
if (self.get_node_type(id_to) == ITEM_TYPE_GROUP_NETWORKMAP &&
self.get_node_type(id_from) == ITEM_TYPE_GROUP_NETWORKMAP) {
@ -702,7 +702,7 @@ NetworkmapController.prototype.get_arrow_AM = function(id_to, id_from) {
var arrow_AM;
var found = false;
$.each(edges, function(i, edge) {
$.each(self.get_edges_map(), function(i, edge) {
if (self.get_node_type(id_to) == ITEM_TYPE_AGENT_NETWORKMAP ||
self.get_node_type(id_from) == ITEM_TYPE_AGENT_NETWORKMAP) {
if (self.get_node_type(id_to) == ITEM_TYPE_MODULE_NETWORKMAP ||
@ -837,9 +837,11 @@ NetworkmapController.prototype.update_arrow = function(graph_id) {
* This function returns the arrow type
*/
NetworkmapController.prototype.get_type_arrow = function(graph_id) {
var self = this;
var return_var = null;
$.each(edges, function(i, edge) {
$.each(self.get_edges_map(), function(i, edge) {
if (edge['graph_id'] == graph_id) {
return_var = edge['type'];
return false;
@ -950,7 +952,7 @@ NetworkmapController.prototype.paint_arrows = function() {
var self = this;
var arrow_layouts = self._viewport.selectAll(".arrow")
.data(edges)
.data(self.get_edges_map())
.enter()
.append("g")
.attr("class", "arrow")
@ -1033,7 +1035,7 @@ NetworkmapController.prototype.make_arrow = function(from_id, to_id) {
edge['from_status'] = null;
edge['from_title'] = null;
edges.push(edge);
self.get_edges_map().push(edge);
}
/**
@ -2300,7 +2302,7 @@ NetworkmapController.prototype.refresh_arrows = function() {
params["id_map"] = self._id;
params["page"] = "include/ajax/map.ajax";
var arrows_AMA_or_AMMA = $.grep(edges,
var arrows_AMA_or_AMMA = $.grep(self.get_edges_map(),
function(edge) {
if ((edge['type'] == "AMA") || (edge['type'] == "AMMA")) {
return true;
@ -2325,10 +2327,10 @@ NetworkmapController.prototype.refresh_arrows = function() {
type: "POST",
url: "ajax.php",
success: function (data) {
$.each(edges, function(i, edge) {
$.each(self.get_edges_map(), function(i, edge) {
if (typeof(data[edge['graph_id']]) != "undefined") {
edges[i]['to_status'] = data[edge['graph_id']]['to_status'];
edges[i]['from_status'] = data[edge['graph_id']]['from_status'];
self.get_edges_map()[i]['to_status'] = data[edge['graph_id']]['to_status'];
self.get_edges_map()[i]['from_status'] = data[edge['graph_id']]['from_status'];
self.update_arrow(edge['graph_id']);
}
@ -2363,7 +2365,7 @@ NetworkmapController.prototype.getArrows = function(id_node) {
var return_var = [];
edges.forEach(function(edge, index) {
self.get_edges_map().forEach(function(edge, index) {
if (("node_" + edge['to']['graph_id']) == id_node
|| ("node_" + edge['from']['graph_id']) == id_node) {
return_var[index] = edge["graph_id"];

View File

@ -137,12 +137,6 @@ else {
$result = system ($cmd);
fclose ($fh);
unlink ($filename_dot);
html_debug_print($cmd);
html_debug(file_get_contents("/tmp/caca.txt"), true);
html_debug($graph);
}
}

View File

@ -494,7 +494,7 @@ else {
}
$action_url = 'index.php?sec=maps&sec2=operation/maps/networkmap_editor';
$action_url = 'index.php?sec=maps&sec2=operation/maps/networkmap_list';
if (is_metaconsole()) {
$action_url = 'index.php?sec=screen&sec2=screens/screens';
}