From b8f6b9fad4252d324af399251ddf25cd85c3c021 Mon Sep 17 00:00:00 2001 From: m-lopez-f Date: Fri, 3 Mar 2017 12:50:03 +0100 Subject: [PATCH] Fixed style of visual mapwidget in dashboards. Gitlab: #374 --- .../include/functions_visual_map.php | 287 ++++++++---------- pandora_console/include/graphs/fgraph.php | 2 +- .../operation/visual_console/render_view.php | 122 ++------ 3 files changed, 155 insertions(+), 256 deletions(-) diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 4e356faf43..6f34924024 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -124,105 +124,83 @@ function visual_map_print_item($mode = "read", $layoutData, $text = '' . $label .''; - if($height == 0){ - - switch($type){ - - case 0: - case 11: - $tableheight0 = '70'; - break; - - case 3: - $tableheight0 = '30'; - break; - - case 9: - $tableheight0 = '130'; - break; - - case 1: - $tableheight0 = '180'; - break; - - case SERVICE: - $tableheight0 = '50'; - break; - + if ($height == 0) { + switch($type) { + case 0: + case 11: + $tableheight0 = '70'; + break; + case 3: + $tableheight0 = '30'; + break; + case 9: + $tableheight0 = '130'; + break; + case 1: + $tableheight0 = '180'; + break; + case SERVICE: + $tableheight0 = '50'; + break; + } + } + else { + $tableheight0 = $height; } -} -else{ - $tableheight0 = $height; -} -if ($layoutData['width'] == 0 || $layoutData['height'] == 0){ - switch($type){ - - case 0: - case 11: - $himg = '70'; - $wimg ='70'; - break; - - case 3: - - if(get_parameter('action') == 'edit'){ - - $himg = '30'; - $wimg = '150'; - - } - else{ - $himg = '15'; - $wimg = '150'; - } - - - break; - - case 9: - $himg = '130'; - $wimg = '130'; - break; - - case 1: - $himg = '180'; - $wimg = '300'; - break; - - case SERVICE: - $himg = '50'; - $wimg = '150'; - break; - - } -} -else{ - $wimg = $layoutData['width']; - $himg = $layoutData['height']; - - if($type == 3){ - if(get_parameter('action') == 'edit'){ - - $himg = '30'; - - } - else{ - $himg = '15'; + if ($layoutData['width'] == 0 || $layoutData['height'] == 0) { + switch($type) { + case 0: + case 11: + $himg = '70'; + $wimg ='70'; + break; + case 3: + if (get_parameter('action') == 'edit') { + $himg = '30'; + $wimg = '150'; + } + else{ + $himg = '15'; + $wimg = '150'; + } + break; + case 9: + $himg = '130'; + $wimg = '130'; + break; + case 1: + $himg = '180'; + $wimg = '300'; + break; + case SERVICE: + $himg = '50'; + $wimg = '150'; + break; } } - if($type == 9){ - $himg = $wimg; + else { + $wimg = $layoutData['width']; + $himg = $layoutData['height']; + + if ($type == 3) { + if(get_parameter('action') == 'edit') + $himg = '30'; + else + $himg = '15'; + } + if ($type == 9) { + $himg = $wimg; + } } -} - if($label_position == 'left'){ + if ($label_position == 'left') { $text = '
' . $label .'
'; } - else if($label_position == 'right'){ + elseif ($label_position == 'right') { $text = '
' . $label .'
'; } - else{ + else { $text = '
' . $label .'
'; } @@ -276,9 +254,7 @@ else{ case GROUP_ITEM: if ($layoutData['enable_link'] && can_user_access_node()) { - $link = true; - } break; case LABEL: @@ -1013,10 +989,11 @@ else{ false, $type_graph) . ''; } else { - $img = grafico_modulo_sparse($id_module, $period, 0,300,180, - '',null, - false, 1, false, 0, '', 0, 0, true, $only_image, '', 1, false, - '', false, false, false, $layoutData['image'], null, true, false,$type_graph); + $img = grafico_modulo_sparse($id_module, + $period, 0, 300, 180, '',null, false, 1, + false, 0, '', 0, 0, true, $only_image, '', + 1, false, '', false, false, false, + $layoutData['image'], null, true, false, $type_graph); } } else{ @@ -1237,72 +1214,66 @@ else{ break; case PERCENTILE_BAR: - - $imgpos = ''; - - if($layoutData['label_position']=='left'){ - $imgpos = 'float:right;'; - } - else if($layoutData['label_position']=='right'){ - $imgpos = 'float:left;'; - } - - $progress_bar_heigh = 15; - if (!empty($proportion)) { - if ($width != 0) { - $width = (integer)($proportion['proportion_width'] * $width); + $imgpos = ''; + + if($layoutData['label_position']=='left'){ + $imgpos = 'float:right;'; } - else { - $width = (integer)($proportion['proportion_width'] * $infoImage[0]); + else if($layoutData['label_position']=='right'){ + $imgpos = 'float:left;'; } - - if ($height != 0) { - $height = (integer)($proportion['proportion_height'] * $height); - $progress_bar_heigh = $progress_bar_heigh * $proportion['proportion_height']; - } - else { - $height = (integer)($proportion['proportion_height'] * $infoImage[1]); - } - } - - if($layoutData['label_position']=='up'){ - echo io_safe_output($text); - } - - ob_start(); - if ($type == PERCENTILE_BUBBLE) { - echo progress_bubble($percentile, $width, $width, '', 1, $value_text, $colorStatus,$imgpos); - } - else { - echo progress_bar($percentile, $width, $progress_bar_heigh, '', 1, $value_text, $colorStatus,$imgpos); - } - $img = ob_get_clean(); - - - if(get_parameter('action') == 'edit'){ - - if($width == 0){ - $img = ''; - } - else{ - $img = ''; - } - - } - else{ - $img = str_replace('>', 'class="image" style="height:'.$himg.'px;width:'.$wimg.'px;'.$imgpos.'" id="image_' . $id . '" />', $img); - - } - - echo $img; - - if($layoutData['label_position']=='down'){ - echo io_safe_output($text); - } - else if($layoutData['label_position']=='left' || $layoutData['label_position']=='right'){ - echo io_safe_output($text); - } + $progress_bar_heigh = 15; + if (!empty($proportion)) { + if ($width != 0) { + $width = (integer)($proportion['proportion_width'] * $width); + } + else { + $width = (integer)($proportion['proportion_width'] * $infoImage[0]); + } + + if ($height != 0) { + $height = (integer)($proportion['proportion_height'] * $height); + $progress_bar_heigh = $progress_bar_heigh * $proportion['proportion_height']; + } + else { + $height = (integer)($proportion['proportion_height'] * $infoImage[1]); + } + } + + if($layoutData['label_position']=='up'){ + echo io_safe_output($text); + } + + ob_start(); + if ($type == PERCENTILE_BUBBLE) { + echo progress_bubble($percentile, $width, $width, '', 1, $value_text, $colorStatus,$imgpos); + } + else { + echo progress_bar($percentile, $width, $progress_bar_heigh, '', 1, $value_text, $colorStatus,$imgpos); + } + $img = ob_get_clean(); + + if (get_parameter('action') == 'edit') { + if ($width == 0) { + $img = ''; + } + else { + $img = ''; + } + } + else{ + $img = str_replace('>', 'class="image" style="height:'.$himg.'px;width:'.$wimg.'px;'.$imgpos.'" id="image_' . $id . '" />', $img); + } + + echo $img; + + if($layoutData['label_position']=='down'){ + echo io_safe_output($text); + } + else if($layoutData['label_position']=='left' || $layoutData['label_position']=='right'){ + echo io_safe_output($text); + } break; diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 900f9a0d74..775905fcab 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -399,7 +399,7 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, false, '', $menu, - $background_color, + $backgroundColor, $dashboard, $vconsole); } diff --git a/pandora_console/operation/visual_console/render_view.php b/pandora_console/operation/visual_console/render_view.php index 16c474547a..a9e7e04586 100755 --- a/pandora_console/operation/visual_console/render_view.php +++ b/pandora_console/operation/visual_console/render_view.php @@ -100,7 +100,10 @@ if ($vconsole_write || $vconsole_manage) { $hash = md5($config["dbpass"] . $id_layout . $config["id_user"]); - $options['public_link']['text'] = ''. + $options['public_link']['text'] = ''. html_print_image ("images/camera_mc.png", true, array ("title" => __('Show link to public Visual Console'))).''; $options['public_link']['active'] = false; @@ -234,35 +237,13 @@ $ignored_params['refr'] = ''; url = js_html_entity_decode( href ) + duration; //$(document).attr ("location", url); $.get(window.location.href.replace("render_view","pure_ajax"), function(respuestaSolicitud){ - $('#background_').html(respuestaSolicitud); + $('#background_').html(respuestaSolicitud); startCountDown(refr, false); }); - - } }); } - //~ var fetchMap = function () { - //~ $.ajax({ - //~ url: 'ajax.php', - //~ type: 'GET', - //~ dataType: 'html', - //~ data: { - //~ page: 'include/ajax/visual_console.ajax', - //~ render_map: true, - //~ keep_aspect_ratio: true, - //~ id_visual_console: , - //~ graph_javascript: , - //~ width: $(window).width(), - //~ height: $(window).height() - //~ } - //~ }) - //~ .done(function (data, textStatus, xhr) { - //~ $('div#vc-container').html(data); - //~ startCountDown(refr, false); - //~ }); - //~ } startCountDown(refr, false); //~ // Auto hide controls var controls = document.getElementById('vc-controls'); @@ -272,9 +253,6 @@ $ignored_params['refr'] = ''; refr = Number.parseInt(event.target.value, 10); startCountDown(refr, false); }); - - //~ // Start the map fetch - //~ fetchMap(); } else { $('#refr').change(function () { @@ -282,96 +260,46 @@ $ignored_params['refr'] = ''; }); } - /* - $(".module_graph").each(function(){ - left = parseInt($(this).css("left")) + 150 + ((parseInt($(this).css("width"))-300)/2); - $(this).css('left', left); - }); - - $('.item:not([class~="module_graph"])').each(function(){ - left = parseInt($(this).css('left')) + ((parseInt($('#' + $(this).attr('id')).css('width')) - parseInt($('#' + $(this).attr('id') + " img").css('width')))*0.5); - - $(this).css('left', left); - }); - - - */ - $(".module_graph .menu_graph").css('display','none'); - $(".parent_graph").each(function(){ - - if($(this).css('background-color') != 'rgb(255, 255, 255)'){ - $(this).css('color', '#999'); - } - }); - + $(".parent_graph").each( function() { + if ($(this).css('background-color') != 'rgb(255, 255, 255)') + $(this).css('color', '#999'); + }); + $(".overlay").removeClass("overlay").addClass("overlaydisabled"); - $('.item:not(.icon) img').each(function(){ - - - if($(this).css('float')=='left' || $(this).css('float')=='right'){ - - - $(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px'); - $(this).css('margin-left',''); - + $('.item:not(.icon) img').each( function() { + if ($(this).css('float')=='left' || $(this).css('float')=='right') { + $(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px'); + $(this).css('margin-left',''); } - else{ + else { $(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px'); $(this).css('margin-top',''); } - }); - $('.item > div').each(function(){ - if($(this).css('float')=='left' || $(this).css('float')=='right'){ - - - $(this).css('margin-top',(parseInt($(this).parent().css('height'))/2-parseInt($(this).css('height'))/2-15)+'px'); - $(this).css('margin-left',''); - + $('.item > div').each( function() { + if ($(this).css('float')=='left' || $(this).css('float')=='right') { + $(this).css('margin-top',(parseInt($(this).parent().css('height'))/2-parseInt($(this).css('height'))/2-15)+'px'); + $(this).css('margin-left',''); } - else{ + else { $(this).css('margin-left',(parseInt($(this).parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px'); $(this).css('margin-top',''); } - }); - $('.item > a > div').each(function(){ - if($(this).css('float')=='left' || $(this).css('float')=='right'){ - - - $(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2-5)+'px'); - $(this).css('margin-left',''); - + $('.item > a > div').each( function() { + if ($(this).css('float')=='left' || $(this).css('float')=='right') { + $(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2-5)+'px'); + $(this).css('margin-left',''); } - else{ + else { $(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px'); $(this).css('margin-top',''); } - }); - - /* - $('.percentile_item a > img').each(function(){ - - if($(this).css('float')=='left' || $(this).css('float')=='right'){ - - - $(this).css('margin-top',(parseInt($(this).parent().parent().css('height'))/2-parseInt($(this).css('height'))/2)+'px'); - $(this).css('margin-left',''); - - } - else{ - $(this).css('margin-left',(parseInt($(this).parent().parent().css('width'))/2-parseInt($(this).css('width'))/2)+'px'); - $(this).css('margin-top',''); - } - - }); - */ - });