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/visual_console_builder.constans.php,
	godmode/reporting/visual_console_builder.editor.js: worked about the new
	visual console builder editor, now it is developing, don't afray.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2527 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2010-03-29 18:31:22 +00:00
parent 3c146799dd
commit 6b758bc76c
5 changed files with 257 additions and 37 deletions

View File

@ -1,3 +1,11 @@
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/visual_console_builder.constans.php,
godmode/reporting/visual_console_builder.editor.js: worked about the new
visual console builder editor, now it is developing, don't afray.
2010-03-24 Miguel de Dios <miguel.dedios@artica.es>
* include/ajax/visual_console_builder.ajax.php,

View File

@ -15,4 +15,6 @@
//constants
define('STATIC_GRAPH', 0);
define('PERCENTILE_BAR', 3);
define('MODULE_GRAPH', 1);
define('SIMPLE_VALUE', 2);
?>

View File

@ -132,6 +132,13 @@ function updateAction() {
$("#text_" + idItem).html(values['label']);
$("#image_" + idItem).attr('src', getPercentileBar(idItem));
break;
case 'module_graph':
$("#text_" + idItem).html(values['label']);
$("#image_" + idItem).attr('src', getModuleGraph(idItem));
break;
case 'simple_value':
$("#text_" + idItem).html(values['label']);
break;
}
actionClick();
@ -155,6 +162,8 @@ function readFields() {
values['label_color'] = $("input[name=label_color]").val();
values['width_percentile'] = $("input[name=width_percentile]").val();
values['max_percentile'] = $("input[name=max_percentile]").val();
values['width_module_graph'] = $("input[name=width_module_graph]").val();
values['height_module_graph'] = $("input[name=height_module_graph]").val();
return values;
}
@ -272,6 +281,8 @@ function loadFieldsFromDB(item) {
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);
if (key == 'width_module_graph') $("input[name=width_module_graph]").val(val);
if (key == 'height_module_graph') $("input[name=height_module_graph]").val(val);
});
}
});
@ -319,6 +330,9 @@ function hiddenFields(item) {
$("#label_color_row").css('display', 'none');
$("#label_color_row." + item).css('display', '');
$("#module_graph_size_row").css('display', 'none');
$("#module_graph_size_row." + item).css('display', '');
}
function cleanFields() {
@ -337,12 +351,60 @@ function cleanFields() {
$("select[name=parent]").val('');
$("select[name=map_linked]").val('');
$("input[name=label_color]").val('#000000');
$("input[name=width_module_graph]").val(0);
$("input[name=height_module_graph]").val(0);
$("#preview").empty();
var anyText = $("#any_text").html(); //Trick for catch the translate text.
$("#module").empty().append($('<option value="0" selected="selected">' + anyText + '</option></select>'));
}
function getModuleGraph(id_data) {
var parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
parameter.push ({name: "action", value: "get_layout_data"});
parameter.push ({name: "id_element", value: id_data});
jQuery.ajax({
async: false,
url: "ajax.php",
data: parameter,
type: "POST",
dataType: 'json',
success: function (data)
{
id_agente_modulo = data['id_agente_modulo'];
label = data['label'];
height = data['height'];
width = data['width'];
period = data['period'];
}
});
var img = 'include/fgraph.php?tipo=sparse&id=' + id_agente_modulo + '&label=' + label + '&height=' + height + '&pure=1&width=' + width + '&period=' + period;
return img;
}
function getModuleValue(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'];
}
});
return module_value;
}
function getPercentileBar(id_data) {
var parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
@ -369,7 +431,6 @@ function getPercentileBar(id_data) {
var img = 'include/fgraph.php?tipo=progress&height=15&width=' + width_percentile + '&mode=1&percent=' + percentile;
console.log(img);
return img;
}
@ -442,7 +503,27 @@ function createItem(type, values, id_data) {
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) + '" />' +
'<img class="image" id="image_' + id_data + '" src="' + getPercentileBar(id_data) + '" />' +
'</div>'
);
break;
case 'module_graph':
var sizeStyle = '';
var imageSize = '';
var item = $('<div id="' + id_data + '" class="item module_graph" 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="' + getModuleGraph(id_data) + '" />' +
'</div>'
);
break;
case 'simple_value':
var sizeStyle = '';
var imageSize = '';
var item = $('<div id="' + id_data + '" class="item simple_value" 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 />' +
'<strong>' + getModuleValue(id_data) + '</strong>' +
'</div>'
);
break;
@ -528,23 +609,30 @@ function updateDB(type, idElement , values) {
success: function (data)
{
switch (type) {
case 'module_graph':
case 'static_graph':
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 'percentile_bar':
case 'simple_value':
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']);
jQuery.each(lines, function(i, line) {
if (lines[i]['id'] == idElement) {
if (values['parent'] == 0) {
lines.splice(i);
}
else {
if ((typeof(values['mov_left']) == 'undefined') &&
(typeof(values['mov_top']) == 'undefined')) {
lines[i]['node_begin'] = values['parent'];
}
}
}
});
refresh_lines(lines, 'background');
break;
case 'background':
$("#background").css('width', values['width'] + 'px');
@ -574,7 +662,7 @@ function deleteDB(idElement) {
$("#parent > option[value=" + idElement + "]").remove();
jQuery.each(lines, function(i, line) {
if (line['id'] == idElement) {
if ((line['id'] == idElement) || (line['node_begin'] == idElement)) {
lines.splice(i);
}
});
@ -637,6 +725,20 @@ function eventsItems() {
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
}
if ($(divParent).hasClass('module_graph')) {
creationItem = null;
selectedItem = 'module_graph';
idItem = $(divParent).attr('id');
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
}
if ($(divParent).hasClass('simple_value')) {
creationItem = null;
selectedItem = 'simple_value';
idItem = $(divParent).attr('id');
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
}
}
});
@ -670,6 +772,20 @@ function eventsItems() {
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
}
if ($(divParent).hasClass('module_graph')) {
creationItem = null;
selectedItem = 'module_graph';
idItem = $(divParent).attr('id');
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
}
if ($(divParent).hasClass('simple_value')) {
creationItem = null;
selectedItem = 'simple_value';
idItem = $(divParent).attr('id');
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
}
}
});
@ -815,12 +931,12 @@ function eventsButtonsToolbox() {
actionClick();
break;
case 'module_graph':
creationItem = 'module_graph';
actionClick();
break;
case 'simple_value':
break;
case 'save_visual_console':
break;
case 'edit_item':
creationItem = 'simple_value';
actionClick();
break;
case 'delete_item':
deleteItem();

View File

@ -102,7 +102,7 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde
<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 percentile_bar datos">
<tr id="label_row" style="" class="static_graph percentile_bar module_graph simple_value datos">
<td style=""><?php echo __('Label');?></td>
<td style=""><?php print_input_text ('label', '', '', 20, 200); ?></td>
</tr>
@ -113,12 +113,12 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde
<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 percentile_bar datos">
<tr id="agent_row" class="static_graph percentile_bar module_graph simple_value datos">
<td><?php echo __('Agent') . '<a href="#" class="tip">&nbsp;<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 percentile_bar datos">
<tr id="module_row" class="static_graph percentile_bar module_graph simple_value datos">
<td><?php echo __('Module');?></td>
<td><?php print_select (array (), 'module', '', '', __('Any'), 0);?></td>
</tr>
@ -142,6 +142,20 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde
?>
</td>
</tr>
<tr id="period_row" class="module_graph datos">
<td><?php echo __('Period');?></td>
<td><?php print_select ($intervals, 'period', '', '', '--', 0);?></td>
</tr>
<tr id="module_graph_size_row" class="module_graph datos">
<td><?php echo __('Size');?></td>
<td>
<?php
print_input_text('width_module_graph', 0, '', 3, 5);
echo ' X ';
print_input_text('height_module_graph', 0, '', 3, 5);
?>
</td>
</tr>
<tr id="button_update_row" class="datos">
<td colspan="2" style="text-align: right;">
<?php
@ -165,11 +179,7 @@ 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 datos">
<td><?php echo __('Period');?></td>
<td><?php print_select ($intervals, 'period', '', '', '--', 0);?></td>
</tr>
<tr id="position_row" class="static_graph percentile_bar datos">
<tr id="position_row" class="static_graph percentile_bar module_graph simple_value datos">
<td><?php echo __('Position');?></td>
<td>
<?php
@ -191,11 +201,11 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde
?>
</td>
</tr>
<tr id="parent_row" class="static_graph percentile_bar datos">
<tr id="parent_row" class="static_graph percentile_bar module_graph simple_value 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 percentile_bar datos">
<tr id="map_linked_row" class="static_graph percentile_bar module_graph simple_value datos">
<td><?php echo __('Map linked');?></td>
<td>
<?php
@ -203,7 +213,7 @@ echo '<div id="properties_panel" style="display: none; position: absolute; borde
?>
</td>
</tr>
<tr id="label_color_row" class="static_graph percentile_bar datos">
<tr id="label_color_row" class="static_graph percentile_bar module_graph simple_value 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>
@ -272,6 +282,7 @@ function printItemInVisualConsole($layoutData) {
$label = $layoutData['label'];
$id_module = $layoutData['id_agente_modulo'];
$type = $layoutData['type'];
$period = $layoutData['period'];
switch ($type) {
case STATIC_GRAPH:
@ -308,6 +319,26 @@ function printItemInVisualConsole($layoutData) {
echo $img;
echo '</div>';
break;
case MODULE_GRAPH:
$sizeStyle = '';
$imageSize = '';
$img = '<img class="image" id="image_' . $id . '" src="include/fgraph.php?tipo=sparse&id=' . $id_module . '&label=' . $label . '&height=' . $height . '&pure=1&width=' . $width . '&period=' . $period . '" />';
echo '<div id="' . $id . '" class="item module_graph" 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;
case SIMPLE_VALUE:
$sizeStyle = '';
$imageSize = '';
echo '<div id="' . $id . '" class="item simple_value" 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 '<strong>' . get_db_value ('datos', 'tagente_estado', 'id_agente_modulo', $id_module) . '</strong>';
echo '</div>';
break;
}

View File

@ -46,8 +46,15 @@ $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);
$height_module_graph = get_parameter('height_module_graph', null);
$width_module_graph = get_parameter('width_module_graph', null);
switch ($action) {
case 'get_layout_data':
$layoutData = get_db_row_filter('tlayout_data', array('id' => $id_element));
echo json_encode($layoutData);
break;
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']);
@ -85,13 +92,10 @@ 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 'simple_value':
case 'percentile_bar':
case 'static_graph':
case 'module_graph':
$values = array();
if ($label !== null) {
$values['label'] = $label;
@ -119,6 +123,17 @@ switch ($action) {
$values['label_color'] = $label_color;
}
switch($type) {
case 'module_graph':
if ($height_module_graph !== null) {
$values['height'] = $height_module_graph;
}
if ($width_module_graph !== null) {
$values['width'] = $width_module_graph;
}
if ($period !== null) {
$values['period'] = $period;
}
break;
case 'percentile_bar':
if ($width_percentile !== null) {
$values['width'] = $width_percentile;
@ -186,6 +201,44 @@ switch ($action) {
$elementFields['modules_html'] = '<option value="0">' . __('Any') . '</option>';
}
echo json_encode($elementFields);
break;
case 'module_graph':
$elementFields = get_db_row_filter('tlayout_data', array('id' => $id_element));
$elementFields['agent_name'] = get_agent_name($elementFields['id_agent']);
$elementFields['width_module_graph'] = $elementFields['width'];
$elementFields['height_module_graph'] = $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 'simple_value':
$elementFields = get_db_row_filter('tlayout_data', array('id' => $id_element));
$elementFields['agent_name'] = get_agent_name($elementFields['id_agent']);
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;
}
@ -204,8 +257,15 @@ switch ($action) {
$values['id_layout_linked'] = $map_linked;
$values['label_color'] = $label_color;
$values['parent_item'] = $parent;
$values['no_link_color'] = 1;
switch ($type) {
case 'module_graph':
$values['type'] = MODULE_GRAPH;
$values['height'] = $height_module_graph;
$values['width'] = $width_module_graph;
$values['period'] = $period;
break;
case 'percentile_bar':
$values['type'] = PERCENTILE_BAR;
$values['width'] = $width_percentile;
@ -217,6 +277,9 @@ switch ($action) {
$values['width'] = $width;
$values['height'] = $height;
break;
case 'simple_value':
$values['type'] = SIMPLE_VALUE;
break;
}
$idData = process_sql_insert('tlayout_data', $values);