2010-03-31 Miguel de Dios <miguel.dedios@artica.es>

* include/styles/pandora.css, include/functions_visual_map.php,
	include/ajax/visual_console_builder.ajax.php,
	godmode/reporting/visual_console_builder.editor.php,
	godmode/reporting/visual_console_builder.editor.js: cleaned source code and
	changed the buttons.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@2530 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2010-03-31 09:13:54 +00:00
parent fa0166ccf3
commit 9539b3e924
5 changed files with 328 additions and 234 deletions

View File

@ -31,7 +31,7 @@ function showAdvanceOptions(close) {
}
// Main function, execute in event documentReady
function editorMain2() {
function initJavascript() {
$(".label_color").attachColorPicker();
eventsBackground();
@ -198,7 +198,6 @@ function actionClick() {
activeToolboxButton('percentile_bar', true);
activeToolboxButton('module_graph', true);
activeToolboxButton('simple_value', true);
activeToolboxButton('delete_item', true);
$(".item").draggable("enable");
$("#background").resizable('enable');
@ -220,6 +219,7 @@ function actionClick() {
activeToolboxButton('percentile_bar', false);
activeToolboxButton('module_graph', false);
activeToolboxButton('simple_value', false);
activeToolboxButton('edit_item', false);
activeToolboxButton('delete_item', false);
if (creationItem != null) {
@ -309,7 +309,10 @@ function hiddenFields(item) {
$("#label_row." + item).css('display', '');
$("#image_row").css('display', 'none');
$("#image_row." + item).css('display', '');
$("#image_row." + item).css('display', '');
$("#preview_row").css('display', 'none');
$("#preview_row." + item).css('display', '');
$("#position_row").css('display', 'none');
$("#position_row." + item).css('display', '');
@ -693,12 +696,14 @@ function deleteDB(idElement) {
function activeToolboxButton(id, active) {
if (active) {
$("#" + id).attr('class', 'button_toolbox');
$(".label", $("#" + id)).css('color','#000000');
$("input." + id + "[name=button_toolbox2]").removeAttr('disabled');
// $("#" + id).attr('class', 'button_toolbox');
// $(".label", $("#" + id)).css('color','#000000');
}
else {
$("#" + id).attr('class', 'button_toolbox disabled');
$(".label", $("#" + id)).css('color','#aaaaaa');
$("input." + id + "[name=button_toolbox2]").attr('disabled', 'disabled');
// $("#" + id).attr('class', 'button_toolbox disabled');
// $(".label", $("#" + id)).css('color','#aaaaaa');
}
}
@ -864,99 +869,126 @@ function unselectAll() {
}
function eventsButtonsToolbox() {
$('.button_toolbox').mouseover(function(event) {
event.stopPropagation();
// $('.button_toolbox').mouseover(function(event) {
// event.stopPropagation();
//
// // over label
// if ($(event.target).is('span')) {
// id = $(event.target).parent().attr('id');
// }
// else {
// id = $(event.target).attr('id');
// }
//
// if ($("#" + id).hasClass('disabled') == false) {
// $("#" + id).css('background', '#f5f5f5');
// }
// });
//
// $('.button_toolbox').mouseout(function(event) {
// event.stopPropagation();
// id = $(event.target).attr('id');
// if ($("#" + id).hasClass('disabled') == false) {
// $("#" + id).css('background', '#e5e5e5');
// }
// $("#" + id).css('border', '4px outset black');
// });
//
// $('.button_toolbox').mousedown(function(event) {
// event.stopPropagation();
//
// // over label
// if ($(event.target).is('span')) {
// id = $(event.target).parent().attr('id');
// }
// else {
// id = $(event.target).attr('id');
// }
//
// if ($("#" + id).hasClass('disabled') == false) {
// $("#" + id).css('border', '4px inset black');
// }
// });
//
// $('.button_toolbox').mouseup(function(event) {
// event.stopPropagation();
//
// // over label
// if ($(event.target).is('span')) {
// id = $(event.target).parent().attr('id');
// }
// else {
// id = $(event.target).attr('id');
// }
//
// $("#" + id).css('border', '4px outset black');
// });
//
// $('.button_toolbox').click(function(event) {
// event.stopPropagation();
//
// // over label
// if ($(event.target).is('span')) {
// id = $(event.target).parent().attr('id');
// }
// else {
// id = $(event.target).attr('id');
// }
//
// if ($("#" + id).hasClass('disabled') == false) {
// switch (id) {
// case 'edit_item':
// actionClick();
// break;
// case 'static_graph':
// creationItem = 'static_graph';
// actionClick();
// break;
// case 'percentile_bar':
// creationItem = 'percentile_bar';
// actionClick();
// break;
// case 'module_graph':
// creationItem = 'module_graph';
// actionClick();
// break;
// case 'simple_value':
// creationItem = 'simple_value';
// actionClick();
// break;
// case 'delete_item':
// deleteItem();
// break;
// }
// }
// });
}
// over label
if ($(event.target).is('span')) {
id = $(event.target).parent().attr('id');
}
else {
id = $(event.target).attr('id');
}
if ($("#" + id).hasClass('disabled') == false) {
$("#" + id).css('background', '#f5f5f5');
}
});
$('.button_toolbox').mouseout(function(event) {
event.stopPropagation();
id = $(event.target).attr('id');
if ($("#" + id).hasClass('disabled') == false) {
$("#" + id).css('background', '#e5e5e5');
}
$("#" + id).css('border', '4px outset black');
});
$('.button_toolbox').mousedown(function(event) {
event.stopPropagation();
// over label
if ($(event.target).is('span')) {
id = $(event.target).parent().attr('id');
}
else {
id = $(event.target).attr('id');
}
if ($("#" + id).hasClass('disabled') == false) {
$("#" + id).css('border', '4px inset black');
}
});
$('.button_toolbox').mouseup(function(event) {
event.stopPropagation();
// over label
if ($(event.target).is('span')) {
id = $(event.target).parent().attr('id');
}
else {
id = $(event.target).attr('id');
}
$("#" + id).css('border', '4px outset black');
});
$('.button_toolbox').click(function(event) {
event.stopPropagation();
// over label
if ($(event.target).is('span')) {
id = $(event.target).parent().attr('id');
}
else {
id = $(event.target).attr('id');
}
if ($("#" + id).hasClass('disabled') == false) {
switch (id) {
case 'edit_item':
actionClick();
break;
case 'static_graph':
creationItem = 'static_graph';
actionClick();
break;
case 'percentile_bar':
creationItem = 'percentile_bar';
actionClick();
break;
case 'module_graph':
creationItem = 'module_graph';
actionClick();
break;
case 'simple_value':
creationItem = 'simple_value';
actionClick();
break;
case 'delete_item':
deleteItem();
break;
}
}
});
function click2(id) {
switch (id) {
case 'edit_item':
actionClick();
break;
case 'static_graph':
creationItem = 'static_graph';
actionClick();
break;
case 'percentile_bar':
creationItem = 'percentile_bar';
actionClick();
break;
case 'module_graph':
creationItem = 'module_graph';
actionClick();
break;
case 'simple_value':
creationItem = 'simple_value';
actionClick();
break;
case 'delete_item':
deleteItem();
break;
}
}
function showPreviewStaticGraph(staticGraph) {

View File

@ -46,13 +46,13 @@ foreach ($all_images as $image_file) {
echo '<div id="editor">';
echo '<div id="toolbox">';
printButtonEditorVisualConsole('static_graph', __('Static Graph'));
printButtonEditorVisualConsole('percentile_bar', __('Percentile Bar'));
printButtonEditorVisualConsole('module_graph', __('Module Graph'));
printButtonEditorVisualConsole('simple_value', __('Simple Value'));
printButtonEditorVisualConsole('static_graph', __('Static Graph'), 'left', false, 'camera');
printButtonEditorVisualConsole('percentile_bar', __('Percentile Bar'), 'left', false, 'percentile');
printButtonEditorVisualConsole('module_graph', __('Module Graph'), 'left', false, 'graph');
printButtonEditorVisualConsole('simple_value', __('Simple Value'), 'left', false, 'binary');
printButtonEditorVisualConsole('edit_item', __('Edit item'), 'right', true);
printButtonEditorVisualConsole('delete_item', __('Delete item'), 'right', true);
printButtonEditorVisualConsole('edit_item', __('Edit item'), 'right', true, 'config');
printButtonEditorVisualConsole('delete_item', __('Delete item'), 'right', true, 'delete');
echo '</div>';
echo '</div>';
echo '<div style="clear:both;"></div>';
@ -246,110 +246,6 @@ require_jquery_file('ui.draggable');
require_javascript_file('wz_jsgraphics');
require_javascript_file('pandora_visual_console');
require_javascript_file('visual_console_builder.editor', 'godmode/reporting/');
function printButtonEditorVisualConsole($idDiv, $label, $float = 'left', $disabled = false) {
if (!$disabled) $disableClass = '';
else $disableClass = 'disabled';
if ($float == 'left') {
$margin = 'margin-right';
}
else {
$margin = 'margin-left';
}
echo '<div class="button_toolbox ' . $disableClass . '" id="' . $idDiv . '"
style="font-weight: bolder; text-align: center; float: ' . $float . ';' .
'width: 80px; height: 50px; background: #e5e5e5; border: 4px outset black; ' . $margin . ': 5px;">';
if ($disabled) {
echo '<span class="label" style="color: #aaaaaa;">';
}
else {
echo '<span class="label" style="color: #000000;">';
}
echo $label;
echo '</span>';
echo '</div>';
}
function printItemInVisualConsole($layoutData) {
$width = $layoutData['width'];
$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'];
$period = $layoutData['period'];
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;
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;
}
if ($layoutData['parent_item'] != 0) {
echo '<script type="text/javascript">';
echo '$(document).ready (function() {
lines.push({"id": "' . $id . '" , "node_begin":"' . $layoutData['parent_item'] . '","node_end":"' . $id . '","color":"' . getColorLineStatus($layoutData) . '"});
});';
echo '</script>';
}
}
?>
<style type="text/css">
.ui-resizable-handle {
@ -359,5 +255,5 @@ function printItemInVisualConsole($layoutData) {
</style>
<script type="text/javascript">
id_visual_console = <?php echo $visualConsole['id']; ?>;
$(document).ready (editorMain2);
$(document).ready (initJavascript);
</script>

View File

@ -29,8 +29,11 @@ require_once('include/functions_visual_map.php');
$action = get_parameter('action');
$type = get_parameter('type');
$id_visual_console = get_parameter('id_visual_console', null);
$id_element = get_parameter('id_element', null);
$image = get_parameter('image', null);
$background = get_parameter('background', null);
$label = get_parameter('label', null);

View File

@ -19,6 +19,119 @@
* @subpackage Reporting
*/
function printButtonEditorVisualConsole($idDiv, $label, $float = 'left', $disabled = false, $class= '') {
if ($float == 'left') {
$margin = 'margin-right';
}
else {
$margin = 'margin-left';
}
print_button($label, 'button_toolbox2', $disabled, "click2('" . $idDiv . "');", 'class="sub ' . $idDiv . ' ' . $class . '" style="float: ' . $float . '; ' . $margin . ': 5px;"');
return;
if (!$disabled) $disableClass = '';
else $disableClass = 'disabled';
echo '<div class="button_toolbox ' . $disableClass . '" id="' . $idDiv . '"
style="font-weight: bolder; text-align: center; float: ' . $float . ';' .
'width: 80px; height: 50px; background: #e5e5e5; border: 4px outset black; ' . $margin . ': 5px;">';
if ($disabled) {
echo '<span class="label" style="color: #aaaaaa;">';
}
else {
echo '<span class="label" style="color: #000000;">';
}
echo $label;
echo '</span>';
echo '</div>';
}
function printItemInVisualConsole($layoutData) {
$width = $layoutData['width'];
$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'];
$period = $layoutData['period'];
$sizeStyle = '';
$imageSize = '';
$text = '<span id="text_' . $id . '" class="text">' . $label . '</span>';
switch ($type) {
case STATIC_GRAPH:
$img = getImageStatusElement($layoutData);
$imgSizes = getimagesize($img);
if (($width != 0) && ($height != 0)) {
$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 $text;
echo "</div>";
break;
case PERCENTILE_BAR:
$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 $text . '<br />';
echo $img;
echo '</div>';
break;
case MODULE_GRAPH:
$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 $text . '<br />';
echo $img;
echo '</div>';
break;
case SIMPLE_VALUE:
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 $text . '<br />';
echo '<strong>' . get_db_value ('datos', 'tagente_estado', 'id_agente_modulo', $id_module) . '</strong>';
echo '</div>';
break;
}
//Add the line between elements.
if ($layoutData['parent_item'] != 0) {
echo '<script type="text/javascript">';
echo '$(document).ready (function() {
lines.push({"id": "' . $id . '" , "node_begin":"' . $layoutData['parent_item'] . '","node_end":"' . $id . '","color":"' . getColorLineStatus($layoutData) . '"});
});';
echo '</script>';
}
}
/**
* The function to save the new elements of agents make as wizard.
*
* @param array $id_agents The list of id of agents.
* @param string $image The image to set the elements.
* @param integer $id_layout The id of visual console to insert the elements.
* @param integer $range The distance between elements.
* @param integer $width Width of image.
* @param integer $height Height of image.
*
* @return string Return the message status to insert DB.
*/
function process_wizard_add ($id_agents, $image, $id_layout, $range, $width = 0, $height = 0) {
if (empty ($id_agents)) {
print_error_message (__('No agents selected'));
@ -37,16 +150,16 @@ function process_wizard_add ($id_agents, $image, $id_layout, $range, $width = 0,
}
process_sql_insert ('tlayout_data',
array ('id_layout' => $id_layout,
'pos_x' => $pos_x,
'pos_y' => $pos_y,
'label' => get_agent_name ($id_agent),
'image' => $image,
'id_agent' => $id_agent,
'width' => $width,
'height' => $height,
'label_color' => '#000000')
);
array ('id_layout' => $id_layout,
'pos_x' => $pos_x,
'pos_y' => $pos_y,
'label' => get_agent_name ($id_agent),
'image' => $image,
'id_agent' => $id_agent,
'width' => $width,
'height' => $height,
'label_color' => '#000000')
);
$pos_x = $pos_x + $range;
}
@ -56,9 +169,21 @@ function process_wizard_add ($id_agents, $image, $id_layout, $range, $width = 0,
return $return;
}
/**
* The function to save the new elements of modules make as wizard.
*
* @param array $id_modules The list of id of modules.
* @param string $image The image to set the elements.
* @param integer $id_layout The id of visual console to insert the elements.
* @param integer $range The distance between elements.
* @param integer $width Width of image.
* @param integer $height Height of image.
*
* @return string Return the message status to insert DB.
*/
function process_wizard_add_modules ($id_modules, $image, $id_layout, $range, $width = 0, $height = 0) {
if (empty ($id_modules)) {
print_error_message (__('No modules selected'));
$return = print_error_message (__('No modules selected'), '', true);
return false;
}
@ -77,17 +202,17 @@ function process_wizard_add_modules ($id_modules, $image, $id_layout, $range, $w
$id_agent = get_agentmodule_agent ($id_module);
process_sql_insert ('tlayout_data',
array ('id_layout' => $id_layout,
'pos_x' => $pos_x,
'pos_y' => $pos_y,
'label' => get_agentmodule_name ($id_module),
'image' => $image,
'id_agent' => $id_agent,
'id_agente_modulo' => $id_module,
'width' => $width,
'height' => $height,
'label_color' => '#000000')
);
array ('id_layout' => $id_layout,
'pos_x' => $pos_x,
'pos_y' => $pos_y,
'label' => get_agentmodule_name ($id_module),
'image' => $image,
'id_agent' => $id_agent,
'id_agente_modulo' => $id_module,
'width' => $width,
'height' => $height,
'label_color' => '#000000')
);
$pos_x = $pos_x + $range;
}
@ -97,10 +222,17 @@ function process_wizard_add_modules ($id_modules, $image, $id_layout, $range, $w
return $return;
}
/**
* Get the color of line between elements in the visual map.
*
* @param array $layoutData The row of element in DB.
*
* @return string The color as hexadecimal color in html.
*/
function getColorLineStatus($layoutData) {
switch (getStatusElement($layoutData)) {
case 3:
$color = "#ccc"; // Gray
$color = "#cccccc"; // Gray
break;
case 2:
$color = "#20f6f6"; // Yellow
@ -117,6 +249,13 @@ function getColorLineStatus($layoutData) {
return $color;
}
/**
* Get image of element in the visual console with status.
*
* @param array $layoutData The row of element in DB.
*
* @return string The image with the relative path to pandora console directory.
*/
function getImageStatusElement($layoutData) {
$img = "images/console/icons/" . $layoutData["image"];
switch (getStatusElement($layoutData)) {
@ -141,6 +280,14 @@ function getImageStatusElement($layoutData) {
return $img;
}
/**
* Get the status of element in visual console. Check the agent state or
* module or layout linked.
*
* @param array $layoutData The row of element in DB.
*
* @return integer
*/
function getStatusElement($layoutData) {
//Linked to other layout ?? - Only if not module defined
if ($layoutData['id_layout_linked'] != 0) {

View File

@ -279,7 +279,8 @@ input.sub[disabled] {
}
input.next, input.upd, input.ok, input.wand, input.delete, input.search,
input.copy, input.add {
input.copy, input.add, input.graph, input.percentile, input.binary,
input.camera, input.config {
padding-right: 21px;
}
input.next {
@ -306,6 +307,21 @@ input.ok {
input.add {
background: #e5e5e5 url(../../images/add.png) no-repeat right 3px;
}
input.graph {
background: #e5e5e5 url(../../images/chart_curve.png) no-repeat right 3px;
}
input.percentile {
background: #e5e5e5 url(../../images/chart_bar.png) no-repeat right 3px;
}
input.binary {
background: #e5e5e5 url(../../images/binary.png) no-repeat right 3px;
}
input.camera {
background: #e5e5e5 url(../../images/camera.png) no-repeat right 3px;
}
input.config {
background: #e5e5e5 url(../../images/config.png) no-repeat right 3px;
}
table, img {
border: 0px;
}