Fixed the minimap.

This commit is contained in:
mdtrooper 2016-03-17 11:40:38 +01:00
parent f0d4ae7a9c
commit 5cc89d968c
2 changed files with 133 additions and 86 deletions

View File

@ -154,12 +154,14 @@ if (is_ajax ()) {
}
else if ($getNodeDetails) {
$id_node_data = (int)get_parameter('id_node_data');
$type = (int)get_parameter('type');
$id_map = (int)get_parameter('id_map');
$data_graph_id = (int)get_parameter('data_graph_id');
$node_id = get_parameter('node_id');
ob_start();
?>
<div id="details_{data_graph_id}">
<div id="tooltip_{data_graph_id}">
<div class="title_bar">
<span class="title">{title}</span>
</div>
@ -170,68 +172,102 @@ if (is_ajax ()) {
<?php
$details = ob_get_clean();
$details = str_replace(
"{data_graph_id}",
$data_graph_id,
$details);
$details = str_replace(
"{node_id}",
$node_id,
$details);
$details = str_replace(
"{title}",
agents_get_name($id_node_data),
$details);
$agent_modules = agents_get_modules($id_node_data);
$agent_modules = array_keys($agent_modules);
$agent_interval = agents_get_interval ($id_node_data);
$table = new stdClass();
$table->width = '100%';
$table->class = 'databox data';
$table->head = array ();
$table->head[0] = __('Name');
$table->head[1] = __('Description');
$table->head[2] = __('Type');
$table->head[3] = __('Interval');
$table->head[4] = __('Status');
$table->rowstyle = array();
$table->style = array ();
$table->style[0] = 'font-weight: bold';
$table->align = array ();
$table->align[0] = 'center';
$table->align[1] = 'center';
$table->align[2] = 'center';
$table->align[3] = 'center';
$table->align[4] = 'center';
$table->data = array ();
foreach ($agent_modules as $module) {
$data = array ();
$status = '';
$title = '';
$module_data = db_get_all_rows_sql("SELECT nombre, id_tipo_modulo, descripcion, module_interval
FROM tagente_modulo WHERE id_agente_modulo = " . $module);
$module_data = $module_data[0];
$module_status = db_get_row('tagente_estado', 'id_agente_modulo', $module);
modules_get_status($module_status['id_agente_modulo'], $module_status['estado'], $module_status['datos'], $status, $title);
$data[0] = $module_data['nombre'];
$data[1] = $module_data['descripcion'];
$data[2] = '';
$type = $module_data['id_tipo_modulo'];
if ($type) {
$data[2] = ui_print_moduletype_icon($type, true);
}
if ($module_data['module_interval']) {
$data[3] = human_time_description_raw($module_data['module_interval']);
}
else {
$data[3] = human_time_description_raw($agent_interval);
}
$data[4] = ui_print_status_image($status, $title, true);;
array_push ($table->data, $data);
switch ($type) {
case ITEM_TYPE_AGENT_NETWORKMAP:
$details = str_replace(
"{data_graph_id}",
$data_graph_id,
$details);
$details = str_replace(
"{node_id}",
$node_id,
$details);
$details = str_replace(
"{title}",
agents_get_name($id_node_data),
$details);
$agent_group = groups_get_name(
db_get_value('id_grupo', 'tagente', 'id_agente', $id_node_data));
ob_start();
?>
<span>
<strong><?php echo __('IP Address');?>: </strong>
<?php echo agents_get_address($id_node_data);?>
</span><br />
<span>
<strong><?php echo __('OS');?>: </strong>
<?php echo os_get_name(agents_get_os($id_node_data));?>
</span><br />
<span>
<strong><?php echo __('Description');?>: </strong>
<?php echo db_get_value('comentarios', 'tagente', 'id_agente', $id_node_data);?>
</span> <br/>
<span>
<strong><?php echo __('Group');?>: </strong>
<?php echo $agent_group;?>
</span><br />
<span>
<strong><?php echo __('Agent Version');?>: </strong>
<?php echo db_get_value('agent_version', 'tagente', 'id_agente', $id_node_data);?>
</span><br />
<span>
<strong><?php echo __('Last Contact');?>: </strong>
<?php echo db_get_value('ultimo_contacto', 'tagente', 'id_agente', $id_node_data);?>
</span><br />
<span>
<strong><?php echo __('Remote');?>: </strong>
<?php echo db_get_value('ultimo_contacto_remoto', 'tagente', 'id_agente', $id_node_data);?>
</span>
<?php
$body = ob_get_clean();
$details = str_replace(
"{body}",
$body,
$details);
break;
case ITEM_TYPE_MODULE_NETWORKMAP:
$node_data = db_get_all_rows_sql("SELECT descripcion
FROM tagente_modulo
WHERE id_agente_modulo = " . $id_node_data);
$node_data = $node_data[0];
$details = str_replace(
"{data_graph_id}",
$data_graph_id,
$details);
$details = str_replace(
"{node_id}",
$node_id,
$details);
$details = str_replace(
"{title}",
modules_get_agentmodule_name($id_node_data),
$details);
ob_start();
?>
<span>
<strong><?php echo __('Agent Name');?>: </strong>
<?php echo agents_get_name(modules_get_agentmodule_agent($id_node_data));?>
</span> <br/>
<span>
<strong><?php echo __('Description');?>: </strong>
<?php echo db_get_value('descripcion', 'tagente_modulo', 'id_agente_modulo', $id_node_data);?>
</span> <br/>
<?php
$body = ob_get_clean();
$details = str_replace(
"{body}",
$body,
$details);
break;
}
$body = html_print_table ($table, true);

View File

@ -184,11 +184,11 @@ MapController.prototype.init_map = function() {
MapController.prototype.minimap_get_size = function() {
var self = this;
var map_size = d3.select(self._target).node().getBoundingClientRect();
var map_size = d3.select(self._target + " .minimap").node().getBBox();
var minimap_size = [];
minimap_size[0] = map_size.width / RELATION_MINIMAP;
minimap_size[1] = map_size.height / RELATION_MINIMAP;
minimap_size[0] = map_size.width;
minimap_size[1] = map_size.height;
return minimap_size;
}
@ -344,11 +344,11 @@ MapController.prototype.event_toggle_minimap = function() {
MapController.prototype.paint_minimap = function() {
var self = this;
var map_size = d3.select(self._target).node().getBoundingClientRect();
var viewport_size = d3.select(self._target + " .viewport").node().getBBox();
var screen_size = d3.select(self._target).node().getBoundingClientRect();
var map_size = d3.select(self._target + " .viewport").node().getBBox();
var minimap_map_width = map_size.width / RELATION_MINIMAP;
var minimap_map_height = map_size.height / RELATION_MINIMAP;
var minimap_map_width = (map_size.width + map_size.x) / RELATION_MINIMAP;
var minimap_map_height = (map_size.height + map_size.y) / RELATION_MINIMAP;
var minimap = d3.select(self._target + " .minimap");
var svg = d3.select(self._target + " svg");
@ -356,7 +356,8 @@ MapController.prototype.paint_minimap = function() {
var transform = d3.transform();
// Move the minimap to the right upper corner
transform.translate[0] = map_size.width - minimap_map_width;
transform.translate[0] = screen_size.width - minimap_map_width;
transform.translate[1] = 0;
minimap.attr("transform", transform.toString());
svg.append("defs")
@ -376,34 +377,41 @@ MapController.prototype.paint_minimap = function() {
.attr("height", minimap_map_height)
.attr("style", "fill: #ffffff; stroke: #000000; stroke-width: 1;");
transform = d3.transform();
transform.scale[0] = 1 / RELATION_MINIMAP;
transform.scale[1] = 1 / RELATION_MINIMAP;
var minimap_layer = minimap
.append("g")
.attr("class", "clip_minimap")
.attr("clip-path", "url(#clip_minimap)")
.append("g")
.attr("class", "layer");
.attr("class", "map")
.attr("transform", transform.toString());
var minimap_viewport = minimap_layer.append("g")
.attr("id", "viewport");
minimap_viewport.append("rect")
.attr("style", "fill: #dddddd; stroke: #aaaaaa; stroke-width: 1;")
.attr("x", 0)
.attr("y", 0)
.attr("height", viewport_size.width)
.attr("width", viewport_size.height);
//~ var minimap_viewport = minimap_layer.append("g")
//~ .attr("id", "viewport");
//~
//~ minimap_viewport.append("rect")
//~ .attr("style", "fill: #dddddd; stroke: #aaaaaa; stroke-width: 1;")
//~ .attr("x", 0)
//~ .attr("y", 0)
//~ .attr("height", screen_size.height)
//~ .attr("width", screen_size.width);
//~
self.paint_toggle_button();
self.paint_items_minimap();
self.zoom_minimap();
//~
//~ self.zoom_minimap();
}
MapController.prototype.paint_items_minimap = function() {
var self = this;
var minimap_viewport = d3.select(self._target + " .minimap #viewport");
var minimap_viewport = d3.select(self._target + " .minimap .map");
minimap_viewport.selectAll(".node")
.data(
@ -422,6 +430,7 @@ MapController.prototype.paint_items_minimap = function() {
function(d) {
var x = d['x'];
var y = d['y'];
return "translate(" + x + " " + y + ")";
})
.attr("class", "node")
@ -430,8 +439,10 @@ MapController.prototype.paint_items_minimap = function() {
.attr("data-graph_id", function(d) { return d['graph_id'];})
.attr("data-type", function(d) { return d['type'];})
.append("circle")
.attr("style", "fill: #000000;")
.attr("r", 15);
.attr("style", "fill: rgb(50, 50, 128);")
.attr("x", -8)
.attr("y", -8)
.attr("r", 16);
}
MapController.prototype.zoom_minimap = function() {