diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9b7e4fd5c5..fc2a83967b 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2010-03-24 Miguel de Dios <miguel.dedios@artica.es> + + * include/ajax/visual_console_builder.ajax.php, + godmode/reporting/visual_console_builder.editor.php, + godmode/reporting/map_builder.php, + godmode/reporting/visual_console_builder.editor.js: worked about the new + visual console builder editor, now it is developing, don't afray. + + * godmode/reporting/visual_console_builder.constans.php: added the file that + it has the constans. + 2010-03-24 Miguel de Dios <miguel.dedios@artica.es> * include/config_process.php, diff --git a/pandora_console/godmode/reporting/map_builder.php b/pandora_console/godmode/reporting/map_builder.php index 24d42e9366..a8935743de 100644 --- a/pandora_console/godmode/reporting/map_builder.php +++ b/pandora_console/godmode/reporting/map_builder.php @@ -323,7 +323,7 @@ if (! $edit_layout && ! $id_layout) { foreach ($maps as $map) { if (give_acl ($config['id_user'], $map['id_group'], "AW")){ $data = array (); - $data[0] = '<a href="index.php?sec=gmap&sec2=godmode/reporting/map_builder&id_layout='.$map['id'].'">'.$map['name'].'</a>'; + $data[0] = '<a href="index.php?sec=gmap&sec2=godmode/reporting/visual_console_builder&tab=data&action=edit&id_visual_console='.$map['id'].'">'.$map['name'].'</a>'; $data[1] = print_group_icon ($map['id_group'], true).' '; $data[1] .= get_group_name ($map['id_group']); diff --git a/pandora_console/godmode/reporting/visual_console_builder.constans.php b/pandora_console/godmode/reporting/visual_console_builder.constans.php new file mode 100644 index 0000000000..aee678b5ff --- /dev/null +++ b/pandora_console/godmode/reporting/visual_console_builder.constans.php @@ -0,0 +1,18 @@ +<?php +// Pandora FMS - http://pandorafms.com +// ================================================== +// Copyright (c) 2005-2009 Artica Soluciones Tecnologicas +// Please see http://pandorafms.org for full contribution list + +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation for version 2. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +//constants +define('STATIC_GRAPH', 0); +define('PERCENTILE_BAR', 3); +?> \ No newline at end of file diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.js b/pandora_console/godmode/reporting/visual_console_builder.editor.js index 470592c1e7..a908e4dbcb 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.js +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.js @@ -27,12 +27,6 @@ function editorMain2() { eventsTextAgent(); draw_lines(lines, 'background'); -// var lines = Array (); -// lines.push (eval ({"id":"116","node_begin":"layout-data-115","node_end":"layout-data-116","color":"#ccc"})); - - //$("#background").append($('<div id="pepito"></div>')); -// draw_line({"node_begin":"112","node_end":"110","color":"#000"}, 'background'); - //$(".map-line").css('z-index', '0'); $(".item").css('z-index', '1'); //For paint the icons over lines } @@ -121,6 +115,22 @@ function updateAction() { case 'static_graph': $("#text_" + idItem).html(values['label']); $("#image_" + idItem).attr('src', getImageElement(idItem)); + if ((values['width'] != 0) && (values['height'] != 0)) { + $("#image_" + idItem).attr('width', values['width']); + $("#image_" + idItem).attr('height', values['height']); + $("#" + idItem).css('width', values['width'] + 'px'); + $("#" + idItem).css('height', values['height'] + 'px'); + } + else { + $("#image_" + idItem).removeAttr('width'); + $("#image_" + idItem).removeAttr('height'); + $("#" + idItem).css('width', ''); + $("#" + idItem).css('height', ''); + } + break; + case 'percentile_bar': + $("#text_" + idItem).html(values['label']); + $("#image_" + idItem).attr('src', getPercentileBar(idItem)); break; } @@ -143,6 +153,8 @@ function readFields() { values['parent'] = $("select[name=parent]").val(); values['map_linked'] = $("select[name=map_linked]").val(); values['label_color'] = $("input[name=label_color]").val(); + values['width_percentile'] = $("input[name=width_percentile]").val(); + values['max_percentile'] = $("input[name=max_percentile]").val(); return values; } @@ -258,14 +270,16 @@ function loadFieldsFromDB(item) { if (key == 'parent_item') $("select[name=parent]").val(val); if (key == 'id_layout_linked') $("select[name=map_linked]").val(val); if (key == 'label_color') $("input[name=label_color]").val(val); + if (key == 'width_percentile') $("input[name=width_percentile]").val(val); + if (key == 'max_percentile') $("input[name=max_percentile]").val(val); }); } }); } function hiddenFields(item) { - $(".tittle_panel_span").css('display', 'none'); - $("#tittle_panel_span_" + item).css('display', 'inline'); + $(".title_panel_span").css('display', 'none'); + $("#title_panel_span_" + item).css('display', 'inline'); $("#label_row").css('display', 'none'); $("#label_row." + item).css('display', ''); @@ -285,6 +299,12 @@ function hiddenFields(item) { $("#background_row").css('display', 'none'); $("#background_row." + item).css('display', ''); + $("#percentile_bar_row_1").css('display', 'none'); + $("#percentile_bar_row_1." + item).css('display', ''); + + $("#percentile_bar_row_2").css('display', 'none'); + $("#percentile_bar_row_2." + item).css('display', ''); + $("#period_row").css('display', 'none'); $("#period_row." + item).css('display', ''); @@ -309,6 +329,8 @@ function cleanFields() { $("input[name=agent]").val(''); $("select[name=module]").val(''); $("select[name=background_image]").val(''); + $("input[name=width_percentile]").val(''); + $("input[name=max_percentile]").val(''); $("select[name=period]").val(''); $("input[name=width]").val(0); $("input[name=height]").val(0); @@ -316,10 +338,41 @@ function cleanFields() { $("select[name=map_linked]").val(''); $("input[name=label_color]").val('#000000'); $("#preview").empty(); - var anyText = $("#any_text").html(); + + var anyText = $("#any_text").html(); //Trick for catch the translate text. $("#module").empty().append($('<option value="0" selected="selected">' + anyText + '</option></select>')); } +function getPercentileBar(id_data) { + 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}); + jQuery.ajax({ + async: false, + url: "ajax.php", + data: parameter, + type: "POST", + dataType: 'json', + success: function (data) + { + module_value = data['value']; + max_percentile = data['max_percentile']; + width_percentile = data['width_percentile']; + } + }); + + if ( max_percentile > 0) + var percentile = module_value / max_percentile * 100; + else + var percentile = 100; + + var img = 'include/fgraph.php?tipo=progress&height=15&width=' + width_percentile + '&mode=1&percent=' + percentile; + + console.log(img); + return img; +} + function getImageElement(id_data) { var parameter = Array(); parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"}); @@ -367,23 +420,32 @@ function getColorLineStatus(id) { } function createItem(type, values, id_data) { - if ((values['width'] == 0) && (values['height'] == 0)) { - var sizeStyle = ''; - var imageSize = ''; - } - else { - var sizeStyle = 'width: ' + values['width'] + 'px; height: ' + values['height'] + 'px;'; - var imageSize = 'width="' + values['width'] + '" height="' + values['height'] + '"'; - } - switch (type) { case 'static_graph': + if ((values['width'] == 0) && (values['height'] == 0)) { + var sizeStyle = ''; + var imageSize = ''; + } + else { + var sizeStyle = 'width: ' + values['width'] + 'px; height: ' + values['height'] + 'px;'; + var imageSize = 'width="' + values['width'] + '" height="' + values['height'] + '"'; + } var item = $('<div id="' + id_data + '" class="item static_graph" style="color: ' + values['label_color'] + '; text-align: center; position: absolute; ' + sizeStyle + ' margin-top: ' + values['top'] + 'px; margin-left: ' + values['left'] + 'px;">' + '<img id="image_' + id_data + '" class="image" src="' + getImageElement(id_data) + '" ' + imageSize + ' /><br />' + '<span id="text_' + id_data + '" class="text">' + values['label'] + '</span>' + '</div>' ); break; + case 'percentile_bar': + var sizeStyle = ''; + var imageSize = ''; + + var item = $('<div id="' + id_data + '" class="item percentile_bar" style="color: ' + values['label_color'] + '; text-align: center; position: absolute; ' + sizeStyle + ' margin-top: ' + values['top'] + 'px; margin-left: ' + values['left'] + 'px;">' + + '<span id="text_' + id_data + '" class="text">' + values['label'] + '</span><br />' + + '<img class="image" id="image_' + id_data + '" src=' + getPercentileBar(id_data) + '" />' + + '</div>' + ); + break; } $("#background").append(item); @@ -475,6 +537,15 @@ function updateDB(type, idElement , values) { } $("#" + idElement).css('color', values['label_color']); break; + case 'percentile_bar': + if ((typeof(values['mov_left']) != 'undefined') && + (typeof(values['mov_top']) != 'undefined')) { + $("#" + idElement).css('top', '0px').css('margin-top', top + 'px'); + $("#" + idElement).css('left', '0px').css('margin-left', left + 'px'); + refresh_lines(lines, 'background'); + } + $("#" + idElement).css('color', values['label_color']); + break; case 'background': $("#background").css('width', values['width'] + 'px'); $("#background").css('height', values['height'] + 'px'); @@ -559,6 +630,13 @@ function eventsItems() { activeToolboxButton('edit_item', true); activeToolboxButton('delete_item', true); } + if ($(divParent).hasClass('percentile_bar')) { + creationItem = null; + selectedItem = 'percentile_bar'; + idItem = $(divParent).attr('id'); + activeToolboxButton('edit_item', true); + activeToolboxButton('delete_item', true); + } } }); @@ -585,6 +663,13 @@ function eventsItems() { activeToolboxButton('edit_item', true); activeToolboxButton('delete_item', true); } + if ($(divParent).hasClass('percentile_bar')) { + creationItem = null; + selectedItem = 'percentile_bar'; + idItem = $(divParent).attr('id'); + activeToolboxButton('edit_item', true); + activeToolboxButton('delete_item', true); + } } }); @@ -726,6 +811,8 @@ function eventsButtonsToolbox() { actionClick(); break; case 'percentile_bar': + creationItem = 'percentile_bar'; + actionClick(); break; case 'module_graph': break; diff --git a/pandora_console/godmode/reporting/visual_console_builder.editor.php b/pandora_console/godmode/reporting/visual_console_builder.editor.php index f54c09a2c4..459c362175 100644 --- a/pandora_console/godmode/reporting/visual_console_builder.editor.php +++ b/pandora_console/godmode/reporting/visual_console_builder.editor.php @@ -24,6 +24,7 @@ if (! give_acl ($config['id_user'], 0, "IW")) { exit; } +require_once('godmode/reporting/visual_console_builder.constans.php'); require_once ('include/functions_visual_map.php'); //Arrays for select box. @@ -96,11 +97,12 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde ?> <table class="databox" border="0" cellpadding="4" cellspacing="4" width="300"> <caption> - <span id="tittle_panel_span_background" class="tittle_panel_span" style="display: none; font-weight: bolder;"><?php echo __('Background');?></span><br /><br /> - <span id="tittle_panel_span_static_graph" class="tittle_panel_span" style="display: none; font-weight: bolder;"><?php echo __('Static Graph');?></span><br /><br /> + <span id="title_panel_span_background" class="title_panel_span" style="display: none; visibility:hidden; font-weight: bolder;"><?php echo __('Background');?></span> + <span id="title_panel_span_static_graph" class="title_panel_span" style="display: none; font-weight: bolder;"><?php echo __('Static Graph');?></span> + <span id="title_panel_span_percentile_bar" class="title_panel_span" style="display: none; font-weight: bolder;"><?php echo __('Percentile Bar');?></span> </caption> <tbody> - <tr id="label_row" style="" class="static_graph"> + <tr id="label_row" style="" class="static_graph percentile_bar datos"> <td style=""><?php echo __('Label');?></td> <td style=""><?php print_input_text ('label', '', '', 20, 200); ?></td> </tr> @@ -108,22 +110,38 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde <td><?php echo __('Image');?></td> <td><?php print_select ($images_list, 'image', '', 'showPreviewStaticGraph(this.value);', 'None', '');?></td> </tr> - <tr id="preview_row" style="" class="static_graph datos2"> + <tr id="preview_row" style="" class="static_graph datos"> <td colspan="2" style="text-align: right;"><div id="preview" style="text-align: right;"></div></td> </tr> - <tr id="agent_row" class="static_graph datos2"> - <td><?php echo __('Agent');?></td> + <tr id="agent_row" class="static_graph percentile_bar datos"> + <td><?php echo __('Agent') . '<a href="#" class="tip"> <span>' . __("Type at least two characters to search.") . '</span></a>';?></td> <td><?php print_input_text_extended ('agent', '', 'text-agent', '', 25, 100, false, '', array('style' => 'background: #ffffff url(images/lightning.png) no-repeat right;'), false);?></td> </tr> - <tr id="module_row" class="static_graph datos"> + <tr id="module_row" class="static_graph percentile_bar datos"> <td><?php echo __('Module');?></td> <td><?php print_select (array (), 'module', '', '', __('Any'), 0);?></td> </tr> - <tr id="background_row" class="background datos2"> + <tr id="background_row" class="background datos"> <td><?php echo __('Background');?></td> <td><?php print_select($backgrounds_list, 'background_image', $background, '', 'None', '');?></td> </tr> + <tr id="percentile_bar_row_1" class="percentile_bar datos"> + <td><?php echo __('Width');?></td> + <td> + <?php + print_input_text('width_percentile', 0, '', 3, 5); + ?> + </td> + </tr> + <tr id="percentile_bar_row_2" class="percentile_bar datos"> + <td><?php echo __('Max value');?></td> + <td> + <?php + print_input_text('max_percentile', 0, '', 3, 5); + ?> + </td> + </tr> <tr id="button_update_row" class="datos"> <td colspan="2" style="text-align: right;"> <?php @@ -132,7 +150,7 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde ?> </td> </tr> - <tr id="button_create_row" class="datos2"> + <tr id="button_create_row" class="datos"> <td colspan="2" style="text-align: right;"> <?php print_button(__('Cancel'), 'cancel_button', false, 'cancelAction();', 'class="sub"'); @@ -147,11 +165,11 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde </tr> </tbody> <tbody id="advance_options" style="display: none;"> - <tr id="period_row" class="module_graph datos2"> + <tr id="period_row" class="module_graph datos"> <td><?php echo __('Period');?></td> <td><?php print_select ($intervals, 'period', '', '', '--', 0);?></td> </tr> - <tr id="position_row" class="static_graph datos"> + <tr id="position_row" class="static_graph percentile_bar datos"> <td><?php echo __('Position');?></td> <td> <?php @@ -164,7 +182,7 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde </td> </tr> <tr id="size_row" class="background static_graph datos"> - <td><?php echo __('Size');?></td> + <td><?php echo __('Size') . '<a href="#" class="tip"> <span>' . __("For use the original image file size, set 0 width and 0 height.") . '</span></a>';?></td> <td> <?php print_input_text('width', 0, '', 3, 5); @@ -173,11 +191,11 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde ?> </td> </tr> - <tr id="parent_row" class="static_graph datos2"> + <tr id="parent_row" class="static_graph percentile_bar datos"> <td><?php echo __('Parent');?></td> <td><?php print_select_from_sql('SELECT id, label FROM tlayout_data WHERE id_layout = ' . $visualConsole['id'], 'parent', '', '', __('None'), 0);?></td> </tr> - <tr id="map_linked_row" class="static_graph datos"> + <tr id="map_linked_row" class="static_graph percentile_bar datos"> <td><?php echo __('Map linked');?></td> <td> <?php @@ -185,7 +203,7 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde ?> </td> </tr> - <tr id="label_color_row" class="static_graph datos"> + <tr id="label_color_row" class="static_graph percentile_bar datos"> <td><?php echo __('Label color');?></td> <td><?php print_input_text_extended ('label_color', '#000000', 'text-'.'label_color', '', 7, 7, false, '', 'class="label_color"', false);?></td> </tr> @@ -246,30 +264,53 @@ function printButtonEditorVisualConsole($idDiv, $label, $float = 'left', $disabl function printItemInVisualConsole($layoutData) { $width = $layoutData['width']; - $height = $layoutData['height']; + $height = $max_percentile = $layoutData['height']; $top = $layoutData['pos_y']; $left = $layoutData['pos_x']; $id = $layoutData['id']; $color = $layoutData['label_color']; $label = $layoutData['label']; + $id_module = $layoutData['id_agente_modulo']; + $type = $layoutData['type']; - $img = getImageStatusElement($layoutData); - $imgSizes = getimagesize($img); - //debugPrint($imgSizes); - - if (($width == 0) && ($height == 0)) { - $sizeStyle = ''; - $imageSize = ''; - } - else { - $sizeStyle = 'width: ' . $width . 'px; height: ' . $height . 'px;'; - $imageSize = 'width="' . $width . '" height="' . $height . '"'; + switch ($type) { + case STATIC_GRAPH: + $img = getImageStatusElement($layoutData); + $imgSizes = getimagesize($img); + if (($width == 0) && ($height == 0)) { + $sizeStyle = ''; + $imageSize = ''; + } + else { + $sizeStyle = 'width: ' . $width . 'px; height: ' . $height . 'px;'; + $imageSize = 'width="' . $width . '" height="' . $height . '"'; + } + echo '<div id="' . $id . '" class="item static_graph" style="text-align: center; color: ' . $color . '; position: absolute; ' . $sizeStyle . ' margin-top: ' . $top . 'px; margin-left: ' . $left . 'px;">'; + echo '<img class="image" id="image_' . $id . '" src="' . $img . '" ' . $imageSize . ' /><br />'; + echo '<span id="text_' . $id . '" class="text">' . $label . '</span>'; + echo "</div>"; + break; + case PERCENTILE_BAR: + $sizeStyle = ''; + $imageSize = ''; + + $module_value = get_db_sql ('SELECT datos FROM tagente_estado WHERE id_agente_modulo = ' . $id_module); + + if ( $max_percentile > 0) + $percentile = $module_value / $max_percentile * 100; + else + $percentile = 100; + + $img = '<img class="image" id="image_' . $id . '" src="include/fgraph.php?tipo=progress&height=15&width=' . $width . '&mode=1&percent=' . $percentile . '" />'; + + echo '<div id="' . $id . '" class="item percentile_bar" style="color: ' . $color . '; text-align: center; position: absolute; ' . $sizeStyle . ' margin-top: ' . $top . 'px; margin-left: ' . $left . 'px;">'; + echo '<span id="text_' . $id . '" class="text">' . $label . '</span><br />'; + echo $img; + echo '</div>'; + + break; } - echo '<div id="' . $id . '" class="item static_graph" style="text-align: center; color: ' . $color . '; position: absolute; ' . $sizeStyle . ' margin-top: ' . $top . 'px; margin-left: ' . $left . 'px;">'; - echo '<img class="image" id="image_' . $id . '" src="' . $img . '" ' . $imageSize . ' /><br />'; - echo '<span id="text_' . $id . '" class="text">' . $label . '</span>'; - echo "</div>"; if ($layoutData['parent_item'] != 0) { echo '<script type="text/javascript">'; echo '$(document).ready (function() { diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index cdcb4c6659..05eed69a22 100644 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -24,7 +24,8 @@ if (! give_acl ($config['id_user'], 0, "IW")) { exit; } -require_once ('include/functions_visual_map.php'); +require_once('godmode/reporting/visual_console_builder.constans.php'); +require_once('include/functions_visual_map.php'); $action = get_parameter('action'); $type = get_parameter('type'); @@ -36,15 +37,28 @@ $label = get_parameter('label', null); $left = get_parameter('left', null); $top = get_parameter('top', null); $agent = get_parameter('agent', null); -$module = get_parameter('module', null); +$id_module = get_parameter('module', null); $period = get_parameter('period', null); $width = get_parameter('width', null); $height = get_parameter('height', null); $parent = get_parameter('parent', null); $map_linked = get_parameter('map_linked', null); $label_color = get_parameter('label_color', null); +$width_percentile = get_parameter('width_percentile', null); +$max_percentile = get_parameter('max_percentile', null); switch ($action) { + case 'get_module_value': + $layoutData = get_db_row_filter('tlayout_data', array('id' => $id_element)); + $returnValue = get_db_sql ('SELECT datos FROM tagente_estado WHERE id_agente_modulo = ' . $layoutData['id_agente_modulo']); + + $return = array(); + $return['value'] = $returnValue; + $return['max_percentile'] = $layoutData['height']; + $return['width_percentile'] = $layoutData['width']; + + echo json_encode($return); + break; case 'get_color_line': $layoutData = get_db_row_filter('tlayout_data', array('id' => $id_element)); @@ -71,14 +85,17 @@ switch ($action) { $values['height'] = $height; process_sql_update('tlayout', $values, array('id' => $id_visual_console)); break; + case 'module_graph': + if ($period !== null) { + $values['period'] = $period; + } + break; + case 'percentile_bar': case 'static_graph': $values = array(); if ($label !== null) { $values['label'] = $label; } - if ($image !== null) { - $values['image'] = $image; - } if ($left !== null) { $values['pos_x'] = $left; } @@ -89,17 +106,8 @@ switch ($action) { $id_agent = get_agent_id($agent); $values['id_agent'] = $id_agent; } - if ($module !== null) { - $values['id_agente_modulo'] = $module; - } - if ($period !== null) { - $values['period'] = $period; - } - if ($width !== null) { - $values['width'] = $width; - } - if ($height !== null) { - $values['height'] = $height; + if ($id_module !== null) { + $values['id_agente_modulo'] = $id_module; } if ($parent !== null) { $values['parent_item'] = $parent; @@ -110,7 +118,27 @@ switch ($action) { if ($label_color !== null) { $values['label_color'] = $label_color; } - + switch($type) { + case 'percentile_bar': + if ($width_percentile !== null) { + $values['width'] = $width_percentile; + } + if ($max_percentile !== null) { + $values['height'] = $max_percentile; + } + break; + case 'static_graph': + if ($image !== null) { + $values['image'] = $image; + } + if ($width !== null) { + $values['width'] = $width; + } + if ($height !== null) { + $values['height'] = $height; + } + break; + } $result = process_sql_update('tlayout_data', $values, array('id' => $id_element)); break; } @@ -121,6 +149,27 @@ switch ($action) { $backgroundFields = get_db_row_filter('tlayout', array('id' => $id_visual_console), array('background', 'height', 'width')); echo json_encode($backgroundFields); break; + case 'percentile_bar': + $elementFields = get_db_row_filter('tlayout_data', array('id' => $id_element)); + $elementFields['agent_name'] = get_agent_name($elementFields['id_agent']); + + $elementFields['width_percentile'] = $elementFields['width']; + $elementFields['max_percentile'] = $elementFields['height']; + + if ($elementFields['id_agent'] != 0) { + $modules = get_agent_modules ($elementFields['id_agent'], false, array('disabled' => 0, 'id_agente' => $elementFields['id_agent'])); + + $elementFields['modules_html'] = '<option value="0">--</option>'; + foreach ($modules as $id => $name) { + $elementFields['modules_html'] .= '<option value="' . $id . '">' . $name . '</option>'; + } + } + else { + $elementFields['modules_html'] = '<option value="0">' . __('Any') . '</option>'; + } + + echo json_encode($elementFields); + break; case 'static_graph': $elementFields = get_db_row_filter('tlayout_data', array('id' => $id_element)); $elementFields['agent_name'] = get_agent_name($elementFields['id_agent']); @@ -142,39 +191,45 @@ switch ($action) { } break; case 'insert': + $values = array(); + $values['id_layout'] = $id_visual_console; + $values['label'] = $label; + $values['pos_x'] = $left; + $values['pos_y'] = $top; + if ($agent != '') + $values['id_agent'] = get_agent_id($agent); + else + $values['id_agent'] = 0; + $values['id_agente_modulo'] = $id_module; + $values['id_layout_linked'] = $map_linked; + $values['label_color'] = $label_color; + $values['parent_item'] = $parent; + switch ($type) { + case 'percentile_bar': + $values['type'] = PERCENTILE_BAR; + $values['width'] = $width_percentile; + $values['height'] = $max_percentile; + break; case 'static_graph': - $values = array(); - $values['id_layout'] = $id_visual_console; - $values['label'] = $label; + $values['type'] = STATIC_GRAPH; $values['image'] = $image; - $values['pos_x'] = $left; - $values['pos_y'] = $top; - $values['label_color'] = $label_color; - if ($agent != '') - $values['id_agent'] = get_agent_id($agent); - else - $values['id_agent'] = 0; - $values['id_agente_modulo'] = $module; $values['width'] = $width; $values['height'] = $height; - $values['id_layout_linked'] = $map_linked; - $values['parent_item'] = $parent; - - $idData = process_sql_insert('tlayout_data', $values); - - $return = array(); - if ($idData === false) { - $return['correct'] = 0; - } - else { - $return['correct'] = 1; - $return['id_data'] = $idData; - $return['text'] = $label; - } - echo json_encode($return); break; } + $idData = process_sql_insert('tlayout_data', $values); + + $return = array(); + if ($idData === false) { + $return['correct'] = 0; + } + else { + $return['correct'] = 1; + $return['id_data'] = $idData; + $return['text'] = $label; + } + echo json_encode($return); break; case 'delete': if (process_sql_delete('tlayout_data', array('id' => $id_element, 'id_layout' => $id_visual_console)) === false) {