mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
Merge branch 'ent-7960-filtros-de-alertas-sonoras-sound-events-2' into 'develop'
events sound pandora_enterprise#7960 See merge request artica/pandorafms!4923
This commit is contained in:
commit
4ca27cd5a9
@ -2227,121 +2227,77 @@ if ($process_buffers === true) {
|
|||||||
|
|
||||||
if ($get_events_fired) {
|
if ($get_events_fired) {
|
||||||
global $config;
|
global $config;
|
||||||
$id = get_parameter('id_row');
|
$filter_id = (int) get_parameter('filter_id', 0);
|
||||||
$idGroup = get_parameter('id_group');
|
$interval = (int) get_parameter('interval', 10);
|
||||||
$agents = get_parameter('agents', null);
|
|
||||||
|
|
||||||
$query = ' AND id_evento > '.$id;
|
if (empty($filter_id) === true) {
|
||||||
|
$filter = [
|
||||||
$type = [];
|
'id_group' => 0,
|
||||||
$alert = get_parameter('alert_fired');
|
'event_type' => '',
|
||||||
if ($alert == 'true') {
|
'severity' => -1,
|
||||||
$resultAlert = alerts_get_event_status_group(
|
'status' => -1,
|
||||||
$idGroup,
|
'search' => '',
|
||||||
[
|
'text_agent' => '',
|
||||||
'alert_fired',
|
'id_agent' => 0,
|
||||||
'alert_ceased',
|
'id_agent_module' => 0,
|
||||||
],
|
'pagination' => 0,
|
||||||
$query,
|
'id_user_ack' => 0,
|
||||||
$agents
|
'group_rep' => 0,
|
||||||
);
|
'tag_with' => [],
|
||||||
}
|
'tag_without' => [],
|
||||||
|
'filter_only_alert' => -1,
|
||||||
$critical = get_parameter('critical');
|
'source' => '',
|
||||||
if ($critical == 'true') {
|
'id_extra' => '',
|
||||||
$resultCritical = alerts_get_event_status_group(
|
'user_comment' => '',
|
||||||
$idGroup,
|
'id_source_event' => 0,
|
||||||
[
|
'server_id' => 0,
|
||||||
'going_up_critical',
|
'custom_data' => '',
|
||||||
'going_down_critical',
|
'custom_data_filter_type' => 0,
|
||||||
],
|
|
||||||
$query,
|
|
||||||
$agents
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$warning = get_parameter('warning');
|
|
||||||
if ($warning == 'true') {
|
|
||||||
$resultWarning = alerts_get_event_status_group(
|
|
||||||
$idGroup,
|
|
||||||
[
|
|
||||||
'going_up_warning',
|
|
||||||
'going_down_warning',
|
|
||||||
],
|
|
||||||
$query,
|
|
||||||
$agents
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$unknown = get_parameter('unknown');
|
|
||||||
if ($unknown == 'true') {
|
|
||||||
$resultUnknown = alerts_get_event_status_group(
|
|
||||||
$idGroup,
|
|
||||||
'going_unknown',
|
|
||||||
$query,
|
|
||||||
$agents
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($resultAlert) {
|
|
||||||
$return = [
|
|
||||||
'fired' => $resultAlert,
|
|
||||||
'sound' => $config['sound_alert'],
|
|
||||||
];
|
];
|
||||||
$event = events_get_event($resultAlert);
|
|
||||||
|
|
||||||
$module_name = modules_get_agentmodule_name($event['id_agentmodule']);
|
|
||||||
$agent_name = agents_get_alias($event['id_agente']);
|
|
||||||
|
|
||||||
$return['message'] = io_safe_output($agent_name).' - ';
|
|
||||||
$return['message'] .= __('Alert fired in module ');
|
|
||||||
$return['message'] .= io_safe_output($module_name).' - ';
|
|
||||||
$return['message'] .= $event['timestamp'];
|
|
||||||
} else if ($resultCritical) {
|
|
||||||
$return = [
|
|
||||||
'fired' => $resultCritical,
|
|
||||||
'sound' => $config['sound_critical'],
|
|
||||||
];
|
|
||||||
$event = events_get_event($resultCritical);
|
|
||||||
|
|
||||||
$module_name = modules_get_agentmodule_name($event['id_agentmodule']);
|
|
||||||
$agent_name = agents_get_alias($event['id_agente']);
|
|
||||||
|
|
||||||
$return['message'] = io_safe_output($agent_name).' - ';
|
|
||||||
$return['message'] .= __('Module ').io_safe_output($module_name);
|
|
||||||
$return['message'] .= __(' is going to critical').' - ';
|
|
||||||
$return['message'] .= $event['timestamp'];
|
|
||||||
} else if ($resultWarning) {
|
|
||||||
$return = [
|
|
||||||
'fired' => $resultWarning,
|
|
||||||
'sound' => $config['sound_warning'],
|
|
||||||
];
|
|
||||||
$event = events_get_event($resultWarning);
|
|
||||||
|
|
||||||
$module_name = modules_get_agentmodule_name($event['id_agentmodule']);
|
|
||||||
$agent_name = agents_get_alias($event['id_agente']);
|
|
||||||
|
|
||||||
$return['message'] = io_safe_output($agent_name).' - ';
|
|
||||||
$return['message'] .= __('Module ').io_safe_output($module_name);
|
|
||||||
$return['message'] .= __(' is going to warning').' - ';
|
|
||||||
$return['message'] .= $event['timestamp'];
|
|
||||||
} else if ($resultUnknown) {
|
|
||||||
$return = [
|
|
||||||
'fired' => $resultUnknown,
|
|
||||||
'sound' => $config['sound_alert'],
|
|
||||||
];
|
|
||||||
$event = events_get_event($resultUnknown);
|
|
||||||
|
|
||||||
$module_name = modules_get_agentmodule_name($event['id_agentmodule']);
|
|
||||||
$agent_name = agents_get_alias($event['id_agente']);
|
|
||||||
|
|
||||||
$return['message'] = io_safe_output($agent_name).' - ';
|
|
||||||
$return['message'] .= __('Module ').io_safe_output($module_name);
|
|
||||||
$return['message'] .= __(' is going to unknown').' - ';
|
|
||||||
$return['message'] .= $event['timestamp'];
|
|
||||||
} else {
|
} else {
|
||||||
$return = ['fired' => 0];
|
$filter = events_get_event_filter($filter_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set time.
|
||||||
|
$filter['event_view_hr'] = 0;
|
||||||
|
|
||||||
|
$start = (time() - $interval);
|
||||||
|
$end = time();
|
||||||
|
|
||||||
|
$filter['date_from'] = date('Y-m-d', $start);
|
||||||
|
$filter['date_to'] = date('Y-m-d', $end);
|
||||||
|
$filter['time_from'] = date('H:i:s', $start);
|
||||||
|
$filter['time_to'] = date('H:i:s', $end);
|
||||||
|
$data = events_get_all(
|
||||||
|
['te.*'],
|
||||||
|
$filter
|
||||||
|
);
|
||||||
|
|
||||||
|
$return = [];
|
||||||
|
if (empty($data) === false) {
|
||||||
|
foreach ($data as $event) {
|
||||||
|
$return[] = [
|
||||||
|
'fired' => $event['id_evento'],
|
||||||
|
'message' => ui_print_string_substr(
|
||||||
|
strip_tags(io_safe_output($event['evento'])),
|
||||||
|
75,
|
||||||
|
true,
|
||||||
|
'9'
|
||||||
|
),
|
||||||
|
'priority' => ui_print_event_priority($event['criticity'], true, true),
|
||||||
|
'type' => events_print_type_img(
|
||||||
|
$event['event_type'],
|
||||||
|
true
|
||||||
|
),
|
||||||
|
'timestamp' => ui_print_timestamp(
|
||||||
|
$event['timestamp'],
|
||||||
|
true,
|
||||||
|
['style' => 'font-size: 9pt; letter-spacing: 0.3pt;']
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo io_json_mb_encode($return);
|
echo io_json_mb_encode($return);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2028,6 +2028,60 @@ function inArray(needle, haystack) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Creates a progressbar.
|
||||||
|
* @param id the id of the div we want to transform in a progressbar.
|
||||||
|
* @param duration the duration of the timer example: '10s'.
|
||||||
|
* @param iteration.
|
||||||
|
* @param callback, optional function which is called when the progressbar reaches 0.
|
||||||
|
*/
|
||||||
|
function createProgressTimeBar(id, duration, iteration, callback) {
|
||||||
|
// We select the div that we want to turn into a progressbar
|
||||||
|
var progressbar = document.getElementById(id);
|
||||||
|
progressbar.className = "progressbar";
|
||||||
|
|
||||||
|
// We create the div that changes width to show progress
|
||||||
|
var progressbarinner = document.createElement("div");
|
||||||
|
progressbarinner.className = "inner";
|
||||||
|
|
||||||
|
// Now we set the animation parameters
|
||||||
|
progressbarinner.style.animationDuration = duration;
|
||||||
|
|
||||||
|
progressbarinner.style.animationIterationCount = iteration;
|
||||||
|
|
||||||
|
// Eventually couple a callback
|
||||||
|
if (typeof callback === "function") {
|
||||||
|
if (iteration === "infinite") {
|
||||||
|
progressbarinner.addEventListener("animationiteration", callback);
|
||||||
|
} else {
|
||||||
|
progressbarinner.addEventListener("animationend", callback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Append the progressbar to the main progressbardiv
|
||||||
|
progressbar.appendChild(progressbarinner);
|
||||||
|
|
||||||
|
// When everything is set up we start the animation
|
||||||
|
progressbarinner.style.animationPlayState = "running";
|
||||||
|
|
||||||
|
return progressbarinner;
|
||||||
|
}
|
||||||
|
|
||||||
|
function progressTimeBar(id, interval, iteration, callback) {
|
||||||
|
var progress = createProgressTimeBar(id, interval + "s", iteration, callback);
|
||||||
|
|
||||||
|
var controls = {
|
||||||
|
start: function() {
|
||||||
|
progress.style.animationPlayState = "running";
|
||||||
|
},
|
||||||
|
paused: function() {
|
||||||
|
progress.style.animationPlayState = "paused";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return controls;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter selector item by text based on a text input.
|
* Filter selector item by text based on a text input.
|
||||||
*
|
*
|
||||||
|
@ -6256,7 +6256,7 @@ div.graph div.legend table {
|
|||||||
|
|
||||||
.sound_events {
|
.sound_events {
|
||||||
background-color: #494949;
|
background-color: #494949;
|
||||||
margin: 40px 2em 0;
|
margin: 1em 2em;
|
||||||
min-height: auto;
|
min-height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1475,12 +1475,20 @@ if ($pure) {
|
|||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function openSoundEventWindow() {
|
function openSoundEventWindow() {
|
||||||
url = "<?php echo ui_get_full_url('operation/events/sound_events.php'); ?>";
|
url = '<?php echo ui_get_full_url('operation/events/sound_events.php'); ?>';
|
||||||
|
// devicePixelRatio knows how much zoom browser applied.
|
||||||
|
var windowScale = parseFloat(window.devicePixelRatio);
|
||||||
|
var defaultWidth = 630;
|
||||||
|
var defaultHeight = 630;
|
||||||
|
// If the scale is 1, no zoom has been applied.
|
||||||
|
var windowWidth = windowScale <= 1 ? defaultWidth : windowScale*defaultWidth;
|
||||||
|
var windowHeight = windowScale <= 1 ? defaultHeight : windowScale*defaultHeight + (defaultHeight*0.1);
|
||||||
|
|
||||||
window.open(
|
window.open(
|
||||||
url,
|
url,
|
||||||
'<?php __('Sound Alerts'); ?>',
|
'<?php __('Sound Alerts'); ?>',
|
||||||
'width=600, height=450, toolbar=no, location=no, directories=no, status=no, menubar=no, resizable=no'
|
'width='+windowWidth+', height='+windowHeight+', resizable=yes, toolbar=no, location=no, directories=no, status=no, menubar=no'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
|
@ -55,13 +55,14 @@ if (check_acl($config['id_user'], 0, 'ER') === false
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$agents = agents_get_group_agents(0, false, 'none', false, true);
|
|
||||||
ob_start('ui_process_page_head');
|
ob_start('ui_process_page_head');
|
||||||
ob_start();
|
ob_start();
|
||||||
echo '<html>';
|
echo '<html>';
|
||||||
echo '<head>';
|
echo '<head>';
|
||||||
|
|
||||||
echo '<title>'.__('Sound Events').'</title>';
|
echo '<title>'.__('Sound Events').'</title>';
|
||||||
|
ui_require_css_file('wizard');
|
||||||
|
ui_require_css_file('discovery');
|
||||||
?>
|
?>
|
||||||
<style type='text/css'>
|
<style type='text/css'>
|
||||||
* {
|
* {
|
||||||
@ -72,6 +73,83 @@ echo '<title>'.__('Sound Events').'</title>';
|
|||||||
img {
|
img {
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.wizard li > label:not(.p-switch):first-of-type {
|
||||||
|
width: inherit;
|
||||||
|
}
|
||||||
|
form {
|
||||||
|
margin-top: -3px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.events_fired {
|
||||||
|
background: white;
|
||||||
|
padding: 20px;
|
||||||
|
overflow: auto;
|
||||||
|
height: 200px;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.events_fired li {
|
||||||
|
padding: 5px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
.events_fired li div {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.events_fired li div.flex0 {
|
||||||
|
flex: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.events_fired li div.flex-time {
|
||||||
|
flex: 0 1 100px;
|
||||||
|
text-align: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.events_fired li div.mess {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.forced_title.mini-criticity {
|
||||||
|
width: 10px;
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progressbar {
|
||||||
|
width: 100%;
|
||||||
|
margin: 5px 0px;
|
||||||
|
}
|
||||||
|
.progressbar .inner {
|
||||||
|
height: 10px;
|
||||||
|
animation: progressbar-countdown;
|
||||||
|
/* Placeholder, this will be updated using javascript */
|
||||||
|
animation-duration: 40s;
|
||||||
|
/* We stop in the end */
|
||||||
|
animation-iteration-count: 1;
|
||||||
|
/* Stay on pause when the animation is finished finished */
|
||||||
|
animation-fill-mode: forwards;
|
||||||
|
/* We start paused, we start the animation using javascript */
|
||||||
|
animation-play-state: paused;
|
||||||
|
/* We want a linear animation, ease-out is standard */
|
||||||
|
animation-timing-function: linear;
|
||||||
|
}
|
||||||
|
@keyframes progressbar-countdown {
|
||||||
|
0% {
|
||||||
|
width: 100%;
|
||||||
|
background: #82b92e;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
width: 0%;
|
||||||
|
background: #e63c52;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
<?php
|
<?php
|
||||||
echo '<link rel="icon" href="../../'.ui_get_favicon().'" type="image/ico" />';
|
echo '<link rel="icon" href="../../'.ui_get_favicon().'" type="image/ico" />';
|
||||||
@ -98,106 +176,121 @@ ui_print_message_dialog(
|
|||||||
'/images/error_1.png'
|
'/images/error_1.png'
|
||||||
);
|
);
|
||||||
|
|
||||||
$table = new StdClass;
|
$inputs = [];
|
||||||
$table->width = '100%';
|
|
||||||
$table->class = 'w16px sound_div_background ';
|
|
||||||
$table->size[0] = '10%';
|
|
||||||
$table->rowclass[0] = 'bold_top';
|
|
||||||
$table->rowclass[1] = 'bold_top';
|
|
||||||
$table->rowclass[2] = 'bold_top';
|
|
||||||
|
|
||||||
$table->data[0][0] = __('Group');
|
// Load filter.
|
||||||
$table->data[0][1] = html_print_select_groups(
|
$fields = \events_get_event_filter_select();
|
||||||
false,
|
$inputs[] = [
|
||||||
$access,
|
'label' => \__('Load filter'),
|
||||||
true,
|
'class' => 'flex-row',
|
||||||
'group',
|
'arguments' => [
|
||||||
'',
|
'type' => 'select',
|
||||||
'changeGroup();',
|
'fields' => $fields,
|
||||||
'',
|
'name' => 'filter_id',
|
||||||
0,
|
'selected' => 0,
|
||||||
true,
|
'return' => true,
|
||||||
false,
|
'nothing' => \__('All new events'),
|
||||||
true,
|
'nothing_value' => 0,
|
||||||
'',
|
'class' => 'fullwidth',
|
||||||
false,
|
],
|
||||||
'max-width:200px;'
|
];
|
||||||
).'<br /><br />';
|
|
||||||
|
|
||||||
$table->data[0][2] = __('Type');
|
$times_interval = [
|
||||||
$table->data[0][3] = html_print_checkbox(
|
10 => '10 '.__('seconds'),
|
||||||
'alert_fired',
|
15 => '15 '.__('seconds'),
|
||||||
'alert_fired',
|
30 => '30 '.__('seconds'),
|
||||||
true,
|
60 => '60 '.__('seconds'),
|
||||||
true,
|
];
|
||||||
false,
|
|
||||||
'changeType();'
|
|
||||||
);
|
|
||||||
$table->data[0][3] .= __('Alert fired').'<br />';
|
|
||||||
$table->data[0][3] .= html_print_checkbox(
|
|
||||||
'critical',
|
|
||||||
'critical',
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'changeType();'
|
|
||||||
);
|
|
||||||
$table->data[0][3] .= __('Monitor critical').'<br />';
|
|
||||||
$table->data[0][3] .= html_print_checkbox(
|
|
||||||
'unknown',
|
|
||||||
'unknown',
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'changeType();'
|
|
||||||
);
|
|
||||||
$table->data[0][3] .= __('Monitor unknown').'<br />';
|
|
||||||
$table->data[0][3] .= html_print_checkbox(
|
|
||||||
'warning',
|
|
||||||
'warning',
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
'changeType();'
|
|
||||||
);
|
|
||||||
$table->data[0][3] .= __('Monitor warning').'<br />';
|
|
||||||
|
|
||||||
$table->data[1][0] = __('Agent');
|
$times_sound = [
|
||||||
$table->data[1][1] = html_print_select(
|
2 => '2 '.__('seconds'),
|
||||||
$agents,
|
5 => '5 '.__('seconds'),
|
||||||
'id_agents[]',
|
10 => '10 '.__('seconds'),
|
||||||
true,
|
15 => '15 '.__('seconds'),
|
||||||
|
30 => '30 '.__('seconds'),
|
||||||
|
60 => '60 '.__('seconds'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$inputs[] = [
|
||||||
|
'class' => 'flex-row flex-row-center',
|
||||||
|
'direct' => 1,
|
||||||
|
'block_content' => [
|
||||||
|
[
|
||||||
|
'label' => __('Interval'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'fields' => $times_interval,
|
||||||
|
'name' => 'interval',
|
||||||
|
'selected' => 10,
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'label' => __('Time Sound'),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'fields' => $times_sound,
|
||||||
|
'name' => 'time_sound',
|
||||||
|
'selected' => 10,
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$sounds = [
|
||||||
|
'aircraftalarm.wav' => 'Air craft alarm',
|
||||||
|
'air_shock_alarm.wav' => 'Air shock alarm',
|
||||||
|
'alien_alarm.wav' => 'Alien alarm',
|
||||||
|
'alien_beacon.wav' => 'Alien beacon',
|
||||||
|
'bell_school_ringing.wav' => 'Bell school ringing',
|
||||||
|
'Door_Alarm.wav' => 'Door alarm',
|
||||||
|
'EAS_beep.wav' => 'EAS beep',
|
||||||
|
'Firewarner.wav' => 'Fire warner',
|
||||||
|
'HardPCMAlarm.wav' => 'Hard PCM Alarm',
|
||||||
|
'negativebeep.wav' => 'Negative beep',
|
||||||
|
'Star_Trek_emergency_simulation.wav' => 'StarTrek emergency simulation',
|
||||||
|
];
|
||||||
|
|
||||||
|
$inputs[] = [
|
||||||
|
'label' => \__('Sounds'),
|
||||||
|
'class' => 'flex-row',
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'fields' => $sounds,
|
||||||
|
'name' => 'sound_id',
|
||||||
|
'selected' => 'Star_Trek_emergency_simulation.wav',
|
||||||
|
'return' => true,
|
||||||
|
'class' => 'fullwidth',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Print form.
|
||||||
|
HTML::printForm(
|
||||||
|
[
|
||||||
|
'form' => [
|
||||||
|
'action' => '',
|
||||||
|
'method' => 'POST',
|
||||||
|
],
|
||||||
|
'inputs' => $inputs,
|
||||||
|
],
|
||||||
false,
|
false,
|
||||||
'',
|
|
||||||
'',
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
'max-width:200px; height:100px',
|
|
||||||
'',
|
|
||||||
false,
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
$table->data[1][2] = __('Event');
|
$result = '<div><ul class="events_fired">';
|
||||||
$table->data[1][3] = html_print_textarea(
|
$result .= '<li class="events_fired_li_empty">';
|
||||||
'events_fired',
|
$result .= ui_print_info_message(__('Events not found'), '', true);
|
||||||
200,
|
$result .= '</li>';
|
||||||
20,
|
$result .= '</ul></div>';
|
||||||
'',
|
|
||||||
'readonly="readonly" style="max-height:100px; resize:none;"',
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
html_print_table($table);
|
$result .= '<div id="progressbar_time"></div>';
|
||||||
|
|
||||||
|
echo $result;
|
||||||
|
|
||||||
$table = new StdClass;
|
$table = new StdClass;
|
||||||
$table->width = '100%';
|
$table->width = '100%';
|
||||||
$table->class = 'w16px sound_div_background text_center';
|
$table->class = 'sound_div_background text_center';
|
||||||
|
|
||||||
$table->data[0][0] = '<a href="javascript: toggleButton();">';
|
$table->data[0][0] = '<a href="javascript: toggleButton();">';
|
||||||
$table->data[0][0] .= html_print_image(
|
$table->data[0][0] .= html_print_image(
|
||||||
@ -239,18 +332,11 @@ html_print_table($table);
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var group = 0;
|
var control = false;
|
||||||
var alert_fired = true;
|
|
||||||
var critical = true;
|
|
||||||
var warning = true;
|
|
||||||
var unknown = true;
|
|
||||||
|
|
||||||
var running = false;
|
var running = false;
|
||||||
|
|
||||||
var id_row = 0;
|
var id_row = 0;
|
||||||
|
|
||||||
var button_play_status = "play";
|
var button_play_status = "play";
|
||||||
|
|
||||||
var test_sound = false;
|
var test_sound = false;
|
||||||
|
|
||||||
function test_sound_button() {
|
function test_sound_button() {
|
||||||
@ -258,64 +344,18 @@ function test_sound_button() {
|
|||||||
$("#button_try").attr('src', '../../images/icono_test.png');
|
$("#button_try").attr('src', '../../images/icono_test.png');
|
||||||
$('body').append("<audio src='../../include/sounds/Star_Trek_emergency_simulation.wav' autoplay='true' hidden='true' loop='false'>");
|
$('body').append("<audio src='../../include/sounds/Star_Trek_emergency_simulation.wav' autoplay='true' hidden='true' loop='false'>");
|
||||||
test_sound = true;
|
test_sound = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$("#button_try").attr('src', '../../images/icono_test.png');
|
$("#button_try").attr('src', '../../images/icono_test.png');
|
||||||
$('body audio').remove();
|
$('body audio').remove();
|
||||||
test_sound = false;
|
test_sound = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeGroup() {
|
|
||||||
group = $("#group").val();
|
|
||||||
|
|
||||||
jQuery.post ("../../ajax.php",
|
|
||||||
{"page" : "include/ajax/agent",
|
|
||||||
"get_agents_group": 1,
|
|
||||||
"id_group": group
|
|
||||||
},
|
|
||||||
function (data) {
|
|
||||||
$("#id_agents").empty();
|
|
||||||
jQuery.each (data, function (id, value) {
|
|
||||||
if (value != "") {
|
|
||||||
$("#id_agents")
|
|
||||||
.append(
|
|
||||||
'<option value="' + id + '">' + value + '</option>'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
"json"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function changeType() {
|
|
||||||
alert_fired = false;
|
|
||||||
critical = false;
|
|
||||||
warning = false;
|
|
||||||
unknown = false;
|
|
||||||
|
|
||||||
if($("input[name=alert_fired]").is(':checked') ) {
|
|
||||||
alert_fired = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($("input[name=critical]").is(':checked') ) {
|
|
||||||
critical = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($("input[name=warning]").is(':checked') ) {
|
|
||||||
warning = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($("input[name=unknown]").is(':checked') ) {
|
|
||||||
unknown = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleButton() {
|
function toggleButton() {
|
||||||
if (button_play_status == 'pause') {
|
if (button_play_status == 'pause') {
|
||||||
$("#button").attr('src', '../../images/play.button.png');
|
$("#button").attr('src', '../../images/play.button.png');
|
||||||
stopSound();
|
stopSound();
|
||||||
|
control.paused();
|
||||||
|
|
||||||
button_play_status = 'play';
|
button_play_status = 'play';
|
||||||
}
|
}
|
||||||
@ -331,7 +371,7 @@ function toggleButton() {
|
|||||||
function ok() {
|
function ok() {
|
||||||
$('#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("");
|
$('.events_fired').empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
function stopSound() {
|
function stopSound() {
|
||||||
@ -345,66 +385,77 @@ function startSound() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function forgetPreviousEvents() {
|
function forgetPreviousEvents() {
|
||||||
var agents = $("#id_agents").val();
|
if(control === false) {
|
||||||
|
running = true;
|
||||||
jQuery.post ("../../ajax.php",
|
control = progressTimeBar(
|
||||||
{"page" : "include/ajax/events",
|
"progressbar_time",
|
||||||
"get_events_fired": 1,
|
$("#interval").val(),
|
||||||
"id_group": group,
|
'infinite',
|
||||||
"alert_fired": alert_fired,
|
function() {
|
||||||
"critical": critical,
|
check_event();
|
||||||
"warning": warning,
|
|
||||||
"unknown": unknown,
|
|
||||||
"id_row": id_row,
|
|
||||||
"agents[]" : agents
|
|
||||||
},
|
|
||||||
function (data) {
|
|
||||||
firedId = parseInt(data['fired']);
|
|
||||||
if (firedId != 0) {
|
|
||||||
id_row = firedId;
|
|
||||||
}
|
}
|
||||||
running = true;
|
);
|
||||||
},
|
} else {
|
||||||
"json"
|
control.start();
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_event() {
|
function check_event() {
|
||||||
var agents = $("#id_agents").val();
|
|
||||||
if (running) {
|
if (running) {
|
||||||
|
var sound = '../../include/sounds/' + $('#sound_id').val();
|
||||||
jQuery.post ("../../ajax.php",
|
jQuery.post ("../../ajax.php",
|
||||||
{"page" : "include/ajax/events",
|
{
|
||||||
|
"page" : "include/ajax/events",
|
||||||
"get_events_fired": 1,
|
"get_events_fired": 1,
|
||||||
"id_group": group,
|
"filter_id": $('#filter_id').val(),
|
||||||
"alert_fired": alert_fired,
|
"interval": $('#interval').val(),
|
||||||
"critical": critical,
|
"time_sound": $('#time_sound').val(),
|
||||||
"warning": warning,
|
|
||||||
"unknown": unknown,
|
|
||||||
"id_row": id_row,
|
|
||||||
"agents[]" : agents,
|
|
||||||
},
|
},
|
||||||
function (data) {
|
function (data) {
|
||||||
firedId = parseInt(data['fired']);
|
if(data != false) {
|
||||||
if (firedId != 0) {
|
$('.events_fired_li_empty').remove();
|
||||||
id_row = firedId;
|
|
||||||
var actual_text = $('#textarea_events_fired').val();
|
|
||||||
if (actual_text == "") {
|
|
||||||
$('#textarea_events_fired').val(data['message'] + "\n");
|
|
||||||
} else {
|
|
||||||
$('#textarea_events_fired')
|
|
||||||
.val(actual_text + "\n" + data['message'] + "\n");
|
|
||||||
}
|
|
||||||
$('#button_status')
|
$('#button_status')
|
||||||
.attr(
|
.attr(
|
||||||
'src','../../images/sound_events_console_alert.gif'
|
'src','../../images/sound_events_console_alert.gif'
|
||||||
);
|
);
|
||||||
$('audio').remove();
|
$('audio').remove();
|
||||||
if(data['sound'] == '') {
|
|
||||||
data['sound'] = 'include/sounds/Star_Trek_emergency_simulation.wav';
|
|
||||||
}
|
|
||||||
|
|
||||||
$('body')
|
$('body')
|
||||||
.append("<audio src='../../" + data['sound'] + "' autoplay='true' hidden='true' loop='true'>");
|
.append(
|
||||||
|
"<audio id='audio-boom' src='" + sound + "' autoplay='true' hidden='true' loop='true' >"
|
||||||
|
);
|
||||||
|
|
||||||
|
data.forEach(function (element) {
|
||||||
|
var li = document.createElement('li');
|
||||||
|
li.insertAdjacentHTML(
|
||||||
|
'beforeend',
|
||||||
|
'<div class="flex0">'+element.priority+'</div>'
|
||||||
|
);
|
||||||
|
li.insertAdjacentHTML(
|
||||||
|
'beforeend',
|
||||||
|
'<div class="flex0">'+element.type+'</div>'
|
||||||
|
);
|
||||||
|
li.insertAdjacentHTML(
|
||||||
|
'beforeend',
|
||||||
|
'<div class="mess">'+element.message+'</div>'
|
||||||
|
);
|
||||||
|
li.insertAdjacentHTML(
|
||||||
|
'beforeend',
|
||||||
|
'<div class="flex-time">'+element.timestamp+'</div>'
|
||||||
|
);
|
||||||
|
$('.events_fired').append(li);
|
||||||
|
});
|
||||||
|
|
||||||
|
function removeAudio() {
|
||||||
|
$('audio').remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
// -100 delay sound.
|
||||||
|
setTimeout(
|
||||||
|
removeAudio,
|
||||||
|
(parseInt($('#time_sound').val()) * 1000) - 100
|
||||||
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"json"
|
"json"
|
||||||
@ -412,11 +463,6 @@ function check_event() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready (function () {
|
|
||||||
//10 seconds between ajax request
|
|
||||||
setInterval("check_event()", (10 * 1000));
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
@ -420,7 +420,6 @@ if (check_acl($config['id_user'], 0, 'ER')
|
|||||||
|
|
||||||
// Sound Events.
|
// Sound Events.
|
||||||
$javascript = "javascript: window.open('operation/events/sound_events.php');";
|
$javascript = "javascript: window.open('operation/events/sound_events.php');";
|
||||||
$javascript = 'javascript: alert(111);';
|
|
||||||
$javascript = 'javascript: openSoundEventWindow();';
|
$javascript = 'javascript: openSoundEventWindow();';
|
||||||
$sub[$javascript]['text'] = __('Sound Events');
|
$sub[$javascript]['text'] = __('Sound Events');
|
||||||
$sub[$javascript]['id'] = 'Sound Events';
|
$sub[$javascript]['id'] = 'Sound Events';
|
||||||
@ -432,12 +431,12 @@ if (check_acl($config['id_user'], 0, 'ER')
|
|||||||
url = '<?php echo ui_get_full_url('operation/events/sound_events.php'); ?>';
|
url = '<?php echo ui_get_full_url('operation/events/sound_events.php'); ?>';
|
||||||
// devicePixelRatio knows how much zoom browser applied.
|
// devicePixelRatio knows how much zoom browser applied.
|
||||||
var windowScale = parseFloat(window.devicePixelRatio);
|
var windowScale = parseFloat(window.devicePixelRatio);
|
||||||
var defaultWidth = 600;
|
var defaultWidth = 630;
|
||||||
var defaultHeight = 450;
|
var defaultHeight = 630;
|
||||||
// If the scale is 1, no zoom has been applied.
|
// If the scale is 1, no zoom has been applied.
|
||||||
var windowWidth = windowScale <= 1 ? defaultWidth : windowScale*defaultWidth;
|
var windowWidth = windowScale <= 1 ? defaultWidth : windowScale*defaultWidth;
|
||||||
var windowHeight = windowScale <= 1 ? defaultHeight : windowScale*defaultHeight + (defaultHeight*0.1);
|
var windowHeight = windowScale <= 1 ? defaultHeight : windowScale*defaultHeight + (defaultHeight*0.1);
|
||||||
|
|
||||||
window.open(
|
window.open(
|
||||||
url,
|
url,
|
||||||
'<?php __('Sound Alerts'); ?>',
|
'<?php __('Sound Alerts'); ?>',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user