Added lost code

This commit is contained in:
Arturo Gonzalez 2017-10-26 16:13:27 +02:00
parent b96b50129c
commit 139db28eca
4 changed files with 401 additions and 9 deletions

View File

@ -2194,8 +2194,6 @@ function setEventsBar(id_data, values) {
if (data['no_data'] == true) {
if (values['width'] == "0" || values['height'] == "0") {
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/module-events.png');
$("#" + id_data + " img").css('width', '500px');
$("#" + id_data + " img").css('height', '40px');
}
else {
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/module-events.png');
@ -2207,8 +2205,8 @@ function setEventsBar(id_data, values) {
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/module-events.png');
if($('#text-width').val() == 0 || $('#text-height').val() == 0){
$("#" + id_data + " img").css('width', '500px');
$("#" + id_data + " img").css('height', '40px');
$("#" + id_data + " img").css('width', '300px');
$("#" + id_data + " img").css('height', '180px');
}
else{
$("#" + id_data + " img").css('width', $('#text-width').val()+'px');

View File

@ -104,6 +104,7 @@ $width_percentile = get_parameter('width_percentile', null);
$max_percentile = get_parameter('max_percentile', null);
$height_module_graph = get_parameter('height_module_graph', null);
$width_module_graph = get_parameter('width_module_graph', null);
$bars_graph_type = get_parameter('bars_graph_type', null);
$id_agent_module = get_parameter('id_agent_module', 0);
$process_simple_value = get_parameter('process_simple_value', PROCESS_VALUE_NONE);
$type_percentile = get_parameter('type_percentile', 'percentile');
@ -143,6 +144,39 @@ switch ($action) {
$return['font'] = $config['fontpath'];
echo json_encode($return);
break;
case 'get_module_type_string':
$data = array ();
$layoutData = db_get_row_filter('tlayout_data', array('id' => $id_element));
if ($layoutData['id_metaconsole'] != 0) {
$connection = db_get_row_filter ('tmetaconsole_setup', $layoutData['id_metaconsole']);
if (metaconsole_load_external_db($connection) != NOERR) {
continue;
}
}
$is_string = db_get_value_filter ('id_tipo_modulo', 'tagente_modulo',
array ('id_agente' => $id_agent,
'id_agente_modulo' => $id_module));
if ($layoutData['id_metaconsole'] != 0) {
metaconsole_restore_db();
}
$return = array();
if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) ||
($is_string == 10) || ($is_string == 33)) {
$return['no_data'] = false;
}
else {
$return['no_data'] = true;
}
echo json_encode($return);
break;
case 'get_module_events':
$data = array ();
@ -593,6 +627,17 @@ switch ($action) {
$values['id_custom_graph'] = $id_custom_graph;
}
break;
case 'bars_graph':
if ($width_percentile !== null) {
$values['width'] = $width_percentile;
}
if ($bars_graph_type !== null) {
$values['type_graph'] = $bars_graph_type;
}
if ($background_color !== null) {
$values['image'] = $background_color;
}
break;
case 'percentile_item':
case 'percentile_bar':
if ($action == 'update') {
@ -665,6 +710,10 @@ switch ($action) {
unset($values['image']);
unset($values['type_graph']);
break;
case 'bars_graph':
unset($values['image']);
unset($values['type_graph']);
break;
case 'box_item':
unset($values['border_width']);
unset($values['border_color']);
@ -722,6 +771,7 @@ switch ($action) {
case 'static_graph':
case 'group_item':
case 'module_graph':
case 'bars_graph':
case 'simple_value':
case 'label':
case 'icon':
@ -811,6 +861,10 @@ switch ($action) {
$elementFields['width_module_graph'] = $elementFields['width'];
$elementFields['height_module_graph'] = $elementFields['height'];
break;
case 'bars_graph':
$elementFields['width_percentile'] = $elementFields['width'];
$elementFields['bars_graph_type'] = $elementFields['type_graph'];
break;
case 'box_item':
$elementFields['width_box'] = $elementFields['width'];
$elementFields['height_box'] = $elementFields['height'];
@ -947,6 +1001,17 @@ switch ($action) {
}
$values['period'] = $period;
break;
case 'bars_graph':
$values['type'] = BARS_GRAPH;
if ($width_percentile == null) {
$values['width'] = 0;
}
else {
$values['width'] = $width_percentile;
}
$values['type_graph'] = $bars_graph_type;
$values['image'] = $background_color;
break;
case 'auto_sla_graph':
$values['type'] = AUTO_SLA_GRAPH;
$values['period'] = $event_max_time_row;

View File

@ -378,6 +378,9 @@ function visual_map_print_item($mode = "read", $layoutData,
$link = true;
}
break;
case BARS_GRAPH:
$link = true;
break;
case AUTO_SLA_GRAPH:
$link = true;
@ -1096,6 +1099,274 @@ function visual_map_print_item($mode = "read", $layoutData,
}
break;
case BARS_GRAPH:
$imgpos = '';
if($layoutData['label_position']=='left'){
$imgpos = 'float:right';
}
else if($layoutData['label_position']=='right'){
$imgpos = 'float:left';
}
if (!empty($proportion)) {
$width =
((integer)($proportion['proportion_width'] * $width));
$height =
((integer)($proportion['proportion_height'] * $height));
}
//Metaconsole db connection
if ($layoutData['id_metaconsole'] != 0) {
$connection = db_get_row_filter ('tmetaconsole_setup',
array('id' => $layoutData['id_metaconsole']));
if (metaconsole_load_external_db($connection) != NOERR) {
continue;
}
}
if ($isExternalLink)
$homeurl = $config['homeurl'];
else
$homeurl = '';
$is_string = db_get_value_filter ('id_tipo_modulo', 'tagente_modulo',
array ('id_agente' => $layoutData['id_agent'],
'id_agente_modulo' => $id_module));
if ( (get_parameter('action') == 'edit') || (get_parameter('operation') == 'edit_visualmap') ) {
if($width == 0){
if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) ||
($is_string == 10) || ($is_string == 33)) {
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/barras.png" style="width:400px;height:400px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/barras.png" style="width:400px;height:400px;'.$imgpos.'">';
}
}
else {
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/barras-no.png" style="width:400px;height:400px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/barras-no.png" style="width:400px;height:400px;'.$imgpos.'">';
}
}
}
else{
if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) ||
($is_string == 10) || ($is_string == 33)) {
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/barras.png" style="width:'.$width.'px;height:'.$width.'px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/barras.png" style="width:'.$width.'px;height:'.$width.'px;'.$imgpos.'">';
}
}
else {
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/barras-no.png" style="width:'.$width.'px;height:'.$width.'px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/barras-no.png" style="width:'.$width.'px;height:'.$width.'px;'.$imgpos.'">';
}
}
}
}
else {
if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) ||
($is_string == 10) || ($is_string == 33)) {
$color = array();
$color[0] = array('border' => '#000000',
'color' => $config['graph_color1'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[1] = array('border' => '#000000',
'color' => $config['graph_color2'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[2] = array('border' => '#000000',
'color' => $config['graph_color3'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[3] = array('border' => '#000000',
'color' => $config['graph_color4'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[4] = array('border' => '#000000',
'color' => $config['graph_color5'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[5] = array('border' => '#000000',
'color' => $config['graph_color6'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[6] = array('border' => '#000000',
'color' => $config['graph_color7'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[7] = array('border' => '#000000',
'color' => $config['graph_color8'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[8] = array('border' => '#000000',
'color' => $config['graph_color9'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[9] = array('border' => '#000000',
'color' => $config['graph_color10'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[11] = array('border' => '#000000',
'color' => COL_GRAPH9,
'alpha' => CHART_DEFAULT_ALPHA);
$color[12] = array('border' => '#000000',
'color' => COL_GRAPH10,
'alpha' => CHART_DEFAULT_ALPHA);
$color[13] = array('border' => '#000000',
'color' => COL_GRAPH11,
'alpha' => CHART_DEFAULT_ALPHA);
$color[14] = array('border' => '#000000',
'color' => COL_GRAPH12,
'alpha' => CHART_DEFAULT_ALPHA);
$color[15] = array('border' => '#000000',
'color' => COL_GRAPH13,
'alpha' => CHART_DEFAULT_ALPHA);
$module_data = get_bars_module_data($id_module);
$water_mark = array('file' => '/var/www/html/pandora_console/images/logo_vertical_water.png',
'url' => 'http://localhost/pandora_console/images/logo_vertical_water.png');
if ($width == 0) {
if ($layoutData['label_position']=='left') {
if ($layoutData['type_graph'] == 'horizontal') {
$img = '<div style="float:right;height:'.$himg.'px;">'.
hbar_graph(true, $module_data,
400, 400, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image']) . '</div>';
}
else {
$img = '<div style="float:right;height:'.$himg.'px;">'.
vbar_graph(true, $module_data,
400, 400, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image'], true) . '</div>';
}
}
elseif($layoutData['label_position']=='right') {
if ($layoutData['type_graph'] == 'horizontal') {
$img = '<div style="float:left;height:'.$himg.'px;">'.
hbar_graph(true, $module_data,
400, 400, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image']) . '</div>';
}
else {
$img = '<div style="float:left;height:'.$himg.'px;">'.
vbar_graph(true, $module_data,
400, 400, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image'], true) . '</div>';
}
}
else {
if ($layoutData['type_graph'] == 'horizontal') {
$img = hbar_graph(true, $module_data,
400, 400, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image']);
}
else {
$img = vbar_graph(true, $module_data,
400, 400, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image'], true);
}
}
}
else{
if ($layoutData['label_position']=='left') {
if ($layoutData['type_graph'] == 'horizontal') {
$img = '<div style="float:right;height:'.$himg.'px;">'.
hbar_graph(true, $module_data,
$width, $width, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image']) . '</div>';
}
else {
$img = '<div style="float:right;height:'.$himg.'px;">'.
vbar_graph(true, $module_data,
$width, $width, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image'], true) . '</div>';
}
}
elseif($layoutData['label_position']=='right') {
if ($layoutData['type_graph'] == 'horizontal') {
$img = '<div style="float:left;height:'.$himg.'px;">'.
hbar_graph(true, $module_data,
$width, $width, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image']) . '</div>';
}
else {
$img = '<div style="float:left;height:'.$himg.'px;">'.
vbar_graph(true, $module_data,
$width, $width, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image'], true) . '</div>';
}
}
else {
if ($layoutData['type_graph'] == 'horizontal') {
$img = hbar_graph(true, $module_data,
$width, $width, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image']);
}
else {
$img = vbar_graph(true, $module_data,
$width, $width, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image'], true);
}
}
}
}
else {
if($width == 0){
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/barras-no.png" style="width:400px;height:400px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/barras-no.png" style="width:400px;height:400px;'.$imgpos.'">';
}
}
else{
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/barras-no.png" style="width:'.$width.'px;height:'.$width.'px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/barras-no.png" style="width:'.$width.'px;height:'.$width.'px;'.$imgpos.'">';
}
}
}
}
//Restore db connection
if ($layoutData['id_metaconsole'] != 0) {
metaconsole_restore_db();
}
break;
case LABEL:
$z_index = 4 + 1;
break;
@ -1175,6 +1446,9 @@ function visual_map_print_item($mode = "read", $layoutData,
case MODULE_GRAPH:
$class .= "module_graph";
break;
case BARS_GRAPH:
$class .= "bars_graph";
break;
case SIMPLE_VALUE:
case SIMPLE_VALUE_MAX:
case SIMPLE_VALUE_MIN:
@ -1614,6 +1888,20 @@ function visual_map_print_item($mode = "read", $layoutData,
echo $img;
if ($layoutData['label_position']=='down') {
echo io_safe_output($text);
}
elseif($layoutData['label_position']=='left' || $layoutData['label_position']=='right') {
echo io_safe_output($text);
}
break;
case BARS_GRAPH:
if ($layoutData['label_position']=='up') {
echo io_safe_output($text);
}
echo $img;
if ($layoutData['label_position']=='down') {
echo io_safe_output($text);
}
@ -1786,6 +2074,29 @@ function visual_map_print_item($mode = "read", $layoutData,
}
}
function get_bars_module_data ($id_module) {
$mod_values = db_get_value_filter('datos', 'tagente_estado', array('id_agente_modulo' => $id_module));
if (preg_match("/\r\n/", $mod_values)) {
$values = explode("\r\n", $mod_values);
}
elseif (preg_match("/\n/", $mod_values)) {
$values = explode("\n", $mod_values);
}
$values_to_return = array();
$index = 0;
$color_index = 0;
$total = 0;
foreach ($values as $val) {
$data = explode(":", $val);
$values_to_return[$data[0]] = array('g' =>$data[1]);
}
return $values_to_return;
}
/**
* The function to get simple value type from the value of process type in the form
*
@ -3033,6 +3344,10 @@ function visual_map_create_internal_name_item($label = null, $type, $image, $age
case MODULE_GRAPH:
$text = __('Module graph');
break;
case 'bars_graph':
case BARS_GRAPH:
$text = __('Bars graph');
break;
case 'auto_sla_graph':
case AUTO_SLA_GRAPH:
$text = __('Auto SLA Graph');
@ -3162,6 +3477,9 @@ function visual_map_type_in_js($type) {
case MODULE_GRAPH:
return 'module_graph';
break;
case BARS_GRAPH:
return 'bars_graph';
break;
case AUTO_SLA_GRAPH:
return 'auto_sla_graph';
break;

View File

@ -161,7 +161,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
'simple_value',
'datos',
'group_item',
'auto_sla_graph');
'auto_sla_graph',
'bars_graph');
$form_items['label_row']['html'] =
'<td align="left" valign="top" style="">' . __('Label') . '
@ -212,7 +213,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
'module_graph',
'simple_value',
'datos',
'icon');
'icon',
'bars_graph');
if (!is_metaconsole())
$form_items['enable_link_row']['items'][] = 'group_item';
@ -235,7 +237,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$form_items['background_color'] = array();
$form_items['background_color']['items'] = array(
'module_graph',
'datos');
'datos',
'bars_graph');
$form_items['background_color']['html'] = '<td align="left"><span>' .
__('Background color') . '</span></td>
<td align="left">'. html_print_select (
@ -489,6 +492,13 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
'<span id="count_items">1</span> '.
'<span id="dir_items"></span> item/s
</td>';
$bars_graph_types = array('vertical' => __('Vertical'), 'horizontal' => __('Horizontal'));
$form_items['bars_graph_type'] = array();
$form_items['bars_graph_type']['items'] = array('bars_graph');
$form_items['bars_graph_type']['html'] = '<td align="left">' .
__('Type') . '</td>
<td align="left">' . html_print_select($bars_graph_types, 'bars_graph_type', 'vertical', '', '', '', true) . '</td>';
//Insert and modify before the buttons to create or update.
@ -535,7 +545,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$form_items_advance['position_row']['items'] = array('static_graph',
'percentile_bar', 'percentile_item', 'module_graph',
'simple_value', 'label', 'icon', 'datos', 'box_item',
'auto_sla_graph');
'auto_sla_graph', 'bars_graph');
$form_items_advance['position_row']['html'] = '
<td align="left">' . __('Position') . '</td>
<td align="left">(' . html_print_input_text('left', '0', '', 3, 5, true) .
@ -564,7 +574,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$form_items_advance['parent_row']['items'] = array(
'group_item', 'static_graph',
'percentile_bar', 'percentile_item', 'module_graph',
'simple_value', 'label', 'icon', 'datos', 'auto_sla_graph');
'simple_value', 'label', 'icon', 'datos', 'auto_sla_graph',
'bars_graph');
$form_items_advance['parent_row']['html'] = '<td align="left">' .
__('Parent') . '</td>
<td align="left">' .