New maps in progress... (Tooltip buttons now have a function)

This commit is contained in:
Arturo Gonzalez 2016-02-24 16:44:37 +01:00
parent dce72cbca2
commit b7d4c97334
2 changed files with 37 additions and 26 deletions

View File

@ -29,6 +29,7 @@ if (is_ajax ()) {
$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');
$return_data = '';
@ -39,24 +40,27 @@ if (is_ajax ()) {
WHERE id_agente = " . $id_node_data);
$node_data = $node_data[0];
if (!empty($node_data)) {
$return_data .= '<div id="open_close_click_"' . $data_graph_id . '>';
$return_data .= '<span><strong>Agent: </strong>' . $node_data['nombre'] . '</span>';
/*-----------------PROVISIONAL, HABRÁ QUE METER ICONOS DE VERDAD------------------*/
/*-*/$return_data .= '<span class="close_click" onClick="close_button_tooltip()" style="float:right;">| X </span>';/*-*/
/*-*/$return_data .= '<span class="open_click" style="float:right;"> -> |</span>';/*-*/
/*--------------------------------------------------------------------------------*/
$link = $config['homeurl'] . 'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' . $node_data['id_agente'];
$return_data .= '<div id="agent_data_to_show_"' . $node_data['id_agente'] .'>';
$return_data .= '<span><strong>IP Addres: </strong>' . $node_data['direccion'] . '</span></br>';
$agent_os = db_get_row_sql("SELECT name FROM tconfig_os WHERE id_os = " . $node_data['id_os']);
$agent_os = $agent_os['name'];
$return_data .= '<span><strong>OS: </strong>' . $agent_os . ' ' . $node_data['os_version'] .'</span></br>';
$return_data .= '<span><strong>Description: </strong>' . $node_data['comentarios'] . '</span></br>';
$agent_group = db_get_row_sql("SELECT nombre FROM tgrupo WHERE id_grupo = " . $node_data['id_grupo']);
$agent_group = $agent_group['nombre'];
$return_data .= '<span><strong>Group: </strong>' . $agent_group . '</span></br>';
$return_data .= '<span><strong>Agent Version: </strong>' . $node_data['agent_version'] . '</span></br>';
$return_data .= '<span><strong>Last Contact: </strong>' . $node_data['ultimo_contacto'] . '</span></br>';
$return_data .= '<span><strong>Remote: </strong>' . $node_data['ultimo_contacto_remoto'] . '</span>';
$return_data .= '<div id="open_close_click_"' . $data_graph_id . '>';
$return_data .= '<span><strong>Agent: </strong>' . $node_data['nombre'] . '</span>';
$return_data .= '<span class="close_click" onClick="close_button_tooltip(\'' . $node_id . '\');" style="float:right;">| X </span>';
$return_data .= '<span class="open_click" onClick="javascript: open_in_another_window(\'' . $link . '\');" style="float:right;"> -> |</span>';
$return_data .= '</div>';
$return_data .= '<div>';
$return_data .= '<span><strong>IP Addres: </strong>' . $node_data['direccion'] . '</span></br>';
$agent_os = db_get_row_sql("SELECT name FROM tconfig_os WHERE id_os = " . $node_data['id_os']);
$agent_os = $agent_os['name'];
$return_data .= '<span><strong>OS: </strong>' . $agent_os . ' ' . $node_data['os_version'] .'</span></br>';
$return_data .= '<span><strong>Description: </strong>' . $node_data['comentarios'] . '</span></br>';
$agent_group = db_get_row_sql("SELECT nombre FROM tgrupo WHERE id_grupo = " . $node_data['id_grupo']);
$agent_group = $agent_group['nombre'];
$return_data .= '<span><strong>Group: </strong>' . $agent_group . '</span></br>';
$return_data .= '<span><strong>Agent Version: </strong>' . $node_data['agent_version'] . '</span></br>';
$return_data .= '<span><strong>Last Contact: </strong>' . $node_data['ultimo_contacto'] . '</span></br>';
$return_data .= '<span><strong>Remote: </strong>' . $node_data['ultimo_contacto_remoto'] . '</span>';
$return_data .= '</div>';
$return_data .= '</div>';
}
else {

View File

@ -222,7 +222,6 @@ MapController.prototype.init_events = function(principalObject) {
.on("click", function(d) {
if (d3.event.defaultPrevented) return;
self.tooltip_map_create(self, this);
});
@ -240,7 +239,6 @@ MapController.prototype.init_events = function(principalObject) {
}
function dragged(d) {
console.log("dragged");
var delta_x = d3.event.dx;
var delta_y = d3.event.dy;
@ -267,7 +265,6 @@ MapController.prototype.tooltip_map_create = function(self, target) {
var nodeTarget = $(target);
var spinner = $('#spinner_tooltip').html();
var nodeR = parseInt($("circle", nodeTarget).attr("r"));
nodeR = nodeR * self._zoomManager.scale(); // Apply zoom
var node_id = nodeTarget.attr("id");
@ -278,7 +275,7 @@ MapController.prototype.tooltip_map_create = function(self, target) {
if (this.containsTooltipId(node_id)) {
nodeTarget.tooltipster('content', spinner);
self.nodeData(data_id, type, self._id, data_graph_id, nodeTarget);
self.nodeData(data_id, type, self._id, data_graph_id, nodeTarget, node_id);
nodeTarget.tooltipster("option", "offsetX", nodeR);
nodeTarget.tooltipster("show");
}
@ -295,7 +292,7 @@ MapController.prototype.tooltip_map_create = function(self, target) {
content: spinner,
functionBefore: function(origin, continueTooltip) {
continueTooltip();
self.nodeData(data_id, type, self._id, data_graph_id, origin);
self.nodeData(data_id, type, self._id, data_graph_id, origin, node_id);
}
});
@ -335,13 +332,14 @@ Function nodeData
Return array(data)
This function returns the data of the node
*/
MapController.prototype.nodeData = function(data_id, type, id_map, data_graph_id, origin) {
MapController.prototype.nodeData = function(data_id, type, id_map, data_graph_id, origin, node_id) {
var params = {};
params["getNodeData"] = 1;
params["id_node_data"] = data_id;
params["type"] = type;
params["id_map"] = id_map;
params["data_graph_id"] = data_graph_id;
params["node_id"] = node_id;
params["page"] = "include/ajax/map.ajax";
jQuery.ajax ({
@ -363,6 +361,15 @@ Function close_button_tooltip
Return void
This function hide the tooltip
*/
function close_button_tooltip() {
console.log($(this));
function close_button_tooltip(node_id) {
$('#' + node_id).tooltipster("hide");
}
/**
Function open_in_another_window
Return void
This function open the node in extra window
*/
function open_in_another_window(link) {
window.open(link);
}