From 3a96c60bac9ac053abf1d31276f3f377931cd4e6 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 11 Apr 2023 13:50:11 +0200 Subject: [PATCH 1/5] #10191 new event sound modal --- pandora_console/include/ajax/events.php | 2 +- .../include/javascript/pandora_events.js | 15 +- .../include/styles/sound_events.css | 4 - pandora_console/operation/events/events.php | 106 +++ .../operation/events/sound_events.php | 712 +++++++++++------- 5 files changed, 558 insertions(+), 281 deletions(-) diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 8b3c15751b..f03c8af06b 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -2406,7 +2406,7 @@ if ($drawConsoleSound === true) { 'Star_Trek_emergency_simulation.wav' => 'StarTrek emergency simulation', ]; - $eventsounds = mysql_db_get_all_rows_sql('SELECT * FROM tevent_sound WHERE active = 1'); + $eventsounds = db_get_all_rows_sql('SELECT * FROM tevent_sound WHERE active = 1'); foreach ($eventsounds as $key => $row) { $sounds[$row['sound']] = $row['name']; } diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 2f657779a6..74049462a1 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -947,8 +947,21 @@ function process_buffers(buffers) { } function openSoundEventModal(settings) { - settings = JSON.parse(atob(settings)); + var win = open( + "http://172.16.0.2/pandora_console/operation/events/sound_events.php", + "day_123", + "width=600,height=500" + ); + if (win) { + //Browser has allowed it to be opened + win.focus(); + } else { + //Browser has blocked it + alert("Please allow popups for this website"); + } + settings = JSON.parse(atob(settings)); + console.log(settings); // Check modal exists and is open. if ( $("#modal-sound").hasClass("ui-dialog-content") && diff --git a/pandora_console/include/styles/sound_events.css b/pandora_console/include/styles/sound_events.css index 121b606d7e..5bab51a89d 100644 --- a/pandora_console/include/styles/sound_events.css +++ b/pandora_console/include/styles/sound_events.css @@ -231,10 +231,6 @@ div.container-button-play > button#button-start-search { border: 0; } -button#button-start-search:hover { - background-position: 82px 14px !important; -} - .actions-sound-modal .buttons-sound-modal button.alerts, .actions-sound-modal .buttons-sound-modal input[type="button"].alerts { width: 154px; diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 62a8850b80..2ed9d27e94 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -3006,6 +3006,11 @@ $(document).ready( function() { }); + var show_event_dialog = ""; + if (show_event_dialog !== ''){ + show_event_dialo(show_event_dialog); + } + /* Multi select handler */ $('#checkbox-all_validate_box').on('change', function() { if($('#checkbox-all_validate_box').is(":checked")) { @@ -3250,4 +3255,105 @@ $(document).ready(function () { $('.white_table_graph_header').first().append($('.filter_summary')); }); + +// Show the modal window of an event +function show_event_dialo(event, dialog_page) { + var ajax_file = getUrlAjax(); + + var view = ``; + + if ($("#event_details_window").length) { + view = "#event_details_window"; + } else if ($("#sound_event_details_window").length) { + view = "#sound_event_details_window"; + } + + if (dialog_page == undefined) { + dialog_page = "general"; + } + + try { + event = event.replaceAll(" ", "+"); + event = JSON.parse(atob(event), true); + } catch (e) { + console.error(e); + return; + } + + var inputs = $("#events_form :input"); + var values = {}; + inputs.each(function() { + values[this.name] = $(this).val(); + }); + + // Metaconsole mode flag + var meta = $("#hidden-meta").val(); + + // History mode flag + var history = $("#hidden-history").val(); + + jQuery.post( + ajax_file, + { + page: "include/ajax/events", + get_extended_event: 1, + dialog_page: dialog_page, + event: event, + meta: meta, + history: history, + filter: values + }, + function(data) { + $(view) + .hide() + .empty() + .append(data) + .dialog({ + title: event.evento, + resizable: true, + draggable: true, + modal: true, + minWidth: 875, + minHeight: 600, + close: function() { + $("#refrcounter").countdown("resume"); + $("div.vc-countdown").countdown("resume"); + }, + overlay: { + opacity: 0.5, + background: "black" + }, + width: 710, + height: 650, + autoOpen: true, + open: function() { + if ( + $.ui && + $.ui.dialog && + $.ui.dialog.prototype._allowInteraction + ) { + var ui_dialog_interaction = + $.ui.dialog.prototype._allowInteraction; + $.ui.dialog.prototype._allowInteraction = function(e) { + if ($(e.target).closest(".select2-dropdown").length) + return true; + return ui_dialog_interaction.apply(this, arguments); + }; + } + }, + _allowInteraction: function(event) { + return !!$(event.target).is(".select2-input") || this._super(event); + } + }) + .show(); + + $("#refrcounter").countdown("pause"); + $("div.vc-countdown").countdown("pause"); + + forced_title_callback(); + }, + "html" + ); + return false; +} diff --git a/pandora_console/operation/events/sound_events.php b/pandora_console/operation/events/sound_events.php index f2a8c62432..efcbef4ab9 100644 --- a/pandora_console/operation/events/sound_events.php +++ b/pandora_console/operation/events/sound_events.php @@ -160,315 +160,477 @@ if ($config['style'] === 'pandora_black' && !is_metaconsole()) { } echo ''; -echo ""; -echo "

".__('Accoustic console').'

'; +echo ''; +echo ui_require_css_file('wizard', 'include/styles/', true); +echo ui_require_css_file('discovery', 'include/styles/', true); +echo ui_require_css_file('sound_events', 'include/styles/', true); +$output = '
'; + // Header tabs. + $output .= ''; -// Connection lost alert. -ui_require_css_file('register', 'include/styles/', true); -$conn_title = __('Connection with server has been lost'); -$conn_text = __('Connection to the server has been lost. Please check your internet connection or contact with administrator.'); -ui_require_javascript_file('connection_check'); -set_js_value('absolute_homeurl', ui_get_full_url(false, false, false, false)); -ui_print_message_dialog( - $conn_title, - $conn_text, - 'connection', - '/images/fail@svg.svg' -); + // Content tabs. + $output .= '
'; + $output .= '

'; + $output .= __('Console configuration'); + $output .= '

'; + $inputs = []; -$inputs = []; - -// Load filter. -$fields = \events_get_event_filter_select(); -$inputs[] = [ - 'label' => \__('Load filter'), - 'class' => 'flex-row', - 'arguments' => [ - 'type' => 'select', - 'fields' => $fields, - 'name' => 'filter_id', - 'selected' => 0, - 'return' => true, - 'nothing' => \__('All new events'), - 'nothing_value' => 0, - 'class' => 'fullwidth', - ], -]; - -$times_interval = [ - 10 => '10 '.__('seconds'), - 15 => '15 '.__('seconds'), - 30 => '30 '.__('seconds'), - 60 => '60 '.__('seconds'), -]; - -$times_sound = [ - 2 => '2 '.__('seconds'), - 5 => '5 '.__('seconds'), - 10 => '10 '.__('seconds'), - 15 => '15 '.__('seconds'), - 30 => '30 '.__('seconds'), - 60 => '60 '.__('seconds'), -]; - -$inputs[] = [ - 'class' => 'flex-row flex-row-center', - 'direct' => 1, - 'block_content' => [ - [ - 'label' => __('Interval'), + // Load filter. + $fields = \events_get_event_filter_select(); + $inputs[] = [ + 'label' => \__('Set condition'), 'arguments' => [ - 'type' => 'select', - 'fields' => $times_interval, - 'name' => 'interval', - 'selected' => 10, - 'return' => true, + 'type' => 'select', + 'fields' => $fields, + 'name' => 'filter_id', + 'selected' => 0, + 'return' => true, + 'nothing' => \__('All new events'), + 'nothing_value' => 0, + 'class' => 'fullwidth', ], - ], - [ - 'label' => __('Time Sound'), - 'arguments' => [ - 'type' => 'select', - 'fields' => $times_sound, - 'name' => 'time_sound', - 'selected' => 10, - 'return' => true, + ]; + + $times_interval = [ + 10 => '10 '.__('seconds'), + 15 => '15 '.__('seconds'), + 30 => '30 '.__('seconds'), + 60 => '60 '.__('seconds'), + ]; + + $times_sound = [ + 2 => '2 '.__('seconds'), + 5 => '5 '.__('seconds'), + 10 => '10 '.__('seconds'), + 15 => '15 '.__('seconds'), + 30 => '30 '.__('seconds'), + 60 => '60 '.__('seconds'), + ]; + + $inputs[] = [ + 'class' => 'interval-sounds', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Interval'), + 'arguments' => [ + 'type' => 'select', + 'fields' => $times_interval, + 'name' => 'interval', + 'selected' => 10, + 'return' => true, + ], + ], + [ + 'label' => __('Sound duration'), + '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', -]; + $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', + ]; -$eventsounds = mysql_db_get_row_sql('SELECT * FROM tevent_sound WHERE active = 1'); -foreach ($eventsounds as $key => $row) { - $sounds[$row['sound']] = $row['name']; -} + $eventsounds = db_get_all_rows_sql('SELECT * FROM tevent_sound WHERE active = 1'); + foreach ($eventsounds as $key => $row) { + $sounds[$row['sound']] = $row['name']; + } -$inputs[] = [ - 'label' => \__('Sounds'), - 'class' => 'flex-row', - 'arguments' => [ - 'type' => 'select', - 'fields' => $sounds, - 'name' => 'sound_id', - 'selected' => 'Star_Trek_emergency_simulation.wav', - 'return' => true, - 'class' => 'fullwidth', - ], -]; + $inputs[] = [ + 'class' => 'test-sounds', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => \__('Sound melody'), + 'arguments' => [ + 'type' => 'select', + 'fields' => $sounds, + 'name' => 'sound_id', + 'selected' => 'Star_Trek_emergency_simulation.wav', + 'return' => true, + 'class' => 'fullwidth', + ], + ], + [ + 'arguments' => [ + 'type' => 'button', + 'name' => 'melody_sound', + 'label' => __('Test sound'), + 'attributes' => ['icon' => 'sound'], + 'return' => true, + ], + ], + ], + ]; -// Print form. -HTML::printForm( - [ - 'form' => [ - 'action' => '', - 'method' => 'POST', - ], - 'inputs' => $inputs, - ], - false, - true -); + // Print form. + $output .= HTML::printForm( + [ + 'form' => [ + 'action' => '', + 'method' => 'POST', + ], + 'inputs' => $inputs, + ], + true, + false + ); + $output .= '
'; -$result = '
    '; -$result .= '
  • '; -$result .= ui_print_info_message(__('Events not found'), '', true); -$result .= '
  • '; -$result .= '
'; + $output .= '
'; + $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 .= html_print_input_hidden( + 'ajax_file_sound_console', + ui_get_full_url('ajax.php', false, false, false), + true + ); + $output .= html_print_input_hidden( + 'meta', + is_metaconsole(), + true + ); + $output .= '
    '; + $output .= '
    '; + $output .= '
    '; + $output .= '
    '; -$result .= '
    '; + $output .= '
    '; + $output .= '
    '; + $output .= '
    '; + $output .= html_print_button( + __('Start'), + 'start-search', + false, + '', + [ + 'icon' => 'cog', + 'class' => 'mrgn_lft_20px', + ], + true + ); + // $output .= html_print_submit_button( + // [ + // 'label' => __('Start'), + // 'type' => 'button', + // 'name' => 'start-search', + // 'attributes' => [ 'class' => 'play' ], + // 'return' => true, + // ], + // 'div', + // true + // ); + $output .= '
    '; + $output .= html_print_input( + [ + 'type' => 'button', + 'name' => 'no-alerts', + 'label' => __('No alerts'), + 'attributes' => ['class' => 'secondary alerts'], + 'return' => true, + ], + 'div', + true + ); + $output .= '
    '; -echo $result; - -$table = new StdClass; -$table->width = '100%'; -$table->class = 'sound_div_background text_center'; - -$table->data[0][0] = ''; -$table->data[0][0] .= html_print_image( - 'images/play.button.png', - true, - ['id' => 'button'] -); -$table->data[0][0] .= ''; - -$table->data[0][1] = ''; -$table->data[0][1] .= html_print_image( - 'images/ok.button.png', - true, - ['style' => 'margin-left: 15px;'] -); -$table->data[0][1] .= ''; - -$table->data[0][2] = ''; -$table->data[0][2] .= html_print_image( - 'images/icono_test.png', - true, - [ - 'id' => 'button_try', - 'style' => 'margin-left: 15px;', - ] -); -$table->data[0][2] .= ''; - -$table->data[0][3] = html_print_image( - 'images/tick_sound_events.png', - true, - [ - 'id' => 'button_status', - 'style' => 'margin-left: 15px;', - ] -); - -html_print_table($table); -?> + $output .= html_print_input( + [ + 'type' => 'hidden', + 'name' => 'mode_alert', + 'value' => 0, + 'return' => true, + ], + 'div', + true + ); + $output .= '
    '; + $output .= '
    '; + echo $output; + ?> Date: Tue, 11 Apr 2023 15:04:21 +0200 Subject: [PATCH 2/5] #10191 no show old sound event modal --- .../include/javascript/pandora_events.js | 97 ------------------- 1 file changed, 97 deletions(-) diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 74049462a1..e23b729984 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -961,7 +961,6 @@ function openSoundEventModal(settings) { } settings = JSON.parse(atob(settings)); - console.log(settings); // Check modal exists and is open. if ( $("#modal-sound").hasClass("ui-dialog-content") && @@ -969,102 +968,6 @@ function openSoundEventModal(settings) { ) { return; } - - // Initialize modal. - $("#modal-sound") - .empty() - .dialog({ - title: settings.title, - resizable: false, - modal: true, - position: { my: "right top", at: "right bottom", of: window }, - overlay: { - opacity: 0.5, - background: "black" - }, - width: 600, - height: 600, - open: function() { - $(".ui-widget-overlay") - .css("background", "black") - .css("opacity", 0.5); - $.ajax({ - method: "post", - url: settings.url, - data: { - page: settings.page, - drawConsoleSound: 1 - }, - dataType: "html", - success: function(data) { - $("#modal-sound").append(data); - $("#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, settings.urlSound); - }); - - // 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); - $("#button-no-alerts > span").text(settings.noAlert); - - // Background button. - $(".container-button-alert").removeClass("fired"); - - // New progress. - listen_event_sound(settings); - } - }); - }, - error: function(error) { - console.error(error); - } - }); - }, - close: function() { - remove_audio(); - $(this).dialog("destroy"); - } - }) - .show(); } function test_sound_button(test_sound, urlSound) { From b36ade1821d1723fc71a609e872a9e1e9279ac89 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 11 Apr 2023 16:24:37 +0200 Subject: [PATCH 3/5] #10191 fix url event sounds --- pandora_console/include/javascript/pandora_events.js | 2 +- pandora_console/operation/events/sound_events.php | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index e23b729984..3a043edf8e 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -948,7 +948,7 @@ function process_buffers(buffers) { function openSoundEventModal(settings) { var win = open( - "http://172.16.0.2/pandora_console/operation/events/sound_events.php", + "operation/events/sound_events.php", "day_123", "width=600,height=500" ); diff --git a/pandora_console/operation/events/sound_events.php b/pandora_console/operation/events/sound_events.php index efcbef4ab9..8633cadf86 100644 --- a/pandora_console/operation/events/sound_events.php +++ b/pandora_console/operation/events/sound_events.php @@ -534,7 +534,6 @@ function check_event_sound() { data.forEach(function(element) { var li = document.createElement("li"); var b64 = btoa(JSON.stringify(element)); - console.log(b64); li.insertAdjacentHTML( "beforeend", '
    ' + element.priority + "
    " @@ -545,7 +544,7 @@ function check_event_sound() { ); li.insertAdjacentHTML( "beforeend", - `` + `` ); li.insertAdjacentHTML( "beforeend", @@ -566,8 +565,7 @@ function check_event_sound() { } function open_window_dialog(data) { - console.log(data); - window.open('http://172.16.0.2/pandora_console/index.php?sec=eventos&sec2=operation/events/events&show_event_dialog='+data); + window.open(window.location.origin+'/pandora_console/index.php?sec=eventos&sec2=operation/events/events&show_event_dialog='+data); //show_event_dialog(data); } From a28aef4050f745b2639d773b739b1f5b83a2f76d Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 21 Apr 2023 08:48:19 +0200 Subject: [PATCH 4/5] #10191 fix url sound event on metaconsole --- .../include/javascript/pandora_events.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 3a043edf8e..e240ba6d8d 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -947,11 +947,19 @@ function process_buffers(buffers) { } function openSoundEventModal(settings) { - var win = open( - "operation/events/sound_events.php", - "day_123", - "width=600,height=500" - ); + if ($("#hidden-metaconsole_activated").val() === "1") { + var win = open( + "../../operation/events/sound_events.php", + "day_123", + "width=600,height=500" + ); + } else { + var win = open( + "operation/events/sound_events.php", + "day_123", + "width=600,height=500" + ); + } if (win) { //Browser has allowed it to be opened win.focus(); From f5c517ae7dea483a3d675f21e661574d23b3e38e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 21 Apr 2023 09:30:22 +0200 Subject: [PATCH 5/5] #10191 event sound fix select2 --- pandora_console/include/functions_ui.php | 2 +- pandora_console/operation/events/sound_events.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 11670b33f6..e0750a16ee 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -1744,7 +1744,7 @@ function ui_require_javascript_file($name, $path='include/javascript/', $echo_ta if (is_metaconsole() && (isset($config['requirements_use_base_url']) === false - || $config['requirements_use_base_url'] === false) + || $config['requirements_use_base_url'] === false) && $filename !== 'include/javascript/select2.min.js' ) { $config['js'][$name] = '../../'.$filename; } else { diff --git a/pandora_console/operation/events/sound_events.php b/pandora_console/operation/events/sound_events.php index 8633cadf86..f71dd0fa5d 100644 --- a/pandora_console/operation/events/sound_events.php +++ b/pandora_console/operation/events/sound_events.php @@ -582,7 +582,7 @@ $(document).ready(function(){ sound = true; } var urlSound = '../../include/sounds/'+$('#sound_id :selected').val(); - console.log(urlSound); + test_sound_button(sound, urlSound); });