diff --git a/pandora_console/general/check_image_module.php b/pandora_console/general/check_image_module.php new file mode 100644 index 0000000000..422b1de7ba --- /dev/null +++ b/pandora_console/general/check_image_module.php @@ -0,0 +1,25 @@ + + + diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index b20dc8ca89..4a0fa19d2e 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -84,7 +84,46 @@ function visual_map_main() { //Fixed to wait the load of images. $(window).load(function() { + + $('#module').change(function(){ + var txt = $("#module").val(); + if(selectedItem == 'simple_value' || creationItem == 'simple_value'){ + $.ajax({ + async:false, + type: "POST", + url: "ajax.php", + data: {"page" : "general/check_image_module", + "get_image" : txt, + }, + success: function(data) { + if(data == 0){ + $("#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('
'); + } + } + }); + } + }); + // Begin - Background label color changer $( "#text-label_ifr" ).contents().find( "body" ).bind("contextmenu", function(e) { @@ -360,10 +399,32 @@ function update_button_palette_callback() { setModuleGraph(idItem); break; case 'simple_value': - $("#text_" + idItem).html(values['label']); + //checkpoint + if(($('#text-label_ifr').contents().find('#tinymce p').html() == '_VALUE_' || + $('#text-label_ifr').contents().find('#tinymce').html() == '_VALUE_') + && $('#data_image_check').html() != 'On'){ + alert('_VALUE_ exactly value is only enable for data image. Please change label text or select a data image module.'); + return; + } + $("#" + idItem).html(values['label']); + if(values['label'].replace( /<.*?>/g, '' ) == '_VALUE_'){ + $("#text_" + idItem).html(''); + $("#" + idItem).html(''); + } + else{ + $("#text_" + idItem).html( + '
'+values["label"]+'
' + ) + $("#" + idItem).html( + '
'+values["label"]+'
' + ) + + } + + //$("#simplevalue_" + idItem) //.html($('').attr('src', "images/spinner.gif")); - setModuleValue(idItem,values['process_simple_value'], values['period']); + setModuleValue(idItem,values['process_simple_value'], values['period'],values['width']); break; case 'label': $("#text_" + idItem).html(values['label']); @@ -514,6 +575,10 @@ function readFields() { values['period'] = undefined != $("#hidden-period").val() ? $("#hidden-period").val() : $("#period_select").val(); } values['width'] = $("input[name=width]").val(); + values['width_data_image'] = $("#data_image_width").val(); + if(values['width_data_image'] != 0){ + values['width'] = values['width_data_image']; + } values['height'] = $("input[name=height]").val(); values['parent'] = $("select[name=parent]").val(); values['map_linked'] = $("select[name=map_linked]").val(); @@ -681,6 +746,7 @@ function create_button_palette_callback() { create_line('step_1', values); break; default: + insertDB(creationItem, values); break; } @@ -959,6 +1025,14 @@ function toggle_item_palette() { $( "#text-label_ifr" ).contents().find( "body" ).css("background","lightgray"); } + + if(creationItem != 'simple_value'){ + $("#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(); + } } function fill_parent_select(id_item) { @@ -1679,12 +1753,13 @@ function setModuleGraph(id_data) { } -function setModuleValue(id_data, process_simple_value, period) { +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"}); parameter.push ({name: "id_element", value: id_data}); parameter.push ({name: "period", value: period}); + parameter.push ({name: "width", value: width_data_image}); parameter.push ({name: "id_visual_console", value: id_visual_console}); if (process_simple_value != undefined) { parameter.push ({name: "process_simple_value", value: process_simple_value}); @@ -1696,7 +1771,9 @@ function setModuleValue(id_data, process_simple_value, period) { 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'); @@ -2211,10 +2288,14 @@ function createItem(type, values, id_data) { case 'simple_value': sizeStyle = ''; imageSize = ''; + if($('#data_image_check').html() == 'On'){ + values['label'] = ''; + + } item = $('
' + ' ' + values['label'] + ' ' + '
' ); - setModuleValue(id_data,values.process_simple_value,values.period); + 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'); + } + } + } + else{ + $("#data_image_check").css('display','none'); + $("#data_image_check_label").css('display','none'); + $('#data_image_container').css('display','none'); + } + }); //Set the limit of draggable in the div with id "background" and set drag diff --git a/pandora_console/images/console/signes/data_image.png b/pandora_console/images/console/signes/data_image.png new file mode 100644 index 0000000000..e3542c1ea3 Binary files /dev/null and b/pandora_console/images/console/signes/data_image.png differ diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index 2a786200ad..efc5267119 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -422,6 +422,7 @@ switch ($action) { $values['type'] = visual_map_get_simple_value_type( $process_simple_value); $values['period'] = $period; + $values['width'] = $width; } case 'percentile_bar': case 'percentile_item': @@ -897,6 +898,7 @@ switch ($action) { //This allows min, max and avg process in a simple value $values['type'] = visual_map_get_simple_value_type($process_simple_value); $values['period'] = $period; + $values['width'] = $width; break; case 'label': $values['type'] = LABEL; diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 60125340ff..6967633915 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -1438,17 +1438,25 @@ function visual_map_print_item($mode = "read", $layoutData, if(get_parameter('action') == 'edit'){ - - //echo 'Data value'; - - echo $io_safe_output_text; + //html_debug($layoutData); + //echo 'Data value'; + if(strip_tags($io_safe_output_text) != '_VALUE_'){ + echo $io_safe_output_text; + } + else{ + echo ""; + } } else{ - - echo str_replace(array('_VALUE_','_value_'), $value, $io_safe_output_text); - + if(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); + } + + } //Restore db connection @@ -1575,6 +1583,8 @@ function visual_map_get_simple_value_type($process_simple_value) { function visual_map_get_simple_value($type, $id_module, $period = SECONDS_1DAY) { global $config; + + $unit_text = db_get_sql ('SELECT unit FROM tagente_modulo WHERE id_agente_modulo = ' . $id_module); $unit_text = trim(io_safe_output($unit_text)); @@ -1583,23 +1593,35 @@ function visual_map_get_simple_value($type, $id_module, $period = SECONDS_1DAY) case SIMPLE_VALUE: $value = db_get_value ('datos', 'tagente_estado', 'id_agente_modulo', $id_module); + + if ($value === false) { $value = __('Unknown'); + + $value = preg_replace ('/\n/i','
',$value); + $value = preg_replace ('/\s/i',' ',$value); } else { - if ( is_numeric($value) ) { - if ($config['simple_module_value']) { - $value = remove_right_zeros(number_format($value, $config['graph_precision'])); + if(strpos($value, 'data:image') !== false){ + $value = ''; + } + else{ + + if ( is_numeric($value) ) { + if ($config['simple_module_value']) { + $value = remove_right_zeros(number_format($value, $config['graph_precision'])); + } } + if (!empty($unit_text)) { + $value .= " " . $unit_text; + } + + $value = preg_replace ('/\n/i','
',$value); + $value = preg_replace ('/\s/i',' ',$value); + } - if (!empty($unit_text)) { - $value .= " " . $unit_text; - } + } - - $value = preg_replace ('/\n/i','
',$value); - $value = preg_replace ('/\s/i',' ',$value); - return $value; break; case SIMPLE_VALUE_MAX: diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index 42772adf28..e2e01a21d6 100755 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -314,8 +314,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { $form_items['module_row']['html'] = '' . __('Module') . ' ' . - html_print_select(array(), 'module', '', '', __('Any'), 0, true) . - ''; + html_print_select(array(), 'module', '', '', __('Any'), 0, true). ' + '; $form_items['type_graph'] = array(); diff --git a/pandora_console/operation/visual_console/render_view.php b/pandora_console/operation/visual_console/render_view.php index 001644ac2a..4364bfda9f 100755 --- a/pandora_console/operation/visual_console/render_view.php +++ b/pandora_console/operation/visual_console/render_view.php @@ -280,7 +280,7 @@ $ignored_params['refr'] = ''; $(".overlay").removeClass("overlay").addClass("overlaydisabled"); - $('.item:not(.icon) img').each( function() { + $('.item:not(.icon) img:not(.b64img)').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','');