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(
- '
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));