mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
Working in the arrows A-M-A
This commit is contained in:
parent
92703f13c2
commit
800756b9ac
@ -101,10 +101,12 @@ class Networkmap extends Map {
|
|||||||
|
|
||||||
$chunks = explode("ajax.php?", $chunks[1]);
|
$chunks = explode("ajax.php?", $chunks[1]);
|
||||||
|
|
||||||
|
$id_agent = null;
|
||||||
if (strstr($chunks[1], "&id_module=") !== false) {
|
if (strstr($chunks[1], "&id_module=") !== false) {
|
||||||
// MODULE
|
// MODULE
|
||||||
preg_match("/id_module=([0-9]*)/", $chunks[1], $matches);
|
preg_match("/id_module=([0-9]*)/", $chunks[1], $matches);
|
||||||
$id = $matches[1];
|
$id = $matches[1];
|
||||||
|
$id_agent = agents_get_module_id($id);
|
||||||
$type = ITEM_TYPE_MODULE_NETWORKMAP;
|
$type = ITEM_TYPE_MODULE_NETWORKMAP;
|
||||||
|
|
||||||
$flag_modules = true;
|
$flag_modules = true;
|
||||||
@ -112,12 +114,12 @@ class Networkmap extends Map {
|
|||||||
else {
|
else {
|
||||||
// AGENT
|
// AGENT
|
||||||
preg_match("/id_agent=([0-9]*)/", $chunks[1], $matches);
|
preg_match("/id_agent=([0-9]*)/", $chunks[1], $matches);
|
||||||
$id = $matches[1];
|
$id_agent = $id = $matches[1];
|
||||||
$type = ITEM_TYPE_AGENT_NETWORKMAP;
|
$type = ITEM_TYPE_AGENT_NETWORKMAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nodes[] = array('graph_id' => $graphviz_id,
|
$nodes[] = array('graph_id' => $graphviz_id,
|
||||||
'id' => $id, 'type' => $type);
|
'id' => $id, 'id_agent' => $id_agent,'type' => $type);
|
||||||
|
|
||||||
if ($last_graph_id < $graphviz_id)
|
if ($last_graph_id < $graphviz_id)
|
||||||
$last_graph_id = $graphviz_id;
|
$last_graph_id = $graphviz_id;
|
||||||
|
@ -260,7 +260,6 @@ MapController.prototype.get_edges_from_node = function(id_graph) {
|
|||||||
$.each(edges, function(i, edge) {
|
$.each(edges, function(i, edge) {
|
||||||
if ((edge['to'] == id_graph) || (edge['from'] == id_graph)) {
|
if ((edge['to'] == id_graph) || (edge['from'] == id_graph)) {
|
||||||
return_edges.push(edge);
|
return_edges.push(edge);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -288,6 +287,18 @@ MapController.prototype.get_arrow_from_id = function(id) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MapController.prototype.get_arrows_from_edges = function() {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
var return_var = [];
|
||||||
|
|
||||||
|
$.each(edges, function(i, e) {
|
||||||
|
return_var.push(self.get_arrow_from_id(e['graph_id']));
|
||||||
|
});
|
||||||
|
|
||||||
|
return return_var;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function get_arrow
|
* Function get_arrow
|
||||||
* Return void
|
* Return void
|
||||||
|
@ -145,26 +145,27 @@ NetworkmapController.prototype.get_arrows_AMA = function(id_to, id_from) {
|
|||||||
if (self.get_node_type(id_to) != self.get_node_type(id_from)) {
|
if (self.get_node_type(id_to) != self.get_node_type(id_from)) {
|
||||||
var arrow_AM = self.get_arrow(id_to, id_from);
|
var arrow_AM = self.get_arrow(id_to, id_from);
|
||||||
|
|
||||||
console.log("arrow_AM", arrow_AM);
|
|
||||||
|
|
||||||
var edges_temp = null;
|
var edges_temp = null;
|
||||||
var is_agent = null
|
var is_agent = null
|
||||||
|
|
||||||
if (self.get_node_type(id_to) == ITEM_TYPE_AGENT_NETWORKMAP) {
|
if (self.get_node_type(id_to) == ITEM_TYPE_AGENT_NETWORKMAP) {
|
||||||
edges_temp = self.get_edges_from_node(id_from);
|
if (arrow_AM['nodes']['from']['id_agent'] == arrow_AM['nodes']['to']['id']) {
|
||||||
is_agent = 'to';
|
edges_temp = self.get_edges_from_node(id_from);
|
||||||
|
is_agent = 'to';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (self.get_node_type(id_from) == ITEM_TYPE_AGENT_NETWORKMAP) {
|
else if (self.get_node_type(id_from) == ITEM_TYPE_AGENT_NETWORKMAP) {
|
||||||
edges_temp = self.get_edges_from_node(id_to);
|
if (arrow_AM['nodes']['to']['id_agent'] == arrow_AM['nodes']['from']['id']) {
|
||||||
is_agent = 'from';
|
edges_temp = self.get_edges_from_node(id_to);
|
||||||
|
is_agent = 'from';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("edges_temp", edges_temp);
|
|
||||||
|
|
||||||
if (edges_temp != null) {
|
if (edges_temp != null) {
|
||||||
$.each(edges_temp, function(i, edge) {
|
$.each(edges_temp, function(i, edge) {
|
||||||
// Filter same edge
|
// Filter same edge
|
||||||
if ((edge['to'] != id_to) && (edge['from'] != id_from)) {
|
if ((edge['to'] != id_to) || (edge['from'] != id_from)) {
|
||||||
|
|
||||||
var type_to = self.get_node_type(edge['to']);
|
var type_to = self.get_node_type(edge['to']);
|
||||||
var type_from = self.get_node_type(edge['from']);
|
var type_from = self.get_node_type(edge['from']);
|
||||||
@ -183,29 +184,28 @@ NetworkmapController.prototype.get_arrows_AMA = function(id_to, id_from) {
|
|||||||
|
|
||||||
temp['type'] = 'AMA';
|
temp['type'] = 'AMA';
|
||||||
|
|
||||||
temp['nodes'] = {};
|
|
||||||
switch (is_agent) {
|
switch (is_agent) {
|
||||||
case 'to':
|
case 'to':
|
||||||
temp['nodes']['to'] = arrow_AM['nodes']['to'];
|
temp['to'] = arrow_AM['nodes']['to'];
|
||||||
temp['to_module'] = arrow_AM['nodes']['from']['id'];
|
temp['to_module'] = arrow_AM['nodes']['from']['id'];
|
||||||
|
|
||||||
if (type_to == ITEM_TYPE_AGENT_NETWORKMAP) {
|
if (type_to == ITEM_TYPE_AGENT_NETWORKMAP) {
|
||||||
temp['nodes']['from'] = arrow['nodes']['to'];
|
temp['from'] = arrow['nodes']['to'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
temp['nodes']['from'] = arrow['nodes']['from'];
|
temp['from'] = arrow['nodes']['from'];
|
||||||
}
|
}
|
||||||
temp['from_module'] = null;
|
temp['from_module'] = null;
|
||||||
break;
|
break;
|
||||||
case 'from':
|
case 'from':
|
||||||
temp['nodes']['from'] = arrow_AM['nodes']['from'];
|
temp['from'] = arrow_AM['nodes']['from'];
|
||||||
temp['from_module'] = arrow_AM['nodes']['to']['id'];
|
temp['from_module'] = arrow_AM['nodes']['to']['id'];
|
||||||
|
|
||||||
if (type_to == ITEM_TYPE_AGENT_NETWORKMAP) {
|
if (type_to == ITEM_TYPE_AGENT_NETWORKMAP) {
|
||||||
temp['nodes']['to'] = arrow['nodes']['to'];
|
temp['to'] = arrow['nodes']['to'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
temp['nodes']['to'] = arrow['nodes']['from'];
|
temp['to'] = arrow['nodes']['from'];
|
||||||
}
|
}
|
||||||
temp['to_module'] = null;
|
temp['to_module'] = null;
|
||||||
break;
|
break;
|
||||||
@ -265,7 +265,6 @@ NetworkmapController.prototype.get_arrow_AA = function(id_to, id_from) {
|
|||||||
NetworkmapController.prototype.exists_arrow = function(arrows, arrow) {
|
NetworkmapController.prototype.exists_arrow = function(arrows, arrow) {
|
||||||
var var_return = false;
|
var var_return = false;
|
||||||
|
|
||||||
|
|
||||||
if (arrow === null) {
|
if (arrow === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -279,12 +278,35 @@ NetworkmapController.prototype.exists_arrow = function(arrows, arrow) {
|
|||||||
return true; // Continue
|
return true; // Continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a['type'] == arrow['type']) {
|
|
||||||
if (a['to']['graph_id'] == arrow['to']['graph_id'] &&
|
|
||||||
a['from']['graph_id'] == arrow['from']['graph_id']) {
|
|
||||||
|
|
||||||
var_return = true;
|
if (a['type'] == arrow['type']) {
|
||||||
return false; // Break
|
|
||||||
|
var a_to = a['to']['graph_id'];
|
||||||
|
var arrow_to = arrow['to']['graph_id'];
|
||||||
|
var a_from = a['from']['graph_id'];
|
||||||
|
var arrow_from = arrow['from']['graph_id'];
|
||||||
|
|
||||||
|
switch (arrow['type']) {
|
||||||
|
case 'AA':
|
||||||
|
case 'AMMA':
|
||||||
|
if (a_to == arrow_to) {
|
||||||
|
if (a_from == arrow_from) {
|
||||||
|
|
||||||
|
var_return = true;
|
||||||
|
return false; // Break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'AMA':
|
||||||
|
if ((a_to == arrow_to) && (a_from == arrow_from)) {
|
||||||
|
var_return = true;
|
||||||
|
return false; //Break;
|
||||||
|
}
|
||||||
|
else if ((a_to == arrow_from) && (a_from == arrow_to)) {
|
||||||
|
var_return = true;
|
||||||
|
return false; //Break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user