Working in the update status of nodes.
This commit is contained in:
parent
725a4925a7
commit
e4a2c3c7fb
|
@ -27,6 +27,50 @@ if (is_ajax ()) {
|
|||
$getNodeDetails = (bool)get_parameter('getNodeDetails', 0);
|
||||
$printEditNodeTable = (bool)get_parameter('printEditNodeTable', 0);
|
||||
$printEditMapTable = (bool)get_parameter('printEditMapTable', 0);
|
||||
$refresh_nodes_open = (bool)get_parameter('refresh_nodes_open', 0);
|
||||
|
||||
if ($refresh_nodes_open) {
|
||||
$return = array();
|
||||
|
||||
$id_map = (int)get_parameter('id_map', 0);
|
||||
$nodes = (array)get_parameter('nodes', array());
|
||||
|
||||
|
||||
$status = agents_get_status($node);
|
||||
$status = 1;
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
switch ($status) {
|
||||
case AGENT_STATUS_NORMAL:
|
||||
$color = COL_NORMAL;
|
||||
break;
|
||||
case AGENT_STATUS_CRITICAL:
|
||||
$color = COL_CRITICAL;
|
||||
break;
|
||||
case AGENT_STATUS_WARNING:
|
||||
$color = COL_WARNING;
|
||||
break;
|
||||
case AGENT_STATUS_ALERT_FIRED:
|
||||
$color = COL_ALERTFIRED;
|
||||
break;
|
||||
# Juanma (05/05/2014) Fix: Correct color for not init agents!
|
||||
case AGENT_STATUS_NOT_INIT:
|
||||
$color = COL_NOTINIT;
|
||||
break;
|
||||
default:
|
||||
//Unknown monitor
|
||||
$color = COL_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
$return[$node] = array(
|
||||
'status' => $status,
|
||||
'color' => $color);
|
||||
}
|
||||
|
||||
echo json_encode($return);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($getNodeData) {
|
||||
$id_node_data = (int)get_parameter('id_node_data');
|
||||
|
|
|
@ -227,6 +227,8 @@ abstract class Map {
|
|||
|
||||
public function writeJSConstants() {
|
||||
$contants = array();
|
||||
$contants["MAP_REFRESH_TIME"] = MAP_REFRESH_TIME;
|
||||
|
||||
$contants["ITEM_TYPE_AGENT_NETWORKMAP"] = ITEM_TYPE_AGENT_NETWORKMAP;
|
||||
$contants["ITEM_TYPE_MODULE_NETWORKMAP"] = ITEM_TYPE_MODULE_NETWORKMAP;
|
||||
$contants["ITEM_TYPE_EDGE_NETWORKMAP"] = ITEM_TYPE_EDGE_NETWORKMAP;
|
||||
|
|
|
@ -264,6 +264,19 @@ MapController.prototype.get_node = function(id_graph) {
|
|||
return return_node;
|
||||
}
|
||||
|
||||
MapController.prototype.get_node_filter = function(field, value) {
|
||||
var return_node = null;
|
||||
|
||||
$.each(nodes, function(i, node) {
|
||||
if (node[field] == value) {
|
||||
return_node = node;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return return_node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function get_node_type
|
||||
* Return node type
|
||||
|
@ -1744,6 +1757,23 @@ MapController.prototype.events = function() {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
setTimeout(function() { self.refresh_map();}, MAP_REFRESH_TIME);
|
||||
}
|
||||
|
||||
MapController.prototype.refresh_map = function() {
|
||||
var self = this;
|
||||
|
||||
self.refresh_nodes();
|
||||
self.refresh_arrows();
|
||||
|
||||
setTimeout(function() { self.refresh_map();}, MAP_REFRESH_TIME);
|
||||
}
|
||||
|
||||
MapController.prototype.refresh_nodes = function() {
|
||||
}
|
||||
|
||||
MapController.prototype.refresh_arrows = function() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -371,18 +371,19 @@ NetworkmapController.prototype.exists_arrow = function(arrows, arrow) {
|
|||
return var_return;
|
||||
}
|
||||
|
||||
NetworkmapController.prototype.paint_node = function(g_node, node) {
|
||||
NetworkmapController.prototype.update_node = function(id) {
|
||||
var self = this;
|
||||
|
||||
var color;
|
||||
var node = self.get_node_filter('id', id);
|
||||
|
||||
switch (node['type']) {
|
||||
case ITEM_TYPE_AGENT_NETWORKMAP:
|
||||
//~ color =
|
||||
break;
|
||||
case ITEM_TYPE_FICTIONAL_NODE:
|
||||
break;
|
||||
}
|
||||
d3.select(self._target + "#node_" + id)
|
||||
.attr("data-status", node['status'])
|
||||
.attr("data-status_color", node['color'])
|
||||
.style("fill", node['color']);
|
||||
}
|
||||
|
||||
NetworkmapController.prototype.paint_node = function(g_node, node) {
|
||||
var self = this;
|
||||
|
||||
var d3_node = d3.select(g_node)
|
||||
.attr("transform", "translate(" + node['x'] + " " + node['y'] + ")")
|
||||
|
@ -392,6 +393,7 @@ NetworkmapController.prototype.paint_node = function(g_node, node) {
|
|||
.attr("data-id", node['id'])
|
||||
.attr("data-graph_id", node['graph_id'])
|
||||
.attr("data-type", node['type'])
|
||||
.attr("data-status", node['status'])
|
||||
.attr("data-status_color", node['color']);
|
||||
|
||||
switch (node['shape']) {
|
||||
|
@ -1130,7 +1132,7 @@ NetworkmapController.prototype.arrow_by_pieces_AMA = function(target, arrow_data
|
|||
else {
|
||||
var body_width = distance - arrow_tail_width - radius_to - radius_from;
|
||||
}
|
||||
|
||||
|
||||
transform = d3.transform();
|
||||
transform.scale[0] = body_width / arrow_body_width;
|
||||
|
||||
|
@ -1155,7 +1157,7 @@ NetworkmapController.prototype.arrow_by_pieces_AMA = function(target, arrow_data
|
|||
}
|
||||
else {
|
||||
transform = d3.transform();
|
||||
|
||||
|
||||
var arrow_body_t = d3.transform(arrow_body.attr("transform"));
|
||||
|
||||
var scale = arrow_body_t.scale[0];
|
||||
|
@ -1573,3 +1575,53 @@ NetworkmapController.prototype.update_interfaces_status = function (arrow_data)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NetworkmapController.prototype.refresh_nodes = function() {
|
||||
var self = this;
|
||||
|
||||
|
||||
var params = {};
|
||||
params["refresh_nodes_open"] = 1;
|
||||
params["id_map"] = self._id;
|
||||
params["page"] = "include/ajax/map.ajax2";
|
||||
var agent_nodes = $.grep(nodes,
|
||||
function(node) {
|
||||
if (node['type'] == 0) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
params['nodes'] = [];
|
||||
$.each(agent_nodes, function(i, node) {
|
||||
params['nodes'].push(node['id']);
|
||||
});
|
||||
|
||||
jQuery.ajax ({
|
||||
data: params,
|
||||
dataType: "JSON",
|
||||
type: "POST",
|
||||
url: "ajax.php",
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
$.each(nodes, function(i, node) {
|
||||
if (typeof(data[node['id']]) != "undefined") {
|
||||
nodes[i]['status'] = data[node['id']]['status'];
|
||||
nodes[i]['color'] = data[node['id']]['color'];
|
||||
|
||||
self.update_node(node['id']);
|
||||
}
|
||||
else {
|
||||
console.log("refresh_nodes undefined", node['id'], data[node['id']]);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
NetworkmapController.prototype.refresh_arrows = function() {
|
||||
var self = this;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue