Merge branch '1416-new-h-and-v-bar-charts-in-visual-console-dev' into 'develop'

1416 new h and v bar charts in visual console dev

See merge request artica/pandorafms!956
This commit is contained in:
vgilc 2017-10-26 13:30:52 +02:00
commit e8a14b6981
16 changed files with 602 additions and 77 deletions

View File

@ -291,7 +291,7 @@ if (modules_is_string_type($id_module_type) || $edit) {
$table_simple->data[4][1] .= '<br /><em>'.__('Inverse interval').'</em>';
$table_simple->data[4][1] .= html_print_checkbox ("warning_inverse", 1, $warning_inverse, true, $disabledBecauseInPolicy);
if (!modules_is_string_type($id_module_type) || $edit) {
$table_simple->data[4][2] = '<svg id="svg_dinamic" width="350" height="200" style="padding:40px; padding-left: 100px; margin-bottom: 60px;"> </svg>';
$table_simple->data[4][2] = '<svg id="svg_dinamic" width="350px" height="200px" style="padding:40px; padding-left: 100px; margin-bottom: 60px;"></svg>';
$table_simple->colspan[4][2] = 2;
$table_simple->rowspan[4][2] = 3;
}
@ -1323,8 +1323,8 @@ function paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, er
.attr("id", "legend_normal")
.attr("x", 72)
.attr("y", -30)
.attr("width", 10)
.attr("height", 10)
.attr("width", '10px')
.attr("height", '10px')
.style("fill", "#82B92E");
//legend Warning text
@ -1343,8 +1343,8 @@ function paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, er
.attr("id", "legend_warning")
.attr("x", 168)
.attr("y", -30)
.attr("width", 10)
.attr("height", 10)
.attr("width", '10px')
.attr("height", '10px')
.style("fill", "#ffd731");
//legend Critical text
@ -1363,8 +1363,8 @@ function paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, er
.attr("id", "legend_critical")
.attr("x", 258)
.attr("y", -30)
.attr("width", 10)
.attr("height", 10)
.attr("width", '10px')
.attr("height", '10px')
.style("fill", "#fc4444");
//styles for number and axes
@ -1382,8 +1382,8 @@ function paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, er
.attr("id", "warning_rect")
.attr("x", 3)
.attr("y", 0)
.attr("width", 300)
.attr("height", 200)
.attr("width", '300px')
.attr("height", '200px')
.style("fill", "#82B92E");
//controls the inverse warning

View File

@ -473,8 +473,8 @@ $next_row++;
.attr("id", "legend_normal")
.attr("x", 72)
.attr("y", -30)
.attr("width", 10)
.attr("height", 10)
.attr("width", '10px')
.attr("height", '10px')
.style("fill", "#82B92E");
//legend Warning text

View File

@ -420,6 +420,17 @@ function update_button_palette_callback() {
$("#image_" + idItem).attr("src", "images/spinner.gif");
setModuleGraph(idItem);
break;
case 'bars_graph':
if($('input[name=width_percentile]').val() == ''){
alert('Undefined width');
return false;
}
$("#text_" + idItem).html(values['label']);
$("#image_" + idItem).attr("src", "images/spinner.gif");
setBarsGraph(idItem, values);
break;
case 'auto_sla_graph':
if($('input[name=width]').val() == ''){
alert('Undefined width');
@ -616,6 +627,7 @@ function readFields() {
}
}
values['height'] = $("input[name=height]").val();
values['bars_graph_type'] = $("select[name=bars_graph_type]").val();
values['parent'] = $("select[name=parent]").val();
values['map_linked'] = $("select[name=map_linked]").val();
values['width_percentile'] = $("input[name=width_percentile]").val();
@ -664,7 +676,7 @@ function readFields() {
function create_button_palette_callback() {
var values = readFields();
console.log(values);
//VALIDATE DATA
var validate = true;
switch (creationItem) {
@ -766,6 +778,16 @@ function create_button_palette_callback() {
}
}
break;
case 'bars_graph':
if ((values['agent'] == '')) {
alert($("#message_alert_no_agent").html());
validate = false;
}
if ((values['module'] == 0)) {
alert($("#message_alert_no_module").html());
validate = false;
}
break;
case 'simple_value':
if ((values['agent'] == '')) {
alert($("#message_alert_no_agent").html());
@ -967,6 +989,7 @@ function toggle_item_palette() {
activeToolboxButton('static_graph', true);
activeToolboxButton('module_graph', true);
activeToolboxButton('bars_graph', true);
activeToolboxButton('simple_value', true);
activeToolboxButton('label', true);
activeToolboxButton('icon', true);
@ -994,6 +1017,7 @@ function toggle_item_palette() {
activeToolboxButton('static_graph', false);
activeToolboxButton('module_graph', false);
activeToolboxButton('bars_graph', false);
activeToolboxButton('auto_sla_graph', false);
activeToolboxButton('simple_value', false);
activeToolboxButton('label', false);
@ -1267,6 +1291,8 @@ function loadFieldsFromDB(item) {
$("input[name=width_module_graph]").val(val);
if (key == 'height_module_graph')
$("input[name=height_module_graph]").val(val);
if (key == 'bars_graph_type')
$("select[name=bars_graph_type]").val(val);
if (key == 'type_percentile') {
if (val == 'percentile') {
@ -1527,6 +1553,9 @@ function hiddenFields(item) {
$("#module_graph_size_row").css('display', 'none');
$("#module_graph_size_row." + item).css('display', '');
$("#bars_graph_type").css('display', 'none');
$("#bars_graph_type." + item).css('display', '');
$("#background_color").css('display', 'none');
$("#background_color." + item).css('display', '');
@ -1743,6 +1772,60 @@ function set_image(type, idElement, image) {
});
}
function setBarsGraph(id_data, values) {
var url_hack_metaconsole = '';
if (is_metaconsole()) {
url_hack_metaconsole = '../../';
}
width_percentile = values['width_percentile'];
parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
parameter.push ({name: "action", value: "get_module_type_string"});
parameter.push ({name: "id_agent", value: values['id_agent']});
parameter.push ({name: "module", value: values['module']});
parameter.push ({name: "id_element", value: id_data});
parameter.push ({name: "id_visual_console", value: id_visual_console});
jQuery.ajax({
url: get_url_ajax(),
data: parameter,
type: "POST",
dataType: 'json',
success: function (data) {
if (data['no_data'] == true) {
if (values['width_percentile'] == "0") {
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/barras-no.png');
}
else {
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/barras-no.png');
$("#" + id_data + " img").css('width', width_percentile + 'px');
$("#" + id_data + " img").css('height', width_percentile + 'px');
}
}
else {
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/barras.png');
if (values['width_percentile'] == "0") {
// Image size
}
else{
$("#" + id_data + " img").css('width', width_percentile+'px');
$("#" + id_data + " img").css('height', width_percentile+'px');
}
}
if($('#'+id_data+' table').css('float') == 'right' || $('#'+id_data+ ' table').css('float') == 'left'){
$('#'+id_data+ ' img').css('margin-top', parseInt($('#'+id_data).css('height'))/2 - parseInt($('#'+id_data+ ' img').css('height'))/2);
}
else{
$('#'+id_data+ ' img').css('margin-left', parseInt($('#'+id_data).css('width'))/2 - parseInt($('#'+id_data+ ' img').css('width'))/2);
}
}
});
}
function setModuleGraph(id_data) {
var parameter = Array();
@ -2233,34 +2316,23 @@ function createItem(type, values, id_data) {
}
if(values['show_statistics'] != 1){
if ((values['width'] == 0) || (values['height'] == 0)) {
// Do none
if($('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
$image.attr('width', '70')
.attr('height', '70');
}
else{
$image.attr('width', $('#preview > img')[0].naturalWidth)
.attr('height', $('#preview > img')[0].naturalHeight);
}
}
else {
$image.attr('width', values['width'])
.attr('height', values['height']);
if ((values['width'] == 0) || (values['height'] == 0)) {
// Do none
if($('#preview > img')[0].naturalWidth > 150 || $('#preview > img')[0].naturalHeight > 150){
$image.attr('width', '70')
.attr('height', '70');
}
else{
$image.attr('width', $('#preview > img')[0].naturalWidth)
.attr('height', $('#preview > img')[0].naturalHeight);
}
}
// else{
// $('#image_'+id_data).css('width', values['width']+'px');
// $('#image_'+id_data).css('height', values['height']+'px');
// }
/*
var $span = $('<span></span>')
.attr('id', 'text_' + id_data)
.attr('class', 'text')
.append(values['label']);
*/
else {
$image.attr('width', values['width'])
.attr('height', values['height']);
}
}
var $input = $('<input></input>')
.attr('id', 'hidden-status_' + id_data)
.attr('type', 'hidden')
@ -2461,6 +2533,42 @@ function createItem(type, values, id_data) {
setModuleGraph(id_data);
break;
case 'bars_graph':
sizeStyle = '';
imageSize = '';
if(values['label_position'] == 'up'){
item = $('<div id="' + id_data + '" class="item module_graph" style="text-align: left; position: absolute; ' + sizeStyle + ' top: ' + values['top'] + 'px; left: ' + values['left'] + 'px;">' +
'<table><tr><td></td></tr><tr><td><span id="text_' + id_data + '" class="text">' + values['label'] + '</span></td></tr><tr><td></td></tr></table>' +
'<img class="image" id="image_' + id_data + '" src="images/spinner.gif" />' +
'</div>'
);
}
else if(values['label_position'] == 'down'){
item = $('<div id="' + id_data + '" class="item module_graph" style="text-align: left; position: absolute; ' + sizeStyle + ' top: ' + values['top'] + 'px; left: ' + values['left'] + 'px;">' +
'<img class="image" id="image_' + id_data + '" src="images/spinner.gif" />' +
'<table><tr><td></td></tr><tr><td><span id="text_' + id_data + '" class="text">' + values['label'] + '</span></td></tr><tr><td></td></tr></table>' +
'</div>'
);
}
else if(values['label_position'] == 'left'){
item = $('<div id="' + id_data + '" class="item module_graph" style="text-align: left; position: absolute; ' + sizeStyle + ' top: ' + values['top'] + 'px; left: ' + values['left'] + 'px;">' +
'<img style="float:right" class="image" id="image_' + id_data + '" src="images/spinner.gif" />' +
'<table style="float:left;height:'+values['height_module_graph']+'px;"><tr><td></td></tr><tr><td><span id="text_' + id_data + '" class="text">' + values['label'] + '</span></td></tr><tr><td></td></tr></table>' +
'</div>'
);
}
else if(values['label_position'] == 'right'){
item = $('<div id="' + id_data + '" class="item module_graph" style="text-align: left; position: absolute; ' + sizeStyle + ' top: ' + values['top'] + 'px; left: ' + values['left'] + 'px;">' +
'<img style="float:left" class="image" id="image_' + id_data + '" src="images/spinner.gif" />' +
'<table style="float:right;height:'+values['height_module_graph']+'px;"><tr><td></td></tr><tr><td><span id="text_' + id_data + '" class="text">' + values['label'] + '</span></td></tr><tr><td></td></tr></table>' +
'</div>'
);
}
setBarsGraph(id_data, values);
break;
case 'simple_value':
sizeStyle = '';
imageSize = '';
@ -2680,6 +2788,7 @@ function updateDB_visual(type, idElement , values, event, top, left) {
case 'label':
case 'icon':
case 'module_graph':
case 'bars_graph':
case 'auto_sla_graph':
if (type == 'simple_value') {
setModuleValue(idElement,
@ -3119,6 +3228,15 @@ function eventsItems(drag) {
activeToolboxButton('delete_item', true);
activeToolboxButton('show_grid', false);
}
if ($(divParent).hasClass('bars_graph')) {
creationItem = null;
selectedItem = 'bars_graph';
idItem = $(divParent).attr('id');
activeToolboxButton('copy_item', true);
activeToolboxButton('edit_item', true);
activeToolboxButton('delete_item', true);
activeToolboxButton('show_grid', false);
}
if ($(divParent).hasClass('simple_value')) {
creationItem = null;
selectedItem = 'simple_value';
@ -3301,6 +3419,9 @@ function eventsItems(drag) {
if ($(event.target).hasClass('module_graph')) {
selectedItem = 'module_graph';
}
if ($(event.target).hasClass('bars_graph')) {
selectedItem = 'bars_graph';
}
if ($(event.target).hasClass('simple_value')) {
selectedItem = 'simple_value';
}
@ -3604,6 +3725,10 @@ function click_button_toolbox(id) {
toolbuttonActive = creationItem = 'module_graph';
toggle_item_palette();
break;
case 'bars_graph':
toolbuttonActive = creationItem = 'bars_graph';
toggle_item_palette();
break;
case 'auto_sla_graph':
toolbuttonActive = creationItem = 'auto_sla_graph';
toggle_item_palette();
@ -3659,6 +3784,7 @@ function click_button_toolbox(id) {
activeToolboxButton('static_graph', false);
activeToolboxButton('percentile_item', false);
activeToolboxButton('module_graph', false);
activeToolboxButton('bars_graph', false);
activeToolboxButton('simple_value', false);
activeToolboxButton('label', false);
activeToolboxButton('icon', false);
@ -3690,6 +3816,7 @@ function click_button_toolbox(id) {
activeToolboxButton('static_graph', true);
activeToolboxButton('percentile_item', true);
activeToolboxButton('module_graph', true);
activeToolboxButton('bars_graph', true);
activeToolboxButton('simple_value', true);
activeToolboxButton('label', true);
activeToolboxButton('icon', true);

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

View File

@ -104,6 +104,7 @@ $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);
$bars_graph_type = get_parameter('bars_graph_type', null);
$id_agent_module = get_parameter('id_agent_module', 0);
$process_simple_value = get_parameter('process_simple_value', PROCESS_VALUE_NONE);
$type_percentile = get_parameter('type_percentile', 'percentile');
@ -140,6 +141,39 @@ switch ($action) {
$return['font'] = $config['fontpath'];
echo json_encode($return);
break;
case 'get_module_type_string':
$data = array ();
$layoutData = db_get_row_filter('tlayout_data', array('id' => $id_element));
if ($layoutData['id_metaconsole'] != 0) {
$connection = db_get_row_filter ('tmetaconsole_setup', $layoutData['id_metaconsole']);
if (metaconsole_load_external_db($connection) != NOERR) {
continue;
}
}
$is_string = db_get_value_filter ('id_tipo_modulo', 'tagente_modulo',
array ('id_agente' => $id_agent,
'id_agente_modulo' => $id_module));
if ($layoutData['id_metaconsole'] != 0) {
metaconsole_restore_db();
}
$return = array();
if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) ||
($is_string == 10) || ($is_string == 33)) {
$return['no_data'] = false;
}
else {
$return['no_data'] = true;
}
echo json_encode($return);
break;
case 'get_module_events':
$data = array ();
@ -465,6 +499,7 @@ switch ($action) {
case 'label':
case 'icon':
case 'auto_sla_graph':
case 'bars_graph':
default:
if ($type == 'label') {
$values['type'] = LABEL;
@ -588,6 +623,17 @@ switch ($action) {
$values['id_custom_graph'] = $id_custom_graph;
}
break;
case 'bars_graph':
if ($width_percentile !== null) {
$values['width'] = $width_percentile;
}
if ($bars_graph_type !== null) {
$values['type_graph'] = $bars_graph_type;
}
if ($background_color !== null) {
$values['image'] = $background_color;
}
break;
case 'percentile_item':
case 'percentile_bar':
if ($action == 'update') {
@ -650,6 +696,10 @@ switch ($action) {
unset($values['image']);
unset($values['type_graph']);
break;
case 'bars_graph':
unset($values['image']);
unset($values['type_graph']);
break;
case 'box_item':
unset($values['border_width']);
unset($values['border_color']);
@ -707,6 +757,7 @@ switch ($action) {
case 'static_graph':
case 'group_item':
case 'module_graph':
case 'bars_graph':
case 'simple_value':
case 'label':
case 'icon':
@ -787,6 +838,10 @@ switch ($action) {
$elementFields['width_module_graph'] = $elementFields['width'];
$elementFields['height_module_graph'] = $elementFields['height'];
break;
case 'bars_graph':
$elementFields['width_percentile'] = $elementFields['width'];
$elementFields['bars_graph_type'] = $elementFields['type_graph'];
break;
case 'box_item':
$elementFields['width_box'] = $elementFields['width'];
$elementFields['height_box'] = $elementFields['height'];
@ -923,6 +978,17 @@ switch ($action) {
}
$values['period'] = $period;
break;
case 'bars_graph':
$values['type'] = BARS_GRAPH;
if ($width_percentile == null) {
$values['width'] = 0;
}
else {
$values['width'] = $width_percentile;
}
$values['type_graph'] = $bars_graph_type;
$values['image'] = $background_color;
break;
case 'auto_sla_graph':
$values['type'] = AUTO_SLA_GRAPH;
$values['period'] = $event_max_time_row;

View File

@ -197,6 +197,7 @@ define('SERVICE', 10); //Enterprise Item.
define('GROUP_ITEM', 11);
define('BOX_ITEM', 12);
define('LINE_ITEM', 13);
define('BARS_GRAPH', 18);
//Some styles
define('MIN_WIDTH', 300);
define('MIN_HEIGHT', 120);

View File

@ -375,6 +375,9 @@ function visual_map_print_item($mode = "read", $layoutData,
$link = true;
}
break;
case BARS_GRAPH:
$link = true;
break;
case AUTO_SLA_GRAPH:
$link = true;
@ -487,6 +490,17 @@ function visual_map_print_item($mode = "read", $layoutData,
"&date_to=" . $date_to . "&time_to=" . $time_to . "&status=-1";
}
break;
case BARS_GRAPH:
if (empty($layout_data['id_metaconsole'])) {
$url = $config['homeurl'] . "index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=" . $layoutData['id_agent'] .
"&tab=module&edit_module=1&id_agent_module=" . $layoutData['id_agente_modulo'];
}
else {
$url = "index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=" . $layoutData['id_agent'] .
"&tab=module&edit_module=1&id_agent_module=" . $layoutData['id_agente_modulo'];
}
break;
case GROUP_ITEM:
$is_a_link_to_other_visualconsole = false;
if ($layoutData['id_layout_linked'] != 0) {
@ -1071,6 +1085,274 @@ function visual_map_print_item($mode = "read", $layoutData,
}
break;
case BARS_GRAPH:
$imgpos = '';
if($layoutData['label_position']=='left'){
$imgpos = 'float:right';
}
else if($layoutData['label_position']=='right'){
$imgpos = 'float:left';
}
if (!empty($proportion)) {
$width =
((integer)($proportion['proportion_width'] * $width));
$height =
((integer)($proportion['proportion_height'] * $height));
}
//Metaconsole db connection
if ($layoutData['id_metaconsole'] != 0) {
$connection = db_get_row_filter ('tmetaconsole_setup',
array('id' => $layoutData['id_metaconsole']));
if (metaconsole_load_external_db($connection) != NOERR) {
continue;
}
}
if ($isExternalLink)
$homeurl = $config['homeurl'];
else
$homeurl = '';
$is_string = db_get_value_filter ('id_tipo_modulo', 'tagente_modulo',
array ('id_agente' => $layoutData['id_agent'],
'id_agente_modulo' => $id_module));
if ( (get_parameter('action') == 'edit') || (get_parameter('operation') == 'edit_visualmap') ) {
if($width == 0){
if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) ||
($is_string == 10) || ($is_string == 33)) {
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/barras.png" style="width:400px;height:400px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/barras.png" style="width:400px;height:400px;'.$imgpos.'">';
}
}
else {
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/barras-no.png" style="width:400px;height:400px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/barras-no.png" style="width:400px;height:400px;'.$imgpos.'">';
}
}
}
else{
if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) ||
($is_string == 10) || ($is_string == 33)) {
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/barras.png" style="width:'.$width.'px;height:'.$width.'px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/barras.png" style="width:'.$width.'px;height:'.$width.'px;'.$imgpos.'">';
}
}
else {
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/barras-no.png" style="width:'.$width.'px;height:'.$width.'px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/barras-no.png" style="width:'.$width.'px;height:'.$width.'px;'.$imgpos.'">';
}
}
}
}
else {
if (($is_string == 17) || ($is_string == 23) || ($is_string == 3) ||
($is_string == 10) || ($is_string == 33)) {
$color = array();
$color[0] = array('border' => '#000000',
'color' => $config['graph_color1'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[1] = array('border' => '#000000',
'color' => $config['graph_color2'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[2] = array('border' => '#000000',
'color' => $config['graph_color3'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[3] = array('border' => '#000000',
'color' => $config['graph_color4'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[4] = array('border' => '#000000',
'color' => $config['graph_color5'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[5] = array('border' => '#000000',
'color' => $config['graph_color6'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[6] = array('border' => '#000000',
'color' => $config['graph_color7'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[7] = array('border' => '#000000',
'color' => $config['graph_color8'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[8] = array('border' => '#000000',
'color' => $config['graph_color9'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[9] = array('border' => '#000000',
'color' => $config['graph_color10'],
'alpha' => CHART_DEFAULT_ALPHA);
$color[11] = array('border' => '#000000',
'color' => COL_GRAPH9,
'alpha' => CHART_DEFAULT_ALPHA);
$color[12] = array('border' => '#000000',
'color' => COL_GRAPH10,
'alpha' => CHART_DEFAULT_ALPHA);
$color[13] = array('border' => '#000000',
'color' => COL_GRAPH11,
'alpha' => CHART_DEFAULT_ALPHA);
$color[14] = array('border' => '#000000',
'color' => COL_GRAPH12,
'alpha' => CHART_DEFAULT_ALPHA);
$color[15] = array('border' => '#000000',
'color' => COL_GRAPH13,
'alpha' => CHART_DEFAULT_ALPHA);
$module_data = get_bars_module_data($id_module);
$water_mark = array('file' => '/var/www/html/pandora_console/images/logo_vertical_water.png',
'url' => 'http://localhost/pandora_console/images/logo_vertical_water.png');
if ($width == 0) {
if ($layoutData['label_position']=='left') {
if ($layoutData['type_graph'] == 'horizontal') {
$img = '<div style="float:right;height:'.$himg.'px;">'.
hbar_graph(true, $module_data,
400, 400, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image']) . '</div>';
}
else {
$img = '<div style="float:right;height:'.$himg.'px;">'.
vbar_graph(true, $module_data,
400, 400, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image'], true) . '</div>';
}
}
elseif($layoutData['label_position']=='right') {
if ($layoutData['type_graph'] == 'horizontal') {
$img = '<div style="float:left;height:'.$himg.'px;">'.
hbar_graph(true, $module_data,
400, 400, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image']) . '</div>';
}
else {
$img = '<div style="float:left;height:'.$himg.'px;">'.
vbar_graph(true, $module_data,
400, 400, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image'], true) . '</div>';
}
}
else {
if ($layoutData['type_graph'] == 'horizontal') {
$img = hbar_graph(true, $module_data,
400, 400, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image']);
}
else {
$img = vbar_graph(true, $module_data,
400, 400, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image'], true);
}
}
}
else{
if ($layoutData['label_position']=='left') {
if ($layoutData['type_graph'] == 'horizontal') {
$img = '<div style="float:right;height:'.$himg.'px;">'.
hbar_graph(true, $module_data,
$width, $width, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image']) . '</div>';
}
else {
$img = '<div style="float:right;height:'.$himg.'px;">'.
vbar_graph(true, $module_data,
$width, $width, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image'], true) . '</div>';
}
}
elseif($layoutData['label_position']=='right') {
if ($layoutData['type_graph'] == 'horizontal') {
$img = '<div style="float:left;height:'.$himg.'px;">'.
hbar_graph(true, $module_data,
$width, $width, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image']) . '</div>';
}
else {
$img = '<div style="float:left;height:'.$himg.'px;">'.
vbar_graph(true, $module_data,
$width, $width, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image'], true) . '</div>';
}
}
else {
if ($layoutData['type_graph'] == 'horizontal') {
$img = hbar_graph(true, $module_data,
$width, $width, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image']);
}
else {
$img = vbar_graph(true, $module_data,
$width, $width, $color, array(), array(),
ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $water_mark, $config['fontpath'], 6,
"", 0, $config['homeurl'], $layoutData['image'], true);
}
}
}
}
else {
if($width == 0){
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/barras-no.png" style="width:400px;height:400px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/barras-no.png" style="width:400px;height:400px;'.$imgpos.'">';
}
}
else{
if ($layoutData['id_metaconsole'] != 0) {
$img = '<img src="../../images/console/signes/barras-no.png" style="width:'.$width.'px;height:'.$width.'px;'.$imgpos.'">';
}
else{
$img = '<img src="images/console/signes/barras-no.png" style="width:'.$width.'px;height:'.$width.'px;'.$imgpos.'">';
}
}
}
}
//Restore db connection
if ($layoutData['id_metaconsole'] != 0) {
metaconsole_restore_db();
}
break;
case LABEL:
$z_index = 4 + 1;
break;
@ -1148,6 +1430,9 @@ function visual_map_print_item($mode = "read", $layoutData,
case MODULE_GRAPH:
$class .= "module_graph";
break;
case BARS_GRAPH:
$class .= "bars_graph";
break;
case SIMPLE_VALUE:
case SIMPLE_VALUE_MAX:
case SIMPLE_VALUE_MIN:
@ -1568,6 +1853,20 @@ function visual_map_print_item($mode = "read", $layoutData,
echo $img;
if ($layoutData['label_position']=='down') {
echo io_safe_output($text);
}
elseif($layoutData['label_position']=='left' || $layoutData['label_position']=='right') {
echo io_safe_output($text);
}
break;
case BARS_GRAPH:
if ($layoutData['label_position']=='up') {
echo io_safe_output($text);
}
echo $img;
if ($layoutData['label_position']=='down') {
echo io_safe_output($text);
}
@ -1740,6 +2039,29 @@ function visual_map_print_item($mode = "read", $layoutData,
}
}
function get_bars_module_data ($id_module) {
$mod_values = db_get_value_filter('datos', 'tagente_estado', array('id_agente_modulo' => $id_module));
if (preg_match("/\r\n/", $mod_values)) {
$values = explode("\r\n", $mod_values);
}
elseif (preg_match("/\n/", $mod_values)) {
$values = explode("\n", $mod_values);
}
$values_to_return = array();
$index = 0;
$color_index = 0;
$total = 0;
foreach ($values as $val) {
$data = explode(":", $val);
$values_to_return[$data[0]] = array('g' =>$data[1]);
}
return $values_to_return;
}
/**
* The function to get simple value type from the value of process type in the form
*
@ -2981,6 +3303,10 @@ function visual_map_create_internal_name_item($label = null, $type, $image, $age
case MODULE_GRAPH:
$text = __('Module graph');
break;
case 'bars_graph':
case BARS_GRAPH:
$text = __('Bars graph');
break;
case 'auto_sla_graph':
case AUTO_SLA_GRAPH:
$text = __('Auto SLA Graph');
@ -3096,6 +3422,9 @@ function visual_map_type_in_js($type) {
case MODULE_GRAPH:
return 'module_graph';
break;
case BARS_GRAPH:
return 'bars_graph';
break;
case AUTO_SLA_GRAPH:
return 'auto_sla_graph';
break;

View File

@ -163,7 +163,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
'simple_value',
'datos',
'group_item',
'auto_sla_graph');
'auto_sla_graph',
'bars_graph');
$form_items['label_row']['html'] =
'<td align="left" valign="top" style="">' . __('Label') . '
@ -214,7 +215,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
'module_graph',
'simple_value',
'datos',
'icon');
'icon',
'bars_graph');
if (!is_metaconsole())
$form_items['enable_link_row']['items'][] = 'group_item';
@ -237,7 +239,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$form_items['background_color'] = array();
$form_items['background_color']['items'] = array(
'module_graph',
'datos');
'datos',
'bars_graph');
$form_items['background_color']['html'] = '<td align="left"><span>' .
__('Background color') . '</span></td>
<td align="left">'. html_print_select (
@ -277,7 +280,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$form_items['agent_row'] = array();
$form_items['agent_row']['items'] = array('static_graph',
'percentile_bar', 'percentile_item', 'module_graph',
'simple_value', 'datos', 'auto_sla_graph');
'simple_value', 'datos', 'auto_sla_graph', 'bars_graph');
$form_items['agent_row']['html'] = '<td align="left">' .
__('Agent') . '</td>';
$params = array();
@ -310,7 +313,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$form_items['module_row'] = array();
$form_items['module_row']['items'] = array('static_graph',
'percentile_bar', 'percentile_item', 'module_graph',
'simple_value', 'datos', 'auto_sla_graph');
'simple_value', 'datos', 'auto_sla_graph', 'bars_graph');
$form_items['module_row']['html'] = '<td align="left">' .
__('Module') . '</td>
<td align="left">' .
@ -396,7 +399,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$form_items['percentile_bar_row_1'] = array();
$form_items['percentile_bar_row_1']['items'] = array('percentile_bar', 'percentile_item', 'datos');
$form_items['percentile_bar_row_1']['items'] = array('percentile_bar', 'percentile_item', 'datos', 'bars_graph');
$form_items['percentile_bar_row_1']['html'] = '<td align="left">' .
__('Width') . '</td>
<td align="left">' . html_print_input_text('width_percentile', 0, '', 3, 5, true) . '</td>';
@ -472,6 +475,13 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
'<span id="count_items">1</span> '.
'<span id="dir_items"></span> item/s
</td>';
$bars_graph_types = array('vertical' => __('Vertical'), 'horizontal' => __('Horizontal'));
$form_items['bars_graph_type'] = array();
$form_items['bars_graph_type']['items'] = array('bars_graph');
$form_items['bars_graph_type']['html'] = '<td align="left">' .
__('Type') . '</td>
<td align="left">' . html_print_select($bars_graph_types, 'bars_graph_type', 'vertical', '', '', '', true) . '</td>';
//Insert and modify before the buttons to create or update.
@ -518,7 +528,7 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$form_items_advance['position_row']['items'] = array('static_graph',
'percentile_bar', 'percentile_item', 'module_graph',
'simple_value', 'label', 'icon', 'datos', 'box_item',
'auto_sla_graph');
'auto_sla_graph', 'bars_graph');
$form_items_advance['position_row']['html'] = '
<td align="left">' . __('Position') . '</td>
<td align="left">(' . html_print_input_text('left', '0', '', 3, 5, true) .
@ -547,7 +557,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$form_items_advance['parent_row']['items'] = array(
'group_item', 'static_graph',
'percentile_bar', 'percentile_item', 'module_graph',
'simple_value', 'label', 'icon', 'datos', 'auto_sla_graph');
'simple_value', 'label', 'icon', 'datos', 'auto_sla_graph',
'bars_graph');
$form_items_advance['parent_row']['html'] = '<td align="left">' .
__('Parent') . '</td>
<td align="left">' .
@ -571,7 +582,6 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$form_items_advance['line_case']['html'] = '
<td align="left">' . __('Lines haven\'t advanced options') . '</td>';
//Insert and modify before the buttons to create or update.
if (enterprise_installed()) {
enterprise_visual_map_editor_modify_form_items_advance_palette($form_items_advance);
@ -673,6 +683,7 @@ function visual_map_editor_print_toolbox() {
visual_map_print_button_editor('static_graph', __('Static Graph'), 'left', false, 'camera_min', true);
visual_map_print_button_editor('percentile_item', __('Percentile Item'), 'left', false, 'percentile_item_min', true);
visual_map_print_button_editor('module_graph', __('Module Graph'), 'left', false, 'graph_min', true);
visual_map_print_button_editor('bars_graph', __('Bars Graph'), 'left', false, 'bars_graph_min', true);
visual_map_print_button_editor('auto_sla_graph', __('Auto SLA Graph'), 'left', false, 'auto_sla_graph_min', true);
visual_map_print_button_editor('simple_value', __('Simple Value'), 'left', false, 'binary_min', true);
visual_map_print_button_editor('label', __('Label'), 'left', false, 'label_min', true);

View File

@ -188,7 +188,7 @@ function vbar_graph($flash_chart, $chart_data, $width, $height,
if ($flash_chart) {
return flot_vcolumn_chart ($chart_data, $width, $height, $color,
$legend, $long_index, $homeurl, $unit, $water_mark_url,
$homedir,$font,$font_size, $from_ux, $from_wux);
$homedir,$font,$font_size, $from_ux, $from_wux, $backgroundColor);
}
else {
foreach ($chart_data as $key => $value) {
@ -652,7 +652,7 @@ function hbar_graph($flash_chart, $chart_data, $width, $height,
if ($flash_chart) {
return flot_hcolumn_chart(
$chart_data, $width, $height, $water_mark_url, $font, $font_size);
$chart_data, $width, $height, $water_mark_url, $font, $font_size, $backgroundColor);
}
else {

View File

@ -309,7 +309,7 @@ function pandoraFlotPieCustom(graph_id, values, labels, width,
}
function pandoraFlotHBars(graph_id, values, labels, water_mark,
maxvalue, water_mark, separator, separator2, font, font_size) {
maxvalue, water_mark, separator, separator2, font, font_size, background_color) {
var colors_data = ['#FC4444','#FFA631','#FAD403','#5BB6E5','#F2919D','#80BA27'];
values = values.split(separator2);
@ -355,7 +355,7 @@ function pandoraFlotHBars(graph_id, values, labels, water_mark,
grid: {
hoverable: true,
borderWidth: 1,
backgroundColor: { colors: ["#FFF", "#FFF"] }
backgroundColor: { colors: [background_color, background_color] }
},
xaxis: {
axisLabelUseCanvas: true,
@ -494,7 +494,7 @@ function showTooltip(x, y, color, contents) {
}).appendTo("body").fadeIn(200);
}
function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, water_mark, maxvalue, water_mark, separator, separator2, font, font_size , from_ux, from_wux) {
function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors, water_mark, maxvalue, water_mark, separator, separator2, font, font_size , from_ux, from_wux, background_color) {
values = values.split(separator2);
legend = legend.split(separator);
font = font.split("/").pop().split(".").shift();
@ -585,7 +585,7 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors,
grid: {
hoverable: true,
borderWidth: 1,
backgroundColor: { colors: ["#FFF", "#FFF"] }
backgroundColor: { colors: [background_color, background_color] }
}
};
@ -608,16 +608,7 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors,
$('#' + graph_id).VUseTooltip();
$('#' + graph_id).css("margin-left","auto");
$('#' + graph_id).css("margin-right","auto");
//~ $('#' + graph_id).find('div.legend-tooltip').tooltip({ track: true });
/*
$('#'+graph_id+' .xAxis .tickLabel')
.css('transform', 'rotate(-45deg)')
.css('max-width','100px')
.find('div')
.css('position', 'relative')
.css('top', '+10px')
.css('left', '-30px');
*/
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent))
$('#'+graph_id+' .xAxis .tickLabel')
.find('div')
@ -638,7 +629,7 @@ function pandoraFlotVBars(graph_id, values, labels, labels_long, legend, colors,
}
format.push([i,
'<div class="'+font+'" title="'+title+'" style="word-break: normal; transform: rotate(-45deg); position:relative; top:+30px; left:-20px; max-width: 100px;font-size:'+font_size+'pt !important;">'
'<div class="'+font+'" title="'+title+'" style="word-break: normal; transform: rotate(-45deg); position:relative; top:+30px; left:0px; max-width: 100px;font-size:'+font_size+'pt !important;">'
+ label
+ '</div>']);
}

View File

@ -674,7 +674,7 @@ function flot_custom_pie_chart ($flash_charts, $graph_values,
}
// Returns a 3D column chart
function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font = '', $font_size = 7) {
function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font = '', $font_size = 7, $background_color = "white") {
global $config;
include_javascript_dependencies_flot_graph();
@ -755,7 +755,7 @@ function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font =
$return .= "<script type='text/javascript'>";
$return .= "pandoraFlotHBars('$graph_id', '$values', '$labels',
false, $max, '$water_mark', '$separator', '$separator2', '$font', $font_size)";
false, $max, '$water_mark', '$separator', '$separator2', '$font', $font_size, '$background_color')";
$return .= "</script>";
@ -763,7 +763,7 @@ function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font =
}
// Returns a 3D column chart
function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark, $homedir, $font, $font_size, $from_ux, $from_wux) {
function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark, $homedir, $font, $font_size, $from_ux, $from_wux, $background_color = 'white') {
global $config;
include_javascript_dependencies_flot_graph();
@ -847,14 +847,14 @@ function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $lon
if ($from_ux) {
if($from_wux){
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, true)";
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, true, '$background_color')";
}
else{
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, false)";
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, true, false, '$background_color')";
}
}
else {
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, false, false)";
$return .= "pandoraFlotVBars('$graph_id', '$values', '$labels', '$labels', '$legend', '$colors', false, $max, '$water_mark', '$separator', '$separator2','$font',$font_size, false, false, '$background_color')";
}
$return .= "</script>";

View File

@ -754,13 +754,7 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
$myPicture->setGraphArea($margin_left, $margin_top, $width - $margin_right, $height - $margin_bottom);
$myPicture->drawScale($scaleSettings);
/*
if (isset($legend)) {
/* Write the chart legend
$size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
$myPicture->drawLegend($width-$size['Width'],0,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL, "BoxWidth"=>10, "BoxHeight"=>10));
}
*/
/* Turn on shadow computing */
$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));

View File

@ -769,6 +769,12 @@ input.graph_min {
input.graph_min[disabled] {
background: #fefefe url(../../images/chart_curve.disabled.png) no-repeat center !important;
}
input.bars_graph_min {
background: #fefefe url(../../images/icono-barras-arriba.png) no-repeat center !important;
}
input.bars_graph_min[disabled] {
background: #fefefe url(../../images/icono-barras-arriba.disabled.png) no-repeat center !important;
}
input.percentile_min {
background: #fefefe url(../../images/chart_bar.png) no-repeat center !important;
}