From e96bb53f067e12c7dd47f7811f8bd22c3468c8e1 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Mon, 28 Oct 2013 10:27:10 +0000 Subject: [PATCH] 2013-10-28 Miguel de Dios * godmode/reporting/reporting_builder.list_items.php, godmode/reporting/visual_console_builder.editor.js, godmode/reporting/visual_console_builder.elements.php, godmode/reporting/visual_console_builder.editor.php, include/help/en/help_visual_console_editor_editor_tab.php, include/javascript/jquery.pandora.js, include/functions_visual_map.php, include/ajax/visual_console_builder.ajax.php, include/functions_visual_map_editor.php: added rich labels for all items in the visualmap and the simple value has the new macro (_VALUE_) for to set the value with html style into the rich labels. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8965 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 14 ++++ .../reporting_builder.list_items.php | 8 +- .../visual_console_builder.editor.js | 76 +++++++++---------- .../visual_console_builder.editor.php | 2 +- .../visual_console_builder.elements.php | 66 +++++++++++++++- .../ajax/visual_console_builder.ajax.php | 7 +- .../include/functions_visual_map.php | 49 ++++++++---- .../include/functions_visual_map_editor.php | 17 +++-- .../help_visual_console_editor_editor_tab.php | 16 +++- .../include/javascript/jquery.pandora.js | 2 +- 10 files changed, 180 insertions(+), 77 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index b9f919eebe..8b787a71b0 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2013-10-28 Miguel de Dios + + * godmode/reporting/reporting_builder.list_items.php, + godmode/reporting/visual_console_builder.editor.js, + godmode/reporting/visual_console_builder.elements.php, + godmode/reporting/visual_console_builder.editor.php, + include/help/en/help_visual_console_editor_editor_tab.php, + include/javascript/jquery.pandora.js, + include/functions_visual_map.php, + include/ajax/visual_console_builder.ajax.php, + include/functions_visual_map_editor.php: added rich labels for all + items in the visualmap and the simple value has the new macro + (_VALUE_) for to set the value with html style into the rich labels. + 2013-10-28 Vanessa Gil * include/languages/ar.mo diff --git a/pandora_console/godmode/reporting/reporting_builder.list_items.php b/pandora_console/godmode/reporting/reporting_builder.list_items.php index 8a267d3bea..7619e78fa7 100644 --- a/pandora_console/godmode/reporting/reporting_builder.list_items.php +++ b/pandora_console/godmode/reporting/reporting_builder.list_items.php @@ -322,19 +322,19 @@ foreach ($items as $item) { } else { // The inventory items have the agents and modules in json format in the field external_source - if($is_inventory_item) { + if ($is_inventory_item) { $external_source = json_decode($item['external_source'], true); $agents = $external_source['id_agents']; $modules = $external_source['id_agents']; $agent_name_db = array(); - foreach($agents as $a) { + foreach ($agents as $a) { $agent_name_db[] = agents_get_name($a); } $agent_name_db = implode('
',$agent_name_db); $module_name_db = array(); - foreach($modules as $m) { + foreach ($modules as $m) { $module_name_raw = db_get_value_filter('nombre', 'tagente_modulo', array('id_agente_modulo' => $m)); $module_name_db[] = ui_print_truncate_text(io_safe_output($module_name_raw), 'module_small'); } @@ -365,7 +365,7 @@ foreach ($items as $item) { } } - if($item['period'] > 0) { + if ($item['period'] > 0) { $row[4] = human_time_description_raw($item['period']); } else { diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index af73e2c001..878e164486 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -143,7 +143,7 @@ function update_button_palette_callback() { case 'label': $("#" + idItem).css('color', values['label_color']); - $("#text_" + idItem).html(values['label2']); + $("#text_" + idItem).html(values['label']); break; case 'icon': var params = []; @@ -196,8 +196,8 @@ function readFields() { values['label'] = $("input[name=label]").val(); - var text = tinymce.get('text-label2').getContent(); - values['label2'] = text; + var text = tinymce.get('text-label').getContent(); + values['label'] = text; values['image'] = $("select[name=image]").val(); values['left'] = $("input[name=left]").val(); @@ -252,7 +252,7 @@ function create_button_palette_callback() { } break; case 'label': - if ((values['label2'] == '')) { + if ((values['label'] == '')) { alert($("#message_alert_no_label").html()); validate = false; } @@ -371,7 +371,7 @@ function toggle_item_palette() { item = creationItem; $("#button_update_row").css('display', 'none'); $("#button_create_row").css('display', ''); - cleanFields(); + cleanFields(item); unselectAll(); } else if (selectedItem != null) { @@ -423,7 +423,6 @@ function loadFieldsFromDB(item) { parameter.push ({name: "type", value: item}); parameter.push ({name: "id_element", value: idItem}); - is_label = false; set_label = false; jQuery.ajax({ @@ -443,26 +442,13 @@ function loadFieldsFromDB(item) { if (key == 'width') $("input[name=width]").val(val); if (key == 'height') $("input[name=height]").val(val); - if (key == 'type') - if (val == 4) { //Label - is_label = true; - - //Sometimes is set previous to know the - //type - if (set_label) { - tinymce.get('text-label2') - .setContent(set_label); - - $("input[name=label]").val(""); - } - } - if (key == 'label') { - if (is_label) - tinymce.get('text-label2').setContent(val); - else - $("input[name=label]").val(val); - set_label = val; + tinymce.get('text-label') + .setContent(""); + $("input[name=label]").val(""); + + tinymce.get('text-label').setContent(val); + $("input[name=label]").val(val); } if (key == 'enable_link') $("input[name=enable_link]").val(val); @@ -491,21 +477,25 @@ function loadFieldsFromDB(item) { if (key == 'period') { var anySelected = false; var periodId = $('#hidden-period').attr('class'); - $('#'+periodId+'_select option').each(function() { + $('#' + periodId + '_select option') + .each(function() { + if($(this).val() == val) { $(this).attr('selected',true); $(this).trigger('change'); anySelected = true; } }); - if(anySelected == false) { - $('#'+periodId+'_select option').eq(0).attr('selected',true); - $('#'+periodId+'_units option').eq(0).attr('selected',true); + if (anySelected == false) { + $('#' + periodId + '_select option') + .eq(0).attr('selected',true); + $('#' + periodId + '_units option') + .eq(0).attr('selected',true); $('#hidden-period').val(val); - $('#text-'+periodId+'_text').val(val); + $('#text-' + periodId + '_text').val(val); adjustTextUnits(periodId); - $('#'+periodId+'_default').hide(); - $('#'+periodId+'_manual').show(); + $('#' + periodId + '_default').hide(); + $('#' + periodId + '_manual').show(); } } if (key == 'width') $("input[name=width]").val(val); @@ -618,9 +608,6 @@ function hiddenFields(item) { $(".title_panel_span").css('display', 'none'); $("#title_panel_span_" + item).css('display', 'inline'); - $("#label2_row").css('display', 'none'); - $("#label2_row." + item).css('display', ''); - $("#label_row").css('display', 'none'); $("#label_row." + item).css('display', ''); @@ -692,9 +679,9 @@ function hiddenFields(item) { } } -function cleanFields() { +function cleanFields(item) { $("input[name=label]").val(''); - tinymce.get('text-label2').setContent(""); + tinymce.get('text-label').setContent(""); $("select[name=image]").val(''); $("input[name=left]").val(0); $("input[name=top]").val(0); @@ -714,6 +701,12 @@ function cleanFields() { $("input[name=height_module_graph]").val(180); $("#preview").empty(); + + if (item == "simple_value") { + $("input[name=label]").val('(_VALUE_)'); + tinymce.get('text-label').setContent("(_VALUE_)"); + } + fill_parent_select(); var anyText = $("#any_text").html(); //Trick for catch the translate text. @@ -1139,8 +1132,13 @@ function createItem(type, values, id_data) { ); break; case 'label': - item = $('
' + - '' + values['label2'] + '' + + item = $('
' + + '' + + values['label'] + + '' + '
' ); break; diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.php b/pandora_console/godmode/reporting/visual_console_builder.editor.php index 69a6bbf6e3..3e4c49cef4 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.php +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.php @@ -126,7 +126,7 @@ ui_require_javascript_file ('encode_decode_base64'); tinyMCE.init({ mode : "exact", - elements: "text-label2", + elements: "text-label", theme : "advanced", data[$i + 1][0] = '' . - html_print_input_text ('label_' . $idLayoutData, $layoutData['label'], '', 10, 200, true) . + html_print_input_hidden('label_' . $idLayoutData, $layoutData['label'], true) . + '' . __('Edit label') .'' . html_print_input_text_extended ('label_color_' . $idLayoutData, $layoutData['label_color'], 'text-'.'label_color_' . $idLayoutData, '', 7, 7, false, '', 'style="visibility: hidden; width: 0px;" class="label_color"', true) . ''; } @@ -339,7 +340,12 @@ echo ''; //Trick for it have a traduct text for javascript. echo ''; - +?> +
+ + +
+ diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index 9e13db8241..0bdba60f69 100644 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -44,7 +44,6 @@ $id_element = get_parameter('id_element', null); $image = get_parameter('image', null); $background = get_parameter('background', null); $label = get_parameter('label', ''); -$label2 = get_parameter('label2', ''); $left = get_parameter('left', null); $top = get_parameter('top', null); $agent = get_parameter('agent', null); @@ -319,8 +318,7 @@ switch ($action) { default: if ($type == 'label') { $values['type'] = LABEL; - $values['label'] = $label2; - $label = $label2; + $values['label'] = $label; } if ($enable_link !== null) { @@ -611,8 +609,7 @@ switch ($action) { break; case 'label': $values['type'] = LABEL; - $values['label'] = $label2; - $label = $label2; + $values['label'] = $label; break; case 'icon': $values['type'] = ICON; diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index ada93de419..05f3efc13a 100644 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -118,7 +118,7 @@ function visual_map_print_item($layoutData) { echo html_print_image($img, true, array("class" => "image", "id" => "image_" . $id, "style" => $borderStyle)); echo '
'; } - echo $text; + echo io_safe_output($text); echo "
"; break; @@ -163,7 +163,7 @@ function visual_map_print_item($layoutData) { $percentile = 100; echo '
'; - echo $text . '
'; + echo io_safe_output($text) . '
'; ob_start(); if ($type == PERCENTILE_BUBBLE) { @@ -201,7 +201,7 @@ function visual_map_print_item($layoutData) { $img = str_replace('>', 'class="image" id="image_' . $id . '" />', $img); echo '
'; - echo $text . '
'; + echo io_safe_output($text) . '
'; echo $img; echo '
'; break; @@ -210,7 +210,7 @@ function visual_map_print_item($layoutData) { case SIMPLE_VALUE_MIN: case SIMPLE_VALUE_AVG: echo '
'; - echo $text; + echo io_safe_output($text); //Metaconsole db connection if ($layoutData['id_metaconsole'] != 0) { @@ -249,7 +249,7 @@ function visual_map_print_item($layoutData) { echo '
'; if ($layoutData['image'] != null) { // If match with protocol://direction - if (preg_match('/^(http:\/\/)((.)+)$/i', $text)){ + if (preg_match('/^(http:\/\/)((.)+)$/i', $text)) { echo '' . '' . '
'; } @@ -1125,7 +1125,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line } $img_style = array (); - $img_style["title"] = $layout_data["label"]; + $img_style["title"] = strip_tags($layout_data["label"]); if (!empty ($layout_data["width"])) { $img_style["width"] = $layout_data["width"]; @@ -1191,7 +1191,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line // Print label if valid label_color (only testing for starting with #) otherwise print nothing if ($layout_data['label_color'][0] == '#') { echo "
"; - echo $layout_data['label']; + echo io_safe_output($layout_data['label']); } echo "
"; @@ -1217,7 +1217,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line } if ($layout_data['label_color'][0] == '#') { echo "
"; - echo $layout_data['label']; + echo io_safe_output($layout_data['label']); } if ($endTagA) echo ""; echo "
"; @@ -1374,7 +1374,16 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line } } - echo '' . $layout_data['label']. ' '; + $label_simple_value = io_safe_output($layout_data['label']); + if (strstr($label_simple_value, '(_VALUE_)') === false) { + //OLD MODE + $label_simple_value = '' . $label_simple_value . ' '; + } + else { + //NEW MODE WITH MACRO (_VALUE_) + } + + //TODO: change interface to add a period parameter, now is set to 1 day switch ($layout_data['type']) { case SIMPLE_VALUE: @@ -1402,7 +1411,6 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line $value = format_for_graph($value, 2); if (!empty($unit_text)) $value .= " " . $unit_text; - echo $value; break; case SIMPLE_VALUE_MAX: @@ -1435,7 +1443,6 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line if (!empty($unit_text)) $value .= " " . $unit_text; } - echo $value; break; case SIMPLE_VALUE_MIN: @@ -1468,7 +1475,6 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line if (!empty($unit_text)) $value .= " " . $unit_text; } - echo $value; break; case SIMPLE_VALUE_AVG: @@ -1502,10 +1508,21 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line if (!empty($unit_text)) $value .= " " . $unit_text; } - echo $value; break; } - echo ''; + + if (strstr($label_simple_value, '(_VALUE_)') === false) { + //OLD MODE + $label_simple_value .= ''; + } + else { + //NEW MODE WITH MACRO (_VALUE_) + + $label_simple_value = str_replace('(_VALUE_)', + $value, $label_simple_value); + } + + echo $label_simple_value; if ($endTagA) echo ''; @@ -1558,7 +1575,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line $endTagA = false; - echo $layout_data['label']; + echo io_safe_output($layout_data['label']); echo "
"; if ($show_links) { @@ -1697,7 +1714,7 @@ function visual_map_print_visual_map ($id_layout, $show_links = true, $draw_line echo '
'; - echo $layout_data['label']; + echo io_safe_output($layout_data['label']); echo "
"; $endTagA = false; diff --git a/pandora_console/include/functions_visual_map_editor.php b/pandora_console/include/functions_visual_map_editor.php index e9dbbd9eaf..77318afac2 100644 --- a/pandora_console/include/functions_visual_map_editor.php +++ b/pandora_console/include/functions_visual_map_editor.php @@ -75,18 +75,19 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) { ' . __('Label') .' '. html_print_input_text ('label', '', '', 20, 200, true) .''; + */ - - $form_items['label2_row'] = array(); - $form_items['label2_row']['items'] = array('label'); - $form_items['label2_row']['html'] = '' . __('Label') .' - '. html_print_input_text ('label2', '', '', 20, 200, true) .''; + $form_items['label_row'] = array(); + $form_items['label_row']['items'] = array('label', 'static_graph', + 'percentile_bar', 'percentile_item', 'module_graph', + 'simple_value', 'datos', 'icon'); + $form_items['label_row']['html'] = '' . __('Label') .' + '. html_print_input_text ('label', '', '', 20, 200, true) .''; $form_items['image_row'] = array(); diff --git a/pandora_console/include/help/en/help_visual_console_editor_editor_tab.php b/pandora_console/include/help/en/help_visual_console_editor_editor_tab.php index 63108f899d..fcdb43a897 100644 --- a/pandora_console/include/help/en/help_visual_console_editor_editor_tab.php +++ b/pandora_console/include/help/en/help_visual_console_editor_editor_tab.php @@ -6,4 +6,18 @@

Editor

-

This tab has most of the part of the functionality of the visual console editor, because is where you could create the elements, edit and place them. It is a dynamic page, so it will be necessary that your browser support correctly the javascript languaje. As you can see in the screen shot, the screen is divided in two areas that are well defined: the button box, the work area (where you will "draw" the visual console) and the option palette ( that is not visible in this screen shot).

+

This tab has most of the part of the functionality of the +visual console editor, because is where you could create the elements, +edit and place them. It is a dynamic page, so it will be necessary that +your browser support correctly the javascript languaje. As you can see +in the screen shot, the screen is divided in two areas that are well +defined: +

    +
  • the button box
  • +
  • the work area (where you will "draw" the visual console)
  • +
  • the option palette ( that is not visible in this screen shot)
  • +
+In the version Pandora 5.0.1 you can set the label with a rich text. +And the item "Simple value" you can use the macros to set inner the text +with (_VALUE_). +

diff --git a/pandora_console/include/javascript/jquery.pandora.js b/pandora_console/include/javascript/jquery.pandora.js index bb111401d4..e03d385586 100644 --- a/pandora_console/include/javascript/jquery.pandora.js +++ b/pandora_console/include/javascript/jquery.pandora.js @@ -80,7 +80,7 @@ $(document).ready (function () { .show (); }, "html" - ); + ); return false; });