Merge branch '957-sound-events-style-dev' into 'develop'

Added styles to sound events window

See merge request !543
This commit is contained in:
vgilc 2017-06-02 10:34:05 +02:00
commit 5ed3e01afc
2 changed files with 52 additions and 43 deletions

View File

@ -161,29 +161,45 @@ if (is_ajax ()) {
$return = array('fired' => $resultAlert, $return = array('fired' => $resultAlert,
'sound' => $config['sound_alert']); 'sound' => $config['sound_alert']);
$event = events_get_event($resultAlert); $event = events_get_event($resultAlert);
$module_name = modules_get_agentmodule_name($event['id_agentmodule']); $module_name = modules_get_agentmodule_name($event['id_agentmodule']);
$return['message'] = __('Alert fired in module ') . io_safe_output($module_name); $agent_name = agents_get_alias($event['id_agente']);
$return['message'] = $agent_name . " - " . __('Alert fired in module ') . io_safe_output($module_name) .
" - " . $event['timestamp'];
} }
else if ($resultCritical) { else if ($resultCritical) {
$return = array('fired' => $resultCritical, $return = array('fired' => $resultCritical,
'sound' => $config['sound_critical']); 'sound' => $config['sound_critical']);
$event = events_get_event($resultCritical); $event = events_get_event($resultCritical);
$module_name = modules_get_agentmodule_name($event['id_agentmodule']); $module_name = modules_get_agentmodule_name($event['id_agentmodule']);
$return['message'] = __('Module ') . io_safe_output($module_name) . __(' is going to critical'); $agent_name = agents_get_alias($event['id_agente']);
$return['message'] = $agent_name . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to critical') .
" - " . $event['timestamp'];
} }
else if ($resultWarning) { else if ($resultWarning) {
$return = array('fired' => $resultWarning, $return = array('fired' => $resultWarning,
'sound' => $config['sound_warning']); 'sound' => $config['sound_warning']);
$event = events_get_event($resultWarning); $event = events_get_event($resultWarning);
$module_name = modules_get_agentmodule_name($event['id_agentmodule']); $module_name = modules_get_agentmodule_name($event['id_agentmodule']);
$return['message'] = __('Module ') . io_safe_output($module_name) . __(' is going to warning'); $agent_name = agents_get_alias($event['id_agente']);
$return['message'] = $agent_name . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to warning') .
" - " . $event['timestamp'];
} }
else if ($resultUnknown) { else if ($resultUnknown) {
$return = array('fired' => $resultUnknown, $return = array('fired' => $resultUnknown,
'sound' => $config['sound_alert']); 'sound' => $config['sound_alert']);
$event = events_get_event($resultUnknown); $event = events_get_event($resultUnknown);
$module_name = modules_get_agentmodule_name($event['id_agentmodule']); $module_name = modules_get_agentmodule_name($event['id_agentmodule']);
$return['message'] = __('Module ') . io_safe_output($module_name) . __(' is going to unknown'); $agent_name = agents_get_alias($event['id_agente']);
$return['message'] = $agent_name . " - " . __('Module ') . io_safe_output($module_name) . __(' is going to unknown') .
" - " . $event['timestamp'];
} }
else { else {
$return = array('fired' => 0); $return = array('fired' => 0);

View File

@ -77,7 +77,7 @@ $table->style[1] = 'font-weight: bold; vertical-align: top;';
$table->style[2] = 'font-weight: bold; vertical-align: top;'; $table->style[2] = 'font-weight: bold; vertical-align: top;';
$table->data[0][0] = __('Group'); $table->data[0][0] = __('Group');
$table->data[0][1] = html_print_select_groups(false, $access, true, 'group', '', 'changeGroup();', '', 0, true) . '<br />' . '<br />'; $table->data[0][1] = html_print_select_groups(false, $access, true, 'group', '', 'changeGroup();', '', 0, true, false, true, '', false, 'width:120px;') . '<br />' . '<br />';
$table->data[0][2] = __('Type'); $table->data[0][2] = __('Type');
$table->data[0][3] = html_print_checkbox('alert_fired', 'alert_fired', true, true, false, 'changeType();') . __('Alert fired') . '<br />' . $table->data[0][3] = html_print_checkbox('alert_fired', 'alert_fired', true, true, false, 'changeType();') . __('Alert fired') . '<br />' .
@ -86,10 +86,10 @@ $table->data[0][3] = html_print_checkbox('alert_fired', 'alert_fired', true, tru
html_print_checkbox('warning', 'warning', true, true, false, 'changeType();') . __('Monitor warning') . '<br />'; html_print_checkbox('warning', 'warning', true, true, false, 'changeType();') . __('Monitor warning') . '<br />';
$table->data[1][0] = __('Agent'); $table->data[1][0] = __('Agent');
$table->data[1][1] = html_print_select($agents, 'id_agents[]', true, false, '', '', true, true,'','','','width:104px; height:60px','',false,'','',true); $table->data[1][1] = html_print_select($agents, 'id_agents[]', true, false, '', '', true, true,'','','','width:120px; height:100px','',false,'','',true);
$table->data[1][2] = __('Event'); $table->data[1][2] = __('Event');
$table->data[1][3] = html_print_textarea ("events_fired", 1, 20, '', 'readonly="readonly" style="background: #ddd; resize:none;"', true); $table->data[1][3] = html_print_textarea ("events_fired", 200, 20, '', 'readonly="readonly" style="max-height:100px; background: #ddd; resize:none;"', true);
html_print_table($table); html_print_table($table);
@ -128,12 +128,9 @@ var warning = true;
var unknown = true; var unknown = true;
var running = false; var running = false;
var fired = false;
var id_row = 0; var id_row = 0;
var redBackground = false;
var button_play_status = "play"; var button_play_status = "play";
var test_sound = false; var test_sound = false;
@ -196,7 +193,6 @@ function toggleButton() {
} }
function ok() { function ok() {
fired = false;
$('#button_status').attr('src','../../images/tick_sound_events.png'); $('#button_status').attr('src','../../images/tick_sound_events.png');
$('audio').remove(); $('audio').remove();
$('#textarea_events_fired').val(""); $('#textarea_events_fired').val("");
@ -206,10 +202,8 @@ function stopSound() {
$('audio').remove(); $('audio').remove();
$('body').css('background', '#494949'); $('body').css('background', '#494949');
redBackground = false;
running = false; running = false;
fired = false;
} }
function startSound() { function startSound() {
@ -245,7 +239,6 @@ function check_event() {
var agents = $("#id_agents").val(); var agents = $("#id_agents").val();
if (running) { if (running) {
if (!fired) {
jQuery.post ("../../ajax.php", jQuery.post ("../../ajax.php",
{"page" : "operation/events/events", {"page" : "operation/events/events",
"get_events_fired": 1, "get_events_fired": 1,
@ -261,23 +254,23 @@ function check_event() {
firedId = parseInt(data['fired']); firedId = parseInt(data['fired']);
if (firedId != 0) { if (firedId != 0) {
id_row = firedId; id_row = firedId;
fired = true;
var actual_text = $('#textarea_events_fired').val(); var actual_text = $('#textarea_events_fired').val();
if (actual_text == "") { if (actual_text == "") {
$('#textarea_events_fired').val(data['message']); $('#textarea_events_fired').val(data['message'] + "\n");
} }
else { else {
$('#textarea_events_fired').val(actual_text + "\n" + data['message']); $('#textarea_events_fired').val(actual_text + "\n" + data['message'] + "\n");
} }
$('#button_status').attr('src','../../images/sound_events_console_alert.gif'); $('#button_status').attr('src','../../images/sound_events_console_alert.gif');
$('audio').remove();
$('body').append("<audio src='../../" + data['sound'] + "' autoplay='true' hidden='true' loop='true'>"); $('body').append("<audio src='../../" + data['sound'] + "' autoplay='true' hidden='true' loop='true'>");
} }
}, },
"json" "json"
); );
} }
} }
}
$(document).ready (function () { $(document).ready (function () {
setInterval("check_event()", (10 * 1000)); //10 seconds between ajax request setInterval("check_event()", (10 * 1000)); //10 seconds between ajax request