diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index 38a1ba1fb9..a06a8252fc 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -89,7 +89,7 @@ function visual_map_main() { if($('#process_value').val() != '0'){ $('#period_row').css('display','table-row'); } - } + } else{ $('#data_image_container').css('display','inline'); $('#data_image_check').css('display','inline'); @@ -642,21 +642,19 @@ function update_button_palette_callback() { break; case 'simple_value': $("#" + idItem).html(values['label']); - if( (values['label'].replace( /<.*?>/g, '' ) != '_VALUE_') - && (values['label'].replace( /<.*?>/g, '' ) != '(_VALUE_)') ){ - + + if($("#data_image_check").html() == "On"){ $("#text_" + idItem).html(''); $("#" + idItem).html(''); } else{ $("#text_" + idItem).html( - '
'+values["label"]+'
' + '
'+values["label"]+'
' ) $("#" + idItem).html( - '
'+values["label"]+'
' + '
'+values["label"]+'
' ) } - setModuleValue(idItem,values['process_simple_value'], values['period'],values['width']); break; case 'label': $("#text_" + idItem).html(values['label']); @@ -744,7 +742,6 @@ function update_button_palette_callback() { $("#" + idItem + ' img').css('margin-top',(parseInt($("#" + idItem).css('height'))/2)-(parseInt($("#" + idItem + " img").css('height'))/2)+'px'); $("#" + idItem + ' > p').remove(); } - else if(values['label_position']=='down'){ $("#" + idItem + ' table').css('float',''); $("#" + idItem + ' img').css('float',''); @@ -752,15 +749,16 @@ function update_button_palette_callback() { $('#' + idItem + ' table').remove(); $('#' + idItem).append(tempoimg); $("#" + idItem + ' table').css('height',''); - $("#" + idItem + ' table').css('width','70'); - $("#" + idItem + ' span').css('width','70'); + if (selectedItem != 'simple_value') { + $("#" + idItem + ' table').css('width','70'); + $("#" + idItem + ' span').css('width','70'); + } + else { + $("#" + idItem + ' table').css('width',''); + $("#" + idItem + ' table').css('text-align','center'); + $("#" + idItem + ' span').css('width',''); + } $("#" + idItem + ' img').css('margin-top',''); - //if(parseInt($("#" + idItem).css('width'))-parseInt($("#" + idItem + " img").css('width'))/2 == 0 || values['height'] == 0 || values['width'] == 0){ - //$("#" + idItem + ' img').css('margin-left',(parseInt($("#" + idItem).css('width'))/2)-(parseInt($("#" + idItem + " img").css('width'))/2)+'px'); - //} - //else{ - //$("#" + idItem + ' img').css('margin-left',''); - //} $("#" + idItem + ' > p').remove(); } @@ -771,19 +769,19 @@ function update_button_palette_callback() { $('#' + idItem + ' img').remove(); $('#' + idItem).append(tempoimg); $("#" + idItem + ' table').css('height',''); - $("#" + idItem + ' table').css('width','70'); - $("#" + idItem + ' span').css('width','70'); + if (selectedItem != 'simple_value') { + $("#" + idItem + ' table').css('width','70'); + $("#" + idItem + ' span').css('width','70'); + } + else { + $("#" + idItem + ' table').css('width',''); + $("#" + idItem + ' table').css('text-align','center'); + $("#" + idItem + ' span').css('width',''); + } $("#" + idItem + ' img').css('margin-top',''); - //if(parseInt($("#" + idItem).css('width'))-parseInt($("#" + idItem + " img").css('width'))/2 == 0 || values['height'] == 0 || values['width'] == 0){ - //$("#" + idItem + ' img').css('margin-left',''); - - //} - //else{ - //$("#" + idItem + ' img').css('margin-left',(parseInt($("#" + idItem).css('width'))/2)-(parseInt($("#" + idItem + " img").css('width'))/2)+'px'); - //} + $("#" + idItem + ' > p').remove(); } - } function readFields() { @@ -2142,7 +2140,7 @@ function setModuleGraph(id_data) { } -function setModuleValue(id_data, process_simple_value, period,width_data_image) { +function setModuleValue(id_data, process_simple_value, period, width_data_image) { var parameter = Array(); parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); parameter.push ({name: "action", value: "get_module_value"}); @@ -2160,12 +2158,9 @@ function setModuleValue(id_data, process_simple_value, period,width_data_image) type: "POST", dataType: 'json', success: function (data) { + var currentValue = $("#text_" + id_data).html(); - var currentValue = $("#text_" + id_data).html(); - - //currentValue = currentValue.replace(/_VALUE_/gi, data.value); $("#text_" + id_data).html(currentValue); - //$("#text_" + id_data).html('Data value'); } }); } @@ -2804,7 +2799,7 @@ function createItem(type, values, id_data) { } else if(values['label_position'] == 'down'){ - + if(values['image'] == '' || values['image'] == 'none'){ item .append('
'+values['label']+'
') @@ -3383,7 +3378,6 @@ function createItem(type, values, id_data) { item = $('
' + ' ' + values['label'] + ' ' + '
' ); - setModuleValue(id_data,values.process_simple_value,values.period,values.width_data_image); break; case 'label': item = $('
0){ - $("#data_image_check").css('display','inline'); - $("#data_image_check_label").css('display','inline'); - $('#data_image_container').css('display','inline'); - $("#data_image_check").html('On'); - $('.block_tinymce').remove(); - $('#label_row').append('
'); - $('#process_value_row').css('display','none'); - $('#period_row').css('display','none'); - } - else{ - $("#data_image_check").html('Off'); - $("#data_image_check").css('display','none'); - $("#data_image_check_label").css('display','none'); - $('#data_image_container').css('display','none'); - $('.block_tinymce').remove(); - $('#process_value_row').css('display','table-row'); - if($('#process_value').val() != 0){ - $('#period_row').css('display','table-row'); + + parameter = Array(); + parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); + parameter.push ({name: "action", value: "get_image_from_module"}); + parameter.push ({name: "id_element", value: idItem}); + parameter.push ({name: "id_visual_console", value: id_visual_console}); + + jQuery.ajax({ + url: "ajax.php", + data: parameter, + type: "POST", + dataType: "json", + success: function(data) { + if(!data['correct']){ + $("#data_image_check").html('Off'); + $('#data_image_container').css('display','none'); + $('#data_image_check').css('display','none'); + $('#data_image_check_label').css('display','none'); + $('.block_tinymce').remove(); + $('#process_value_row').css('display','table-row'); + if($('#process_value').val() != '0'){ + $('#period_row').css('display','table-row'); + } + } + else{ + $('#data_image_container').css('display','inline'); + $('#data_image_check').css('display','inline'); + $('#data_image_check_label').css('display','inline'); + $("#data_image_check").html('On'); + $('#process_value_row').css('display','none'); + $('#period_row').css('display','none'); + $('#text-label_ifr').contents().find('#tinymce').html('_VALUE_'); + $('.block_tinymce').remove(); + $('#label_row').append('
'); + } } - } + }); } else{ $("#data_image_check").css('display','none'); diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index ab13300de9..bffbd3926b 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -145,6 +145,24 @@ switch ($action) { echo json_encode($return); break; + case 'get_image_from_module': + $layoutData = db_get_row_filter('tlayout_data', array('id' => $id_element)); + $sql = 'SELECT datos FROM tagente_estado WHERE id_agente_modulo = '.$layoutData['id_agente_modulo']; + ob_clean(); + $result = db_get_sql($sql); + $image = strpos($result, 'data:image'); + + if($image === false){ + $return['correct'] = false; + } + else{ + $return['correct'] = true; + } + + echo json_encode($return); + + break; + case 'get_module_type_string': $data = array (); @@ -489,12 +507,6 @@ switch ($action) { echo (int)$result; break; case 'simple_value': - if ($action == 'update') { - $values['type'] = visual_map_get_simple_value_type( - $process_simple_value); - $values['period'] = $period; - $values['width'] = $width; - } case 'percentile_bar': case 'percentile_item': case 'static_graph': @@ -692,6 +704,15 @@ switch ($action) { if ($height !== null) { $values['height'] = $height; } + break; + case 'simple_value': + if ($action == 'update') { + $values['type'] = visual_map_get_simple_value_type( + $process_simple_value); + $values['period'] = $period; + $values['width'] = $width; + } + break; default: if (enterprise_installed()) { diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 2391dc30a5..855501de7a 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -2045,39 +2045,25 @@ function visual_map_print_item($mode = "read", $layoutData, global $config; - if ($type == SIMPLE_VALUE) { - //~ $returnValue_value = explode(' ', $value); - - //~ if ($returnValue_value[1] != "") { - //~ $value = remove_right_zeros(number_format($returnValue_value[0], $config['graph_precision'])) . " " . $returnValue_value[1]; - //~ } - //~ else { - //~ $value = remove_right_zeros(number_format($returnValue_value[0], $config['graph_precision'])); - //~ } - - } - else { - // If the value is a string, dont format it - if (!is_string($value)) { - //~ $value = remove_right_zeros(format_for_graph($value, $config['graph_precision'])); - } - } - - if(get_parameter('action') == 'edit'){ - if( (strip_tags($io_safe_output_text) != '_VALUE_') || (strip_tags($io_safe_output_text) != '(_VALUE_)') ) { + $is_image = get_if_module_is_image($layoutData['id_agente_modulo']); + if(get_parameter('action') == 'edit') { + if(!$is_image) { echo $io_safe_output_text; } else { echo ""; } - } else { - if(strrpos(strip_tags($io_safe_output_text),'(_VALUE_)') !== false || (strip_tags($io_safe_output_text) == '(_VALUE_)')) { - echo str_replace(array("(_VALUE_)","(_value_)"), $value, $io_safe_output_text); + } + else { + if(!$is_image) { + $new_text = str_replace(array("(_VALUE_)","(_value_)"), $value, $io_safe_output_text); + $new_text = str_replace(array('_VALUE_','_value_'), $value, $new_text); + + echo $new_text; } - elseif(strrpos(strip_tags($io_safe_output_text),'_VALUE_') !== false || (strip_tags($io_safe_output_text) == '_VALUE_')) { - echo str_replace(array('_VALUE_','_value_'), $value, $io_safe_output_text); - } else { - echo str_replace('>', ' style="width:'.$layoutData['width'].'px">',$value); + else { + $simple_value_img = str_replace('>', ' style="width:'.$layoutData['width'].'px">', $value); + echo $simple_value_img; } } @@ -2167,6 +2153,20 @@ function visual_map_print_item($mode = "read", $layoutData, } } +function get_if_module_is_image ($id_module) { + $sql = 'SELECT datos FROM tagente_estado WHERE id_agente_modulo = ' . $id_module; + + $result = db_get_sql($sql); + $image = strpos($result, 'data:image'); + + if($image === false){ + return false; + } + else{ + return true; + } +} + function get_bars_module_data ($id_module) { $mod_values = db_get_value_filter('datos', 'tagente_estado', array('id_agente_modulo' => $id_module));