New maps in progress... (get node data)
This commit is contained in:
parent
bd736ea598
commit
cccce11f79
|
@ -30,9 +30,55 @@ if (is_ajax ()) {
|
||||||
$id_map = (int)get_parameter('id_map');
|
$id_map = (int)get_parameter('id_map');
|
||||||
$data_graph_id = (int)get_parameter('data_graph_id');
|
$data_graph_id = (int)get_parameter('data_graph_id');
|
||||||
|
|
||||||
$return_data = '<span>GOD SAVE FERMIN!!</span>';
|
$return_data = '';
|
||||||
|
|
||||||
sleep(2);
|
switch ($type) {
|
||||||
|
case ITEM_TYPE_AGENT_NETWORKMAP:
|
||||||
|
$node_data = db_get_all_rows_sql("SELECT *
|
||||||
|
FROM tagente
|
||||||
|
WHERE id_agente = " . $id_node_data);
|
||||||
|
$node_data = $node_data[0];
|
||||||
|
if (!empty($node_data)) {
|
||||||
|
$return_data .= '<div id="agent_data_to_show_"' . $node_data['id_agente'] .'>';
|
||||||
|
$return_data .= '<span><strong>Agent: </strong>' . $node_data['nombre'] . '</span></br>';
|
||||||
|
$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>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$return_data = '<span>No data to show</span>';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ITEM_TYPE_MODULE_NETWORKMAP:
|
||||||
|
$node_data = db_get_all_rows_sql("SELECT *
|
||||||
|
FROM tagente_modulo
|
||||||
|
WHERE id_agente_modulo = " . $id_node_data);
|
||||||
|
$node_data = $node_data[0];
|
||||||
|
if (!empty($node_data)) {
|
||||||
|
$return_data .= '<div id="module_data_to_show_"' . $node_data['id_agente'] .'>';
|
||||||
|
$return_data .= '<span><strong>Module: </strong>' . $node_data['nombre'] . '</span></br>';
|
||||||
|
$agent_module = db_get_row_sql("SELECT nombre FROM tagente WHERE id_agente = " . $node_data['id_agnte']);
|
||||||
|
$agent_module = $agent_module['nombre'];
|
||||||
|
$return_data .= '<span><strong>Agent: </strong>' . $agent_module . '</span></br>';
|
||||||
|
$return_data .= '<span><strong>Description: </strong>' . $node_data['descripcion'] . '</span>';
|
||||||
|
$return_data .= '</div>';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$return_data = '<span>No data to show</span>';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep(1);
|
||||||
echo json_encode($return_data);
|
echo json_encode($return_data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,22 +23,22 @@
|
||||||
|
|
||||||
abstract class Map {
|
abstract class Map {
|
||||||
protected $status = STATUS_OK;
|
protected $status = STATUS_OK;
|
||||||
|
|
||||||
protected $id = null;
|
protected $id = null;
|
||||||
|
|
||||||
protected $type = null;
|
protected $type = null;
|
||||||
protected $subtype = null;
|
protected $subtype = null;
|
||||||
protected $id_group = null;
|
protected $id_group = null;
|
||||||
protected $generation_method = null;
|
protected $generation_method = null;
|
||||||
|
|
||||||
protected $width = null;
|
protected $width = null;
|
||||||
protected $height = null;
|
protected $height = null;
|
||||||
|
|
||||||
protected $nodes = array();
|
protected $nodes = array();
|
||||||
protected $edges = array();
|
protected $edges = array();
|
||||||
|
|
||||||
protected $requires_js = null;
|
protected $requires_js = null;
|
||||||
|
|
||||||
public static function getName($id = null) {
|
public static function getName($id = null) {
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -47,39 +47,39 @@ abstract class Map {
|
||||||
return db_get_value('name', 'tmap', 'id', $id);
|
return db_get_value('name', 'tmap', 'id', $id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct($id) {
|
public function __construct($id) {
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
||||||
$this->requires_js = array();
|
$this->requires_js = array();
|
||||||
$this->requires_js[] = "include/javascript/d3.3.5.14.js";
|
$this->requires_js[] = "include/javascript/d3.3.5.14.js";
|
||||||
$this->requires_js[] = "include/javascript/map/MapController.js";
|
$this->requires_js[] = "include/javascript/map/MapController.js";
|
||||||
$this->requires_js[] = "include/javascript/jquery.tooltipster.js";
|
$this->requires_js[] = "include/javascript/jquery.tooltipster.js";
|
||||||
$this->requires_js[] = "include/javascript/jquery.svg.js";
|
$this->requires_js[] = "include/javascript/jquery.svg.js";
|
||||||
$this->requires_js[] = "include/javascript/jquery.svgdom.js";
|
$this->requires_js[] = "include/javascript/jquery.svgdom.js";
|
||||||
|
|
||||||
if (!$this->loadDB()) {
|
if (!$this->loadDB()) {
|
||||||
$this->status = STATUS_ERROR;
|
$this->status = STATUS_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processDBValues($dbValues) {
|
protected function processDBValues($dbValues) {
|
||||||
$this->type = (int)$dbValues['type'];
|
$this->type = (int)$dbValues['type'];
|
||||||
$this->subtype = (int)$dbValues['subtype'];
|
$this->subtype = (int)$dbValues['subtype'];
|
||||||
|
|
||||||
$this->id_group = (int)$dbValues['id_group'];
|
$this->id_group = (int)$dbValues['id_group'];
|
||||||
$this->generation_method = (int)$dbValues['generation_method'];
|
$this->generation_method = (int)$dbValues['generation_method'];
|
||||||
|
|
||||||
$this->width = (int)$dbValues['width'];
|
$this->width = (int)$dbValues['width'];
|
||||||
$this->height = (int)$dbValues['height'];
|
$this->height = (int)$dbValues['height'];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function loadDB() {
|
private function loadDB() {
|
||||||
$row = db_get_row_filter('tmap', array('id' => $this->id));
|
$row = db_get_row_filter('tmap', array('id' => $this->id));
|
||||||
|
|
||||||
if (empty($row))
|
if (empty($row))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (get_class($this)) {
|
switch (get_class($this)) {
|
||||||
case 'Networkmap':
|
case 'Networkmap':
|
||||||
Networkmap::processDBValues($row);
|
Networkmap::processDBValues($row);
|
||||||
|
@ -92,9 +92,9 @@ abstract class Map {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract function printJSInit();
|
abstract function printJSInit();
|
||||||
|
|
||||||
public function writeJSGraph() {
|
public function writeJSGraph() {
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -105,14 +105,14 @@ abstract class Map {
|
||||||
var temp = [];
|
var temp = [];
|
||||||
for (var i in nodes) { temp[parseInt(i)] = nodes[i];}
|
for (var i in nodes) { temp[parseInt(i)] = nodes[i];}
|
||||||
nodes = temp;
|
nodes = temp;
|
||||||
|
|
||||||
temp = [];
|
temp = [];
|
||||||
for (var i in edges) { temp[parseInt(i)] = edges[i];}
|
for (var i in edges) { temp[parseInt(i)] = edges[i];}
|
||||||
edges = temp;
|
edges = temp;
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show() {
|
public function show() {
|
||||||
// Tooltip css
|
// Tooltip css
|
||||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster.css\"/>" . "\n";
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster.css\"/>" . "\n";
|
||||||
|
@ -120,15 +120,19 @@ abstract class Map {
|
||||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-shadow.css\"/>" . "\n";
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-shadow.css\"/>" . "\n";
|
||||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-noir.css\"/>" . "\n";
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-noir.css\"/>" . "\n";
|
||||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-light.css\"/>" . "\n";
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-light.css\"/>" . "\n";
|
||||||
|
//Tooltips spinner
|
||||||
|
echo "<div id='spinner_tooltip' style='display:none;'>";
|
||||||
|
html_print_image('images/spinner.gif');
|
||||||
|
echo "</div>";
|
||||||
foreach ($this->requires_js as $js) {
|
foreach ($this->requires_js as $js) {
|
||||||
echo "<script type='text/javascript' src='$js'></script>" . "\n";
|
echo "<script type='text/javascript' src='$js'></script>" . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->writeJSContants();
|
$this->writeJSContants();
|
||||||
$this->writeJSGraph();
|
$this->writeJSGraph();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div id="map" data-id="<?php echo $this->id;?>" style="border: 1px red solid;">
|
<div id="map" data-id="<?php echo $this->id;?>" style="border: 1px red solid;">
|
||||||
<div class="zoom_box" style="">
|
<div class="zoom_box" style="">
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
|
@ -137,14 +141,14 @@ abstract class Map {
|
||||||
height: 210px;
|
height: 210px;
|
||||||
background: blue;
|
background: blue;
|
||||||
border-radius: 15px;
|
border-radius: 15px;
|
||||||
|
|
||||||
top: 100px;
|
top: 100px;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.vertical_range {
|
.vertical_range {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
-webkit-transform: rotate(270deg);
|
-webkit-transform: rotate(270deg);
|
||||||
|
@ -156,26 +160,26 @@ abstract class Map {
|
||||||
background: transparent !important;
|
background: transparent !important;
|
||||||
border: 0px !important;
|
border: 0px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vertical_range {
|
.vertical_range {
|
||||||
left: -92px;
|
left: -92px;
|
||||||
top: 93px;
|
top: 93px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (-webkit-min-device-pixel-ratio:0)
|
@media screen and (-webkit-min-device-pixel-ratio:0)
|
||||||
{
|
{
|
||||||
/* Only for chrome */
|
/* Only for chrome */
|
||||||
|
|
||||||
.vertical_range {
|
.vertical_range {
|
||||||
left: -87px;
|
left: -87px;
|
||||||
top: 93px;
|
top: 93px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.home_zoom {
|
.home_zoom {
|
||||||
top: 360px;
|
top: 360px;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
|
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
font-weight: bolder;
|
font-weight: bolder;
|
||||||
|
@ -189,11 +193,11 @@ abstract class Map {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
.zoom_in {
|
.zoom_in {
|
||||||
top: 10px;
|
top: 10px;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
|
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
position: relative;
|
position: relative;
|
||||||
font-weight: bolder;
|
font-weight: bolder;
|
||||||
|
@ -207,11 +211,11 @@ abstract class Map {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
.zoom_out {
|
.zoom_out {
|
||||||
top: 320px;
|
top: 320px;
|
||||||
left: 10px;
|
left: 10px;
|
||||||
|
|
||||||
display: table-cell;
|
display: table-cell;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
font-weight: bolder;
|
font-weight: bolder;
|
||||||
|
@ -250,11 +254,11 @@ abstract class Map {
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" pointer-events="all" width="<?php echo $width;?>" height="<?php echo $height;?>">
|
<svg xmlns="http://www.w3.org/2000/svg" pointer-events="all" width="<?php echo $width;?>" height="<?php echo $height;?>">
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$this->printJSInit();
|
$this->printJSInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function writeJSContants() {
|
public function writeJSContants() {
|
||||||
$contants = array();
|
$contants = array();
|
||||||
$contants["ITEM_TYPE_AGENT_NETWORKMAP"] = ITEM_TYPE_AGENT_NETWORKMAP;
|
$contants["ITEM_TYPE_AGENT_NETWORKMAP"] = ITEM_TYPE_AGENT_NETWORKMAP;
|
||||||
|
@ -270,7 +274,7 @@ abstract class Map {
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType() {
|
public function getType() {
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -170,7 +170,7 @@ MapController.prototype.init_map = function() {
|
||||||
|
|
||||||
|
|
||||||
self.paint_nodes();
|
self.paint_nodes();
|
||||||
|
|
||||||
this.init_events();
|
this.init_events();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -239,6 +239,7 @@ This function manages nodes tooltips
|
||||||
*/
|
*/
|
||||||
MapController.prototype.tooltip_map_create = function(self, event) {
|
MapController.prototype.tooltip_map_create = function(self, event) {
|
||||||
var nodeTarget = $(event.currentTarget).parent();
|
var nodeTarget = $(event.currentTarget).parent();
|
||||||
|
var spinner = $('#spinner_tooltip').html();
|
||||||
|
|
||||||
var nodeR = parseInt($(event.currentTarget).attr("r"));
|
var nodeR = parseInt($(event.currentTarget).attr("r"));
|
||||||
nodeR = nodeR * self._zoomManager.scale(); // Apply zoom
|
nodeR = nodeR * self._zoomManager.scale(); // Apply zoom
|
||||||
|
@ -249,7 +250,7 @@ MapController.prototype.tooltip_map_create = function(self, event) {
|
||||||
var data_graph_id = parseInt(nodeTarget.data("graph_id"));
|
var data_graph_id = parseInt(nodeTarget.data("graph_id"));
|
||||||
|
|
||||||
if (this.containsTooltipId(node_id)) {
|
if (this.containsTooltipId(node_id)) {
|
||||||
nodeTarget.tooltipster('content', 'Loading...');
|
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);
|
||||||
nodeTarget.tooltipster("option", "offsetX", nodeR);
|
nodeTarget.tooltipster("option", "offsetX", nodeR);
|
||||||
nodeTarget.tooltipster("show");
|
nodeTarget.tooltipster("show");
|
||||||
|
@ -263,7 +264,7 @@ MapController.prototype.tooltip_map_create = function(self, event) {
|
||||||
offsetX: nodeR,
|
offsetX: nodeR,
|
||||||
theme: 'tooltipster-noir',
|
theme: 'tooltipster-noir',
|
||||||
multiple: true,
|
multiple: true,
|
||||||
content: 'Loading...',
|
content: spinner,
|
||||||
functionBefore: function(origin, continueTooltip) {
|
functionBefore: function(origin, continueTooltip) {
|
||||||
continueTooltip();
|
continueTooltip();
|
||||||
self.nodeData(data_id, type, self._id, data_graph_id, origin);
|
self.nodeData(data_id, type, self._id, data_graph_id, origin);
|
||||||
|
|
Loading…
Reference in New Issue