Fixed module graph problems in visual console. Ticket#2825

This commit is contained in:
Arturo Gonzalez Diaz 2015-09-30 10:52:12 +02:00
parent 7d6f03c3c8
commit 0dd0ae4b4c
3 changed files with 32 additions and 15 deletions

View File

@ -1221,14 +1221,12 @@ function set_image(type, idElement, image) {
function setModuleGraph(id_data) { function setModuleGraph(id_data) {
var parameter = Array(); var parameter = Array();
parameter.push ({name: "page", parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
value: "include/ajax/visual_console_builder.ajax"});
parameter.push ({name: "action", value: "get_layout_data"}); parameter.push ({name: "action", value: "get_layout_data"});
parameter.push ({name: "id_element", value: id_data}); parameter.push ({name: "id_element", value: id_data});
parameter.push ({name: "id_visual_console", parameter.push ({name: "id_visual_console", value: id_visual_console});
value: id_visual_console});
jQuery.ajax({ jQuery.ajax({
url: get_url_ajax(), url: get_url_ajax(),
data: parameter, data: parameter,
@ -1258,6 +1256,7 @@ function setModuleGraph(id_data) {
if (is_metaconsole()) { if (is_metaconsole()) {
parameter.push ({name: "id_metaconsole", value: id_metaconsole}); parameter.push ({name: "id_metaconsole", value: id_metaconsole});
} }
parameter.push ({name: "type", value: 'module_graph'});
parameter.push ({name: "height", value: height}); parameter.push ({name: "height", value: height});
parameter.push ({name: "width", value: width}); parameter.push ({name: "width", value: width});
parameter.push ({name: "period", value: period}); parameter.push ({name: "period", value: period});
@ -1268,10 +1267,16 @@ function setModuleGraph(id_data) {
url: get_url_ajax(), url: get_url_ajax(),
data: parameter, data: parameter,
type: "POST", type: "POST",
dataType: 'text', //The ajax return the data as text. dataType: 'json', //The ajax return the data as text.
success: function (data) success: function (data)
{ {
$("#image_" + id_data).attr('src', data); console.log(data);
if (data['no_data'] == true) {
$('#' + id_data).html(data['url']);
}
else {
$("#image_" + id_data).attr('src', data['url']);
}
} }
}); });
} }

View File

@ -158,8 +158,8 @@ switch ($action) {
} }
else { else {
$img = grafico_modulo_sparse($id_agent_module, $img = grafico_modulo_sparse($id_agent_module,
$period, false, $width, $height, '', null, false, 1, $period, 0, $width, $height, '', null, false, 1,
false, 0, '', 0, 0, true, true, '', 1, false, '', false, 0, '', 0, 0, true, true, '', 1, false, '',
false, false, true, $background_color); false, false, true, $background_color);
} }
@ -167,11 +167,22 @@ switch ($action) {
if (!empty($id_metaconsole)) { if (!empty($id_metaconsole)) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
$data_image = array();
preg_match("/src=[\'\"](.*)[\'\"]/", $img, $matches); preg_match("/src=[\'\"](.*)[\'\"]/", $img, $matches);
$url = $matches[1]; $url = $matches[1];
echo $url; if (empty($url) && ($type == 'module_graph')) {
$data_image['url'] = $img;
$data_image['no_data'] = true;
$data_image['message'] = __('No data to show');
}
else{
$data_image['url'] = $matches[1];
$data_image['no_data'] = false;
}
echo json_encode($data_image);
break; break;

View File

@ -733,8 +733,9 @@ function visual_map_print_item($mode = "read", $layoutData,
if ($layoutData['id_metaconsole'] != 0) { if ($layoutData['id_metaconsole'] != 0) {
metaconsole_restore_db(); metaconsole_restore_db();
} }
$img = str_replace('>', 'class="image" id="image_' . $id . '" />', $img); //$img = str_replace('>', 'class="image" id="image_' . $id . '" />', $img);
break; break;
case LABEL: case LABEL:
$z_index = 4 + 1; $z_index = 4 + 1;