#8458 Fixed errors

This commit is contained in:
Daniel Maya 2022-03-30 10:21:30 +02:00
parent 270bb433da
commit cab85cbfbd
4 changed files with 115 additions and 56 deletions

View File

@ -38,7 +38,7 @@ if (is_ajax() === true) {
$type = get_parameter('type', 0);
if ($getFilters === true) {
$refresh = get_parameter('refresh', 30);
$refresh = get_parameter('refresh', 180);
$search = get_parameter('search', '');
$group = get_parameter('group', true);
@ -117,6 +117,7 @@ if (is_ajax() === true) {
'return' => true,
'required' => true,
'privilege' => 'AR',
'multiple' => true,
]
);
break;
@ -186,28 +187,20 @@ if (is_ajax() === true) {
break;
case 2:
$module_groups = modules_get_modulegroups();
// $module_groups[0] = _('Not assigned');
// hd(current($filter));
echo '<p class="label-dialog">'.__('Module group').'</p>';
echo html_print_select(
$module_groups,
echo html_print_select_from_sql(
'SELECT id_mg, name FROM tmodule_group ORDER BY name',
'filter[]',
$filter,
'',
_('Not assigned'),
0,
__('Not assigned'),
'0',
true,
true,
true,
false,
false,
'',
false,
'width: 70%',
false,
false,
false,
'',
true
'width: 200px',
'5'
);
break;
}
@ -216,20 +209,28 @@ if (is_ajax() === true) {
}
if ($getInfo === true) {
enterprise_include_once('include/functions_agents.php');
$id = get_parameter('id', 0);
switch ($type) {
case 2:
$data = db_get_row('tagente_modulo', 'id_agente_modulo', $id);
// Nombre.
$link = sprintf(
'index.php?sec=view&sec2=operation/agentes/status_monitor%s&ag_modulename=%s',
'&refr=0&ag_group=0&module_option=1&status=-1',
$data['nombre']
);
echo '<div class="div-dialog">';
echo '<p class="title-dialog">'.__('Module name').'</p>';
echo '<a class="info-dialog">'.$data['nombre'].'</a>';
echo '<a href="'.$link.'" class="info-dialog">'.$data['nombre'].'</a>';
echo '</div>';
// Descripcion.
$description = (empty($data['descripcion']) === true) ? '-' : $data['descripcion'];
echo '<div class="div-dialog">';
echo '<p class="title-dialog">'.__('Description').'</p>';
echo '<p class="info-dialog">'.$data['descripcion'].'</p>';
echo '<p class="info-dialog">'.$description.'</p>';
echo '</div>';
// Agent.
@ -240,24 +241,35 @@ if (is_ajax() === true) {
echo '</div>';
// Group.
$group = (empty($data['id_module_group']) === true)
? '-'
: modules_get_modulegroup_name($data['id_module_group']);
echo '<div class="div-dialog">';
echo '<p class="title-dialog">'.__('Group').'</p>';
echo '<p class="info-dialog">'.modules_get_modulegroup_name($data['id_module_group']).'</p>';
echo '<p class="title-dialog">'.__('Module group').'</p>';
echo '<p class="info-dialog">'.$group.'</p>';
echo '</div>';
break;
case 1:
$data = db_get_row('tagente_modulo', 'id_agente_modulo', $id);
// Nombre.
$link = sprintf(
'index.php?sec=view&sec2=operation/agentes/status_monitor%s&ag_modulename=%s',
'&refr=0&ag_group=0&module_option=1&status=-1',
$data['nombre']
);
echo '<div class="div-dialog">';
echo '<p class="title-dialog">'.__('Module name').'</p>';
echo '<a class="info-dialog">'.$data['nombre'].'</a>';
echo '<a href="'.$link.'" class="info-dialog" target="_blank">'.$data['nombre'].'</a>';
echo '</div>';
// Descripcion.
$description = (empty($data['descripcion']) === true) ? '-' : $data['descripcion'];
echo '<div class="div-dialog">';
echo '<p sclass="title-dialog">'.__('Description').'</p>';
echo '<p class="info-dialog">'.$data['descripcion'].'</p>';
echo '<p class="title-dialog">'.__('Description').'</p>';
echo '<p class="info-dialog">'.$description.'</p>';
echo '</div>';
// Agent.
@ -268,9 +280,13 @@ if (is_ajax() === true) {
echo '</div>';
// Group.
$group = (empty($data['id_module_group']) === true)
? '-'
: modules_get_modulegroup_name($data['id_module_group']);
echo '<div class="div-dialog">';
echo '<p class="title-dialog">'.__('Group').'</p>';
echo '<p class="info-dialog">'.modules_get_modulegroup_name($data['id_module_group']).'</p>';
echo '<p class="title-dialog">'.__('Module group').'</p>';
echo '<p class="info-dialog">'.$group.'</p>';
echo '</div>';
// Tag.
@ -317,17 +333,25 @@ if (is_ajax() === true) {
echo '</div>';
// Group.
$secondary_groups = '';
$secondary = agents_get_secondary_groups($data['id_agente']);
if (isset($secondary['for_select']) === true && empty($secondary['for_select']) === false) {
$secondary_groups = implode(', ', $secondary['for_select']);
$secondary_groups = ', '.$secondary_groups;
}
echo '<div class="div-dialog">';
echo '<p class="title-dialog">'.__('Group').'</p>';
echo '<p class="info-dialog">'.groups_get_name($data['id_grupo']).'</p>';
echo '<p class="info-dialog">'.groups_get_name($data['id_grupo']).$secondary_groups.'</p>';
echo '</div>';
// Events.
echo '<div class="div-dialog">';
echo graph_graphic_agentevents(
$id,
100,
80,
40,
SECONDS_1DAY,
'',
true,

View File

@ -112,7 +112,7 @@ class Heatmap
int $type=0,
array $filter=[],
string $randomId=null,
int $refresh=300,
int $refresh=180,
int $width=0,
int $height=0,
string $search=null,
@ -230,6 +230,8 @@ class Heatmap
},
(refresh * 1000)
);
} else {
location.reload();
}
}
});
@ -307,8 +309,7 @@ class Heatmap
$id_grupo = '';
if (empty($this->filter) === false && current($this->filter) != 0) {
$filter['id_grupo'] = current($this->filter);
$id_grupo = ' AND id_grupo = '.current($this->filter);
$id_grupo = ' AND id_grupo IN ('.implode(',', $this->filter).')';
}
// All agents.
@ -380,7 +381,7 @@ class Heatmap
{
$filter_group = '';
if (empty($this->filter) === false && current($this->filter) != -1) {
$filter_group = 'AND am.id_module_group ='.current($this->filter);
$filter_group = 'AND am.id_module_group IN ('.implode(',', $this->filter).')';
}
$filter_name = '';
@ -477,9 +478,8 @@ class Heatmap
{
$filter_tag = '';
if (empty($this->filter) === false && $this->filter[0] !== '0') {
foreach ($this->filter as $key => $value) {
$filter_tag .= ' AND tm.id_tag ='.$value;
}
$tags = implode(',', $this->filter);
$filter_tag .= ' AND tm.id_tag IN ('.$tags.')';
}
$filter_name = '';
@ -680,11 +680,22 @@ class Heatmap
{
$result = $this->getData();
$scale = ($this->width / $this->height);
if (empty($result) === true) {
echo '<div style="position: absolute; top:70px; left:20px">'.__('No data found').'</div>';
return;
}
$Yaxis = $this->getYAxis(count($result), $scale);
$count_result = count($result);
$scale = ($this->width / $this->height);
$Yaxis = $this->getYAxis($count_result, $scale);
if ($count_result <= 3) {
$Xaxis = $count_result;
$Yaxis = 1;
} else {
$Xaxis = (int) ceil($Yaxis * $scale);
$Yaxis = ceil($Yaxis);
}
$viewBox = sprintf(
'0 0 %d %d',
@ -728,7 +739,7 @@ class Heatmap
modal: true,
closeOnEscape: true,
height: 400,
width: 430,
width: 530,
title: '<?php echo __('Info'); ?>',
open: function() {
$.ajax({
@ -755,7 +766,15 @@ class Heatmap
$x_back = 0;
$y_back = 0;
echo '<polyline points="0,0 '.$Xaxis.',0" class="polyline" />';
if ($count_result <= 100) {
$fontSize = 'small-size';
$stroke = 'small-stroke';
} else {
$fontSize = 'big-size';
$stroke = 'big-stroke';
}
echo '<polyline points="0,0 '.$Xaxis.',0" class="polyline '.$stroke.'" />';
foreach ($groups as $key => $group) {
$name = '';
switch ($this->type) {
@ -786,7 +805,7 @@ class Heatmap
($y_back + 1)
);
echo '<polyline points="'.$points.'" class="polyline" />';
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
}
$points = sprintf(
@ -799,11 +818,11 @@ class Heatmap
$y_back
);
echo '<polyline points="'.$points.'" class="polyline" />';
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
// Name.
echo '<text x="'.((($x_position - $x_back) / 2) + $x_back).'" y="'.($y_position + 1).'"
dominant-baseline="middle" style="font-size:0.4">'.$name.'</text>';
class="'.$fontSize.'">'.$name.'</text>';
$x_back = $x_position;
if ($x_position === $Xaxis) {
@ -815,7 +834,7 @@ class Heatmap
($y_back + 1)
);
echo '<polyline points="'.$points.'" class="polyline" />';
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
$y_back++;
$x_back = 0;
@ -838,7 +857,7 @@ class Heatmap
($y_position)
);
echo '<polyline points="'.$points.'" class="polyline" />';
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
}
// Bottom of last line.
@ -850,11 +869,11 @@ class Heatmap
($y_position + 1)
);
echo '<polyline points="'.$points.'" class="polyline" />';
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
// Name.
echo '<text x="'.(($x_position) / 2).'" y="'.($y_position + 1).'"
dominant-baseline="middle" style="font-size:0.4">'.$name.'</text>';
class="'.$fontSize.'">'.$name.'</text>';
// Bottom-right of last line.
$points = sprintf(
@ -865,7 +884,7 @@ class Heatmap
($y_position + 1)
);
echo '<polyline points="'.$points.'" class="polyline" />';
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
if ($x_position > $x_back) {
// Bottom-top of last line.
@ -877,7 +896,7 @@ class Heatmap
($y_position)
);
echo '<polyline points="'.$points.'" class="polyline" />';
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
}
} else {
// Two or more lines.
@ -896,7 +915,7 @@ class Heatmap
($y_position + 1)
);
echo '<polyline points="'.$points.'" class="polyline" />';
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
// Bottom-right of last line.
$points = sprintf(
@ -907,11 +926,11 @@ class Heatmap
($y_position + 1)
);
echo '<polyline points="'.$points.'" class="polyline" />';
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
// Name.
echo '<text x="'.(($x_position) / 2).'" y="'.($y_position + 1).'"
dominant-baseline="middle" style="font-size:0.4">'.$name.'</text>';
class="'.$fontSize.'">'.$name.'</text>';
// Bottom-top of last line.
$points = sprintf(
@ -922,7 +941,7 @@ class Heatmap
($y_position)
);
echo '<polyline points="'.$points.'" class="polyline" />';
echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />';
}
if ($x_position === $Xaxis) {

View File

@ -253,3 +253,19 @@ div#heatmap-controls div.heatmap-refr > div {
stroke: black;
stroke-width: 0.05;
}
.small-stroke {
stroke-width: 0.03;
}
.big-stroke {
stroke-width: 0.05;
}
.small-size {
font-size: 0.2px;
}
.big-size {
font-size: 0.4px;
}

View File

@ -45,7 +45,7 @@ require_once $config['homedir'].'/include/class/Heatmap.class.php';
$pure = (bool) get_parameter('pure', false);
$type = get_parameter('type', 0);
$randomId = get_parameter('randomId', null);
$refresh = get_parameter('refresh', 30);
$refresh = get_parameter('refresh', 180);
$height = get_parameter('height', 0);
$width = get_parameter('width', 0);
$search = get_parameter('search', '');
@ -274,7 +274,7 @@ if ($is_ajax === true) {
draggable: false,
modal: true,
closeOnEscape: true,
height: 370,
height: 410,
width: 330,
title: '<?php echo __('Config'); ?>',
position: {