Added more things to new vc item

This commit is contained in:
Arturo Gonzalez 2017-07-12 13:34:20 +02:00
parent 9db5669f16
commit 63d07e1416
3 changed files with 104 additions and 2 deletions

View File

@ -515,9 +515,10 @@ function readFields() {
values['parent'] = $("select[name=parent]").val();
values['map_linked'] = $("select[name=map_linked]").val();
values['width_percentile'] = $("input[name=width_percentile]").val();
values['max_percentile'] = $("input[name=max_percentile]").val();
values['max_percentile'] = parseInt($("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();
values['event_max_time_row'] = $("select[name=event_max_time_row]").val();
values['type_percentile'] = $("input[name=type_percentile]:checked").val();
values['value_show'] = $("input[name=value_show]:checked").val();
values['enable_link'] = $("input[name=enable_link]").is(':checked') ? 1 : 0;
@ -587,6 +588,16 @@ function create_button_palette_callback() {
validate = false;
}
break;
case 'auto_sla_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 'label':
if ((values['label'] == '')) {
alert($("#message_alert_no_label").html());
@ -1783,6 +1794,17 @@ function setPercentileBar(id_data, values) {
});
}
function setEventsBar(id_data, values) {
metaconsole = $("input[name='metaconsole']").val();
var url_hack_metaconsole = '';
if (is_metaconsole()) {
url_hack_metaconsole = '../../';
}
$("#image_" + id_data).attr('src', data);
}
function setPercentileBubble(id_data, values) {
metaconsole = $("input[name='metaconsole']").val();
@ -2094,6 +2116,17 @@ function createItem(type, values, id_data) {
set_static_graph_status(id_data, values['image']);
break;
case 'auto_sla_graph':
var sizeStyle = '';
var imageSize = '';
item = $('<div id="' + id_data + '" class="item" style="text-align: left; position: absolute; display: inline-block; ' + 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>'
);
setEventsBar(id_data, values);
break;
case 'percentile_bar':
case 'percentile_item':

View File

@ -470,6 +470,7 @@ foreach ($layoutDatas as $layoutData) {
switch ($layoutData['type']) {
case LINE_ITEM:
case BOX_ITEM:
case AUTO_SLA_GRAPH:
$table->data[$i + 2][4] = "";
break;
default:

View File

@ -95,6 +95,7 @@ $top = get_parameter('top', null);
$agent = get_parameter('agent', null);
$id_module = get_parameter('module', null);
$period = get_parameter('period', null);
$event_max_time_row = get_parameter('event_max_time_row', null);
$width = get_parameter('width', null);
$height = get_parameter('height', null);
$parent = get_parameter('parent', null);
@ -139,7 +140,70 @@ switch ($action) {
echo json_encode($return);
break;
case 'get_module_events':
$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 ();
$datelimit = $date - $event_max_time_row;
$periodtime = floor ($event_max_time_row / $interval);
$time = array ();
$data = array ();
$legend = array();
$full_legend = array();
$cont = 0;
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,
'id_agentmodule' => $id_module,
'utimestamp > '.$bottom,
'utimestamp < '.$top), 'criticity, utimestamp');
if (!empty($event['utimestamp'])) {
$data[$cont]['utimestamp'] = $periodtime;
switch ($event['criticity']) {
case EVENT_CRIT_WARNING:
$data[$cont]['data'] = 2;
break;
case EVENT_CRIT_CRITICAL:
$data[$cont]['data'] = 3;
break;
default:
$data[$cont]['data'] = 1;
break;
}
}
else {
$data[$cont]['utimestamp'] = $periodtime;
$data[$cont]['data'] = 1;
}
$cont++;
}
$colors = array(1 => COL_NORMAL, 2 => COL_WARNING, 3 => COL_CRITICAL, 4 => COL_UNKNOWN);
$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;
case 'get_image_sparse':
//Metaconsole db connection
@ -868,6 +932,10 @@ switch ($action) {
}
$values['period'] = $period;
break;
case 'auto_sla_graph':
$values['type'] = AUTO_SLA_GRAPH;
$values['period'] = $event_max_time_row;
break;
case 'percentile_item':
case 'percentile_bar':
if ($type_percentile == 'percentile') {