Merge branch 'ent-12607-faltan-botones-de-desacoplar-y-minimizar-en-consola-sonora-command-center' into 'develop'
fix error js load modal filter sound events pandora_enterprise#12607 See merge request artica/pandorafms!6739
This commit is contained in:
commit
8658dbc938
|
@ -542,7 +542,7 @@ if ($load_filter_modal) {
|
|||
);
|
||||
|
||||
$action = 'index.php?sec=eventos&sec2=operation/events/events&pure=';
|
||||
if ($settings_modal !== 0 && $parameters_modal !== 0) {
|
||||
if ($settings_modal != 0 && $parameters_modal != 0) {
|
||||
$action .= '&settings='.$settings_modal.'¶meters='.$parameters_modal;
|
||||
}
|
||||
|
||||
|
@ -2644,8 +2644,8 @@ if ($get_events_fired) {
|
|||
// Set time.
|
||||
$filter['event_view_hr'] = 0;
|
||||
|
||||
$start = (time() - $interval);
|
||||
$end = time();
|
||||
$start = ((time() - $interval) + 1);
|
||||
$end = (time() + 1);
|
||||
|
||||
$filter['date_from'] = date('Y-m-d', $start);
|
||||
$filter['date_to'] = date('Y-m-d', $end);
|
||||
|
|
|
@ -2600,6 +2600,16 @@ function showPeriodicityOptions(element) {
|
|||
}
|
||||
}
|
||||
|
||||
function checkExistParameterUrl(url, parameter) {
|
||||
var regex = new RegExp(
|
||||
"[?&]" + encodeURIComponent(parameter) + "(=([^&#]*)|&|#|$)"
|
||||
);
|
||||
|
||||
var exists = regex.exec(url);
|
||||
|
||||
return exists;
|
||||
}
|
||||
|
||||
function christmas_click(flagEasternEgg) {
|
||||
let counter = $("#count_click").val();
|
||||
counter++;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*global jQuery, $, forced_title_callback, confirmDialog, progressTimeBar*/
|
||||
/*global jQuery, $, forced_title_callback, confirmDialog, progressTimeBar, checkExistParameterUrl*/
|
||||
|
||||
// Show the modal window of an event
|
||||
function show_event_dialog(event, dialog_page) {
|
||||
|
@ -975,9 +975,32 @@ function process_buffers(buffers) {
|
|||
}
|
||||
}
|
||||
|
||||
function openSoundEventsDialogModal(settings, dialog_parameters, reload) {
|
||||
function changeUrlParameterForModalSound(settings, filter_id) {
|
||||
/*
|
||||
Basicamente esta funcion lo que hace es: cuando activas el modal sound
|
||||
y das al start para empezar a filtrar lo que hace es mirar si paras o arrancas
|
||||
con el mode y settear en la url los settings necesarios para iniciar el modal,
|
||||
si estaba en star añadira los parametros y si estaba parado los quitara,
|
||||
con esto se consigue que si se hace f5 o reload en la pagina mantenga la busqueda.
|
||||
*/
|
||||
let mode = $("#hidden-mode_alert").val();
|
||||
if (reload != false) {
|
||||
if ("history" in window) {
|
||||
let href = window.location.href;
|
||||
if (checkExistParameterUrl(href, "settings") === null) {
|
||||
href += "&settings=1";
|
||||
}
|
||||
|
||||
var regex_settings = /(settings=)[^&]+(&?)/gi;
|
||||
var replacement_settings = "$1" + settings + "$2";
|
||||
href = href.replace(regex_settings, replacement_settings);
|
||||
|
||||
if (checkExistParameterUrl(href, "filter_id") === null) {
|
||||
href += "&filter_id=1";
|
||||
}
|
||||
|
||||
var regex_filter_id = /(filter_id=)[^&]+(&?)/gi;
|
||||
var replacement_filter_id = "$1" + filter_id + "$2";
|
||||
href = href.replace(regex_filter_id, replacement_filter_id);
|
||||
if (mode == 0) {
|
||||
let filter_id = $("#filter_id option:selected").val();
|
||||
let interval = $("#interval option:selected").val();
|
||||
|
@ -992,25 +1015,34 @@ function openSoundEventsDialogModal(settings, dialog_parameters, reload) {
|
|||
};
|
||||
parameters = JSON.stringify(parameters);
|
||||
parameters = btoa(parameters);
|
||||
let url =
|
||||
window.location + "&settings=" + settings + "¶meters=" + parameters;
|
||||
$(location).attr("href", url);
|
||||
|
||||
if (checkExistParameterUrl(href, "parameters") === null) {
|
||||
href += "¶meters=1";
|
||||
}
|
||||
|
||||
var regex_parameters = /(parameters=)[^&]+(&?)/gi;
|
||||
var replacement_parameters = "$1" + parameters + "$2";
|
||||
href = href.replace(regex_parameters, replacement_parameters);
|
||||
} else {
|
||||
let url = window.location + "&settings=" + settings;
|
||||
$(location).attr("href", url);
|
||||
if (checkExistParameterUrl(href, "parameters") !== null) {
|
||||
var regex = new RegExp(
|
||||
"([?&])" + encodeURIComponent("parameters") + "=[^&]*(&|$)",
|
||||
"i"
|
||||
);
|
||||
href = href.replace(regex, "$1");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
openSoundEventsDialog(settings, dialog_parameters, reload);
|
||||
|
||||
window.history.replaceState({}, document.title, href);
|
||||
}
|
||||
}
|
||||
|
||||
function openSoundEventsDialog(settings, dialog_parameters, reload) {
|
||||
function openSoundEventsDialog(settings, dialog_parameters) {
|
||||
let encode_settings = settings;
|
||||
if (reload == undefined) {
|
||||
reload = true;
|
||||
}
|
||||
if (dialog_parameters != undefined) {
|
||||
if (dialog_parameters != undefined && dialog_parameters) {
|
||||
dialog_parameters = JSON.parse(atob(dialog_parameters));
|
||||
} else {
|
||||
dialog_parameters = undefined;
|
||||
}
|
||||
settings = JSON.parse(atob(settings));
|
||||
// Check modal exists and is open.
|
||||
|
@ -1063,9 +1095,8 @@ function openSoundEventsDialog(settings, dialog_parameters, reload) {
|
|||
|
||||
// Play Stop.
|
||||
$("#button-start-search").click(function() {
|
||||
if (reload == true) {
|
||||
openSoundEventsDialogModal(encode_settings, 0, reload);
|
||||
}
|
||||
var id_filter_event = $("#hidden-id_filter_event").val();
|
||||
changeUrlParameterForModalSound(encode_settings, id_filter_event);
|
||||
var mode = $("#hidden-mode_alert").val();
|
||||
var action = false;
|
||||
if (mode == 0) {
|
||||
|
@ -1094,7 +1125,7 @@ function openSoundEventsDialog(settings, dialog_parameters, reload) {
|
|||
action_events_sound(action, settings);
|
||||
});
|
||||
|
||||
if (reload == false && dialog_parameters != undefined) {
|
||||
if (dialog_parameters != undefined) {
|
||||
if ($("#button-start-search").hasClass("play")) {
|
||||
$("#filter_id").val(dialog_parameters.filter_id);
|
||||
$("#interval").val(dialog_parameters.interval);
|
||||
|
@ -1150,6 +1181,25 @@ function openSoundEventsDialog(settings, dialog_parameters, reload) {
|
|||
$("#minimize_arrow_event_sound").hide();
|
||||
remove_audio();
|
||||
$(this).dialog("destroy");
|
||||
|
||||
let href = window.location.href;
|
||||
if (checkExistParameterUrl(href, "parameters") !== null) {
|
||||
var regex_parameter = new RegExp(
|
||||
"([?&])" + encodeURIComponent("parameters") + "=[^&]*(&|$)",
|
||||
"i"
|
||||
);
|
||||
href = href.replace(regex_parameter, "$1");
|
||||
}
|
||||
|
||||
if (checkExistParameterUrl(href, "settings") !== null) {
|
||||
var regex_settings = new RegExp(
|
||||
"([?&])" + encodeURIComponent("settings") + "=[^&]*(&|$)",
|
||||
"i"
|
||||
);
|
||||
href = href.replace(regex_settings, "$1");
|
||||
}
|
||||
|
||||
window.history.replaceState({}, document.title, href);
|
||||
}
|
||||
})
|
||||
.show();
|
||||
|
@ -1723,43 +1773,12 @@ $(document).ajaxSend(function(event, jqXHR, ajaxOptions) {
|
|||
"display",
|
||||
"none"
|
||||
);
|
||||
|
||||
// Handle the 'change' event for #modal-sound, simply to compact the size of the img "No alerts discovered"
|
||||
// An image should always have a size assigned!!!
|
||||
$("#modal-sound").on("change", function() {
|
||||
// Find the image within the specific div
|
||||
var image = $(this).find(
|
||||
'img.invert_filter.forced_title[data-title="No alerts discovered"][alt="No alerts discovered"]'
|
||||
);
|
||||
|
||||
// Set the desired width and height
|
||||
var width = 48;
|
||||
var height = 48;
|
||||
|
||||
// Resize the image
|
||||
image.width(width);
|
||||
image.height(height);
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
|
||||
function loadModal() {
|
||||
const urlSearch = window.location.search;
|
||||
const urlParams = new URLSearchParams(urlSearch);
|
||||
if (urlParams.has("settings")) {
|
||||
let modal_parameters = "";
|
||||
if (urlParams.has("parameters")) {
|
||||
modal_parameters = urlParams.get("parameters");
|
||||
}
|
||||
let settings = urlParams.get("settings");
|
||||
openSoundEventsDialogModal(settings, modal_parameters, false);
|
||||
}
|
||||
}
|
||||
window.onload = loadModal;
|
||||
|
||||
function openEvents(severity) {
|
||||
$('input[name="filter[severity]"]').val(severity);
|
||||
$("#event_redirect").submit();
|
||||
|
|
|
@ -3431,8 +3431,6 @@ $(document).ready( function() {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
/* Update summary */
|
||||
$("#status").on("change",function(){
|
||||
$('#summary_status').html($("#status option:selected").text());
|
||||
|
@ -3564,7 +3562,6 @@ $(document).ready( function() {
|
|||
show_events_graph();
|
||||
});
|
||||
|
||||
|
||||
//Autorefresh in fullscreen
|
||||
var pure = '<?php echo $pure; ?>';
|
||||
var pure = '<?php echo $pure; ?>';
|
||||
|
@ -3632,6 +3629,16 @@ $(document).ready( function() {
|
|||
|
||||
}
|
||||
|
||||
const urlSearch = window.location.search;
|
||||
const urlParams = new URLSearchParams(urlSearch);
|
||||
if (urlParams.has("settings")) {
|
||||
let modal_parameters = "";
|
||||
if (urlParams.has("parameters")) {
|
||||
modal_parameters = urlParams.get("parameters");
|
||||
}
|
||||
let settings = urlParams.get("settings");
|
||||
openSoundEventsDialog(settings, modal_parameters);
|
||||
}
|
||||
});
|
||||
|
||||
function checked_slide_events(element) {
|
||||
|
|
|
@ -77,6 +77,7 @@ echo '<link rel="stylesheet" href="../../include/styles/pandora.css" type="text/
|
|||
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);
|
||||
echo ui_require_css_file('events', 'include/styles/', true);
|
||||
|
||||
echo '<script type="text/javascript" src="../../include/javascript/jquery.current.js"></script>';
|
||||
echo '<script type="text/javascript" src="../../include/javascript/jquery.pandora.js"></script>';
|
||||
|
@ -126,7 +127,7 @@ $output = '<div id="tabs-sound-modal">';
|
|||
$output .= '</ul>';
|
||||
|
||||
// Content tabs.
|
||||
$output .= '<div id="tabs-sound-modal-1">';
|
||||
$output .= '<div id="tabs-sound-modal-1" style="height: 350px;">';
|
||||
$output .= '<h3 class="title-discovered-alerts">';
|
||||
$output .= __('Console configuration').ui_print_help_tip(__('Warning: Minimizing this window will cause the Acoustic Console to not work as expected'), true);
|
||||
$output .= '</h3>';
|
||||
|
@ -251,7 +252,7 @@ $output = '<div id="tabs-sound-modal">';
|
|||
);
|
||||
$output .= '</div>';
|
||||
|
||||
$output .= '<div id="tabs-sound-modal-2" style="height: 290px;">';
|
||||
$output .= '<div id="tabs-sound-modal-2" style="height: 350px;">';
|
||||
$output .= '<h3 class="title-discovered-alerts">';
|
||||
$output .= __('Discovered alerts');
|
||||
$output .= '</h3>';
|
||||
|
@ -268,7 +269,7 @@ $output = '<div id="tabs-sound-modal">';
|
|||
$output .= __('Congrats! there’s nothing to show');
|
||||
$output .= '</span>';
|
||||
$output .= '</div>';
|
||||
$output .= '<div class="elements-discovered-alerts" style="max-height:250px !important;"><ul></ul></div>';
|
||||
$output .= '<div class="elements-discovered-alerts" style="max-height:315px !important;"><ul></ul></div>';
|
||||
$output .= html_print_input_hidden(
|
||||
'ajax_file_sound_console',
|
||||
ui_get_full_url('ajax.php', false, false, false),
|
||||
|
@ -430,6 +431,36 @@ function listen_event_sound() {
|
|||
}
|
||||
|
||||
function check_event_sound() {
|
||||
$(".elements-discovered-alerts ul li").each(function() {
|
||||
let element_time = $(this)
|
||||
.children(".li-hidden")
|
||||
.val();
|
||||
let obj_time = new Date(element_time);
|
||||
let current_dt = new Date();
|
||||
let timestamp = current_dt.getTime() - obj_time.getTime();
|
||||
timestamp = timestamp / 1000;
|
||||
if (timestamp <= 60) {
|
||||
timestamp = Math.round(timestamp) + " seconds";
|
||||
} else if (timestamp <= 3600) {
|
||||
let minute = Math.floor((timestamp / 60) % 60);
|
||||
minute = minute < 10 ? "0" + minute : minute;
|
||||
let second = Math.floor(timestamp % 60);
|
||||
second = second < 10 ? "0" + second : second;
|
||||
timestamp = minute + " minutes " + second + " seconds";
|
||||
} else {
|
||||
let hour = Math.floor(timestamp / 3600);
|
||||
hour = hour < 10 ? "0" + hour : hour;
|
||||
let minute = Math.floor((timestamp / 60) % 60);
|
||||
minute = minute < 10 ? "0" + minute : minute;
|
||||
let second = Math.round(timestamp % 60);
|
||||
second = second < 10 ? "0" + second : second;
|
||||
timestamp = hour + " hours " + minute + " minutes " + second + " seconds";
|
||||
}
|
||||
$(this)
|
||||
.children(".li-time")
|
||||
.children("span")
|
||||
.html(timestamp);
|
||||
});
|
||||
jQuery.post(
|
||||
$('#hidden-ajax_file_sound_console').val(),
|
||||
{
|
||||
|
@ -465,6 +496,7 @@ function check_event_sound() {
|
|||
|
||||
// Add elements.
|
||||
data.forEach(function(element) {
|
||||
console.log(element);
|
||||
var li = document.createElement("li");
|
||||
var b64 = btoa(JSON.stringify(element));
|
||||
li.insertAdjacentHTML(
|
||||
|
@ -483,7 +515,11 @@ function check_event_sound() {
|
|||
"beforeend",
|
||||
'<div class="li-time">' + element.timestamp + "</div>"
|
||||
);
|
||||
$("#tabs-sound-modal .elements-discovered-alerts ul").append(li);
|
||||
li.insertAdjacentHTML(
|
||||
"beforeend",
|
||||
'<input type="hidden" value="' + element.event_timestamp + '" class="li-hidden"/>'
|
||||
);
|
||||
$("#tabs-sound-modal .elements-discovered-alerts ul").prepend(li);
|
||||
});
|
||||
|
||||
// -100 delay sound.
|
||||
|
|
Loading…
Reference in New Issue