diff --git a/pandora_console/images/alarm-off.png b/pandora_console/images/alarm-off.png new file mode 100644 index 0000000000..99f3895e0b Binary files /dev/null and b/pandora_console/images/alarm-off.png differ diff --git a/pandora_console/images/no-alerts-discovered.png b/pandora_console/images/no-alerts-discovered.png new file mode 100644 index 0000000000..ec9b9a88b1 Binary files /dev/null and b/pandora_console/images/no-alerts-discovered.png differ diff --git a/pandora_console/images/play-white.png b/pandora_console/images/play-white.png new file mode 100644 index 0000000000..2b9b1e93b2 Binary files /dev/null and b/pandora_console/images/play-white.png differ diff --git a/pandora_console/images/silence-alerts.png b/pandora_console/images/silence-alerts.png new file mode 100644 index 0000000000..22b1c95930 Binary files /dev/null and b/pandora_console/images/silence-alerts.png differ diff --git a/pandora_console/images/stop.png b/pandora_console/images/stop.png new file mode 100644 index 0000000000..20903a0132 Binary files /dev/null and b/pandora_console/images/stop.png differ diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 7e578a5488..5a92d33c16 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -2381,30 +2381,65 @@ if ($drawConsoleSound === true) { $output .= ''; $output .= '
'; - $output .= '

Morbi tincidunt, dui sit amet facilisis feugiat, odio metus gravida ante, ut pharetra massa metus id nunc. Duis scelerisque molestie turpis. Sed fringilla, massa eget luctus malesuada, metus eros molestie lectus, ut tempus eros massa ut dolor. Aenean aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit aliquam. Praesent in eros vestibulum mi adipiscing adipiscing. Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel metus. Ut posuere viverra nulla. Aliquam erat volutpat. Pellentesque convallis. Maecenas feugiat, tellus pellentesque pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel felis. Mauris consectetur tortor et purus.

'; + $output .= '

'; + $output .= __('Discovered alerts'); + $output .= '

'; + $output .= '
'; + $output .= html_print_image( + 'images/no-alerts-discovered.png', + true, + [ + 'title' => __('No alerts discovered'), + 'class' => 'invert_filter', + ] + ); + $output .= ''; + $output .= __('Congrats! there’s nothing to show'); + $output .= ''; + $output .= '
'; + $output .= '
'; $output .= '
'; $output .= ''; $output .= '
'; $output .= '
'; $output .= '
'; + $output .= '
'; $output .= html_print_input( [ + 'label' => __('Start'), 'type' => 'button', 'name' => 'start-search', - 'value' => __('Start'), 'attributes' => 'class="sub play"', 'return' => true, - ] + ], + 'div', + true ); + $output .= '
'; + $output .= '
'; $output .= html_print_input( [ 'type' => 'button', 'name' => 'no-alerts', - 'value' => __('No alerts'), + 'label' => __('No alerts'), 'attributes' => 'class="sub alerts"', 'return' => true, - ] + ], + 'div', + true + ); + $output .= '
'; + + $output .= html_print_input( + [ + 'type' => 'hidden', + 'name' => 'mode_alert', + 'value' => 0, + 'return' => true, + ], + 'div', + true ); $output .= '
'; $output .= '
'; diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index eb01e4d3cc..b7f4170afa 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -1,4 +1,4 @@ -/*global jQuery, $, forced_title_callback, confirmDialog*/ +/*global jQuery, $, forced_title_callback, confirmDialog, progressTimeBar*/ // Show the modal window of an event function show_event_dialog(event, dialog_page) { @@ -1042,6 +1042,7 @@ function openSoundEventModal(settings) { // Initialize modal. $("#modal-sound") + .empty() .dialog({ title: settings.title, resizable: false, @@ -1064,7 +1065,60 @@ function openSoundEventModal(settings) { dataType: "html", success: function(data) { $("#modal-sound").append(data); - $("#tabs-sound-modal").tabs(); + $("#tabs-sound-modal").tabs({ + disabled: [1] + }); + + // Test sound. + $("#button-melody_sound").click(function() { + var sound = false; + if ($("#id_sound_event").length == 0) { + sound = true; + } + + test_sound_button(sound); + }); + + // Play Stop. + $("#button-start-search").click(function() { + var mode = $("#hidden-mode_alert").val(); + var action = false; + if (mode == 0) { + action = true; + } + + action_events_sound(action, settings); + }); + + // Silence Alert. + $("#button-no-alerts").click(function() { + if ($("#button-no-alerts").hasClass("silence-alerts") === true) { + // Remove audio. + remove_audio(); + + // Clean events. + $("#tabs-sound-modal .elements-discovered-alerts ul").empty(); + $("#tabs-sound-modal .empty-discovered-alerts").removeClass( + "invisible_important" + ); + + // Clean progress. + $("#progressbar_time").empty(); + + // Change img button. + $("#button-no-alerts") + .removeClass("silence-alerts") + .addClass("alerts"); + // Change value button. + $("#button-no-alerts").val(settings.noAlert); + + // Background button. + $(".container-button-alert").removeClass("fired"); + + // New progress. + listen_event_sound(settings); + } + }); }, error: function(error) { console.error(error); @@ -1072,8 +1126,158 @@ function openSoundEventModal(settings) { }); }, close: function() { + remove_audio(); $(this).dialog("destroy"); } }) .show(); } + +function test_sound_button(test_sound) { + if (test_sound === true) { + add_audio(); + } else { + remove_audio(); + } +} + +function action_events_sound(mode, settings) { + if (mode === true) { + // Enable tabs. + $("#tabs-sound-modal").tabs("option", "disabled", [0]); + // Active tabs. + $("#tabs-sound-modal").tabs("option", "active", 1); + // Change mode. + $("#hidden-mode_alert").val(1); + // Change img button. + $("#button-start-search") + .removeClass("play") + .addClass("stop"); + // Change value button. + $("#button-start-search").val(settings.stop); + // Add Progress bar. + listen_event_sound(settings); + } else { + // Enable tabs. + $("#tabs-sound-modal").tabs("option", "disabled", [1]); + // Active tabs. + $("#tabs-sound-modal").tabs("option", "active", 0); + // Change mode. + $("#hidden-mode_alert").val(0); + // Change img button. + $("#button-start-search") + .removeClass("stop") + .addClass("play"); + // Change value button. + $("#button-start-search").val(settings.start); + // Remove progress bar. + $("#progressbar_time").empty(); + // Remove audio. + remove_audio(); + // Clean events. + $("#tabs-sound-modal .elements-discovered-alerts ul").empty(); + $("#tabs-sound-modal .empty-discovered-alerts").removeClass( + "invisible_important" + ); + // Change img button. + $("#button-no-alerts") + .removeClass("silence-alerts") + .addClass("alerts"); + // Change value button. + $("#button-no-alerts").val(settings.noAlert); + + // Background button. + $(".container-button-alert").removeClass("fired"); + } +} + +function add_audio() { + var sound = "./include/sounds/" + $("#tabs-sound-modal #sound_id").val(); + $(".actions-sound-modal").append( + "