Added js image

This commit is contained in:
Arturo Gonzalez 2017-07-13 12:26:13 +02:00
parent 63d07e1416
commit 19caa3ebfb
3 changed files with 64 additions and 58 deletions

View File

@ -1795,14 +1795,46 @@ function setPercentileBar(id_data, values) {
} }
function setEventsBar(id_data, values) { function setEventsBar(id_data, values) {
metaconsole = $("input[name='metaconsole']").val();
var url_hack_metaconsole = ''; var url_hack_metaconsole = '';
if (is_metaconsole()) { if (is_metaconsole()) {
url_hack_metaconsole = '../../'; url_hack_metaconsole = '../../';
} }
$("#image_" + id_data).attr('src', data); parameter = Array();
parameter.push ({name: "page", value: "include/ajax/visual_console_builder.ajax"});
parameter.push ({name: "action", value: "get_module_events"});
parameter.push ({name: "id_agent", value: values['id_agent']});
parameter.push ({name: "id_agent_module", value: values['module']});
if (is_metaconsole()) {
parameter.push ({name: "id_metaconsole", value: id_metaconsole});
}
parameter.push ({name: "period", value: values['event_max_time_row']});
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) {
console.log(data);
if (data['no_data'] == true) {
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/module_graph.png');
}
else {
$("#" + id_data + " img").attr('src', url_hack_metaconsole + 'images/console/signes/module_graph.png');
if($('#text-width').val() == 0 || $('#text-height').val() == 0){
$("#" + id_data + " img").css('width', '300px');
$("#" + id_data + " img").css('height', '180px');
}
else{
$("#" + id_data + " img").css('width', $('#text-width').val()+'px');
$("#" + id_data + " img").css('height', $('#text-height').val()+'px');
}
}
}
});
} }
function setPercentileBubble(id_data, values) { function setPercentileBubble(id_data, values) {

View File

@ -143,66 +143,36 @@ switch ($action) {
case 'get_module_events': case 'get_module_events':
$data = array (); $data = array ();
$resolution = $config['graph_res'] * ($event_max_time_row * 2 / 450); // Number of "slices" we want in graph
$interval = (int) ($event_max_time_row / $resolution);
$date = get_system_time (); $date = get_system_time ();
$datelimit = $date - $event_max_time_row; $datelimit = $date - $event_max_time_row;
$periodtime = floor ($event_max_time_row / $interval);
$time = array ();
$data = array ();
$legend = array();
$full_legend = array();
$cont = 0; $events = db_get_row_filter ('tevento',
for ($i = 0; $i < $interval; $i++) {
$bottom = $datelimit + ($periodtime * $i);
$name = date('H:i', $bottom);
// Show less values in legend
if ($cont == 0 or $cont % 2)
$legend[$cont] = $name;
$full_legend[$cont] = $name;
$top = $datelimit + ($periodtime * ($i + 1));
$event = db_get_row_filter ('tevento',
array ('id_agente' => $id_agent, array ('id_agente' => $id_agent,
'id_agentmodule' => $id_module, 'id_agentmodule' => $id_module,
'utimestamp > '.$bottom, 'utimestamp > ' . $datelimit,
'utimestamp < '.$top), 'criticity, utimestamp'); 'utimestamp < ' . $date), 'criticity, utimestamp');
html_debug($events, true);
if (!empty($event['utimestamp'])) { $return = array();
$data[$cont]['utimestamp'] = $periodtime; if (!$events) {
switch ($event['criticity']) { $return['no_data'] = true;
case EVENT_CRIT_WARNING: if (!empty($id_metaconsole)) {
$data[$cont]['data'] = 2; $connection = db_get_row_filter ('tmetaconsole_setup',
break; $id_metaconsole);
case EVENT_CRIT_CRITICAL: if (metaconsole_load_external_db($connection) != NOERR) {
$data[$cont]['data'] = 3; continue;
break; }
default: }
$data[$cont]['data'] = 1; $return['url'] = true;
break; if (!empty($id_metaconsole)) {
metaconsole_restore_db();
} }
} }
else { else {
$data[$cont]['utimestamp'] = $periodtime; $return['no_data'] = false;
$data[$cont]['data'] = 1;
}
$cont++;
} }
$colors = array(1 => COL_NORMAL, 2 => COL_WARNING, 3 => COL_CRITICAL, 4 => COL_UNKNOWN); echo json_encode($return);
$out = flot_slicesbar_graph($data, $period, 450, 15, $full_legend, $colors, $config['fontpath'], $config['round_corner'], $homeurl, '', '', false, $id_agent);
html_debug($out, true);
if (!$out) {
$out = array();
}
echo json_encode($out);
break; break;
case 'get_image_sparse': case 'get_image_sparse':
@ -935,6 +905,8 @@ switch ($action) {
case 'auto_sla_graph': case 'auto_sla_graph':
$values['type'] = AUTO_SLA_GRAPH; $values['type'] = AUTO_SLA_GRAPH;
$values['period'] = $event_max_time_row; $values['period'] = $event_max_time_row;
$values['width'] = $width;
$values['height'] = $height;
break; break;
case 'percentile_item': case 'percentile_item':
case 'percentile_bar': case 'percentile_bar':

View File

@ -510,7 +510,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$form_items_advance['position_row'] = array(); $form_items_advance['position_row'] = array();
$form_items_advance['position_row']['items'] = array('static_graph', $form_items_advance['position_row']['items'] = array('static_graph',
'percentile_bar', 'percentile_item', 'module_graph', 'percentile_bar', 'percentile_item', 'module_graph',
'simple_value', 'label', 'icon', 'datos', 'box_item'); 'simple_value', 'label', 'icon', 'datos', 'box_item',
'auto_sla_graph');
$form_items_advance['position_row']['html'] = ' $form_items_advance['position_row']['html'] = '
<td align="left">' . __('Position') . '</td> <td align="left">' . __('Position') . '</td>
<td align="left">(' . html_print_input_text('left', '0', '', 3, 5, true) . <td align="left">(' . html_print_input_text('left', '0', '', 3, 5, true) .
@ -521,7 +522,8 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
$form_items_advance['size_row'] = array(); $form_items_advance['size_row'] = array();
$form_items_advance['size_row']['items'] = array( $form_items_advance['size_row']['items'] = array(
'group_item', 'background', 'group_item', 'background',
'static_graph', 'icon datos'); 'static_graph', 'icon datos',
'auto_sla_graph');
$form_items_advance['size_row']['html'] = '<td align="left">' . $form_items_advance['size_row']['html'] = '<td align="left">' .
__('Size') . __('Size') .
ui_print_help_tip ( ui_print_help_tip (