From 3a96c60bac9ac053abf1d31276f3f377931cd4e6 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Tue, 11 Apr 2023 13:50:11 +0200 Subject: [PATCH] #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; + ?>