#10639 new datepicker style and save filter

This commit is contained in:
Jonathan 2023-08-29 12:17:41 +02:00
parent c7a55e6a0b
commit 84bb4780ca
5 changed files with 127 additions and 24 deletions

View File

@ -10,4 +10,26 @@ UPDATE tagente_modulo SET `tcp_send` = '2c' WHERE `tcp_send` = '2';
UPDATE tpolicy_modules SET `tcp_send` = '2c' WHERE `tcp_send` = '2';
UPDATE tnetwork_component SET `tcp_send` = '2c' WHERE `tcp_send` = '2';
ALTER TABLE `tsesion_filter_log_viewer`
CHANGE COLUMN `date_range` `custom_date` INT NULL DEFAULT NULL ,
CHANGE COLUMN `start_date_defined` `date` VARCHAR(45) NULL DEFAULT NULL ,
CHANGE COLUMN `start_date_time` `date_text` VARCHAR(45) NULL DEFAULT NULL ,
CHANGE COLUMN `start_date_date` `date_units` VARCHAR(45) NULL DEFAULT NULL ,
CHANGE COLUMN `start_date_date_range` `date_init` VARCHAR(45) NULL DEFAULT NULL ,
CHANGE COLUMN `start_date_time_range` `time_init` VARCHAR(45) NULL DEFAULT NULL ,
CHANGE COLUMN `end_date_date_range` `date_end` VARCHAR(45) NULL DEFAULT NULL ,
CHANGE COLUMN `end_date_time_range` `time_end` VARCHAR(45) NULL DEFAULT NULL ;
ALTER TABLE `tsesion_filter`
CHANGE COLUMN `period` `date_text` VARCHAR(45) NULL DEFAULT NULL AFTER `user`;
ALTER TABLE `tsesion_filter`
ADD COLUMN `custom_date` INT NULL AFTER `user`,
ADD COLUMN `date` VARCHAR(45) NULL AFTER `custom_date`,
ADD COLUMN `date_units` VARCHAR(45) NULL AFTER `date_text`,
ADD COLUMN `date_init` VARCHAR(45) NULL AFTER `date_units`,
ADD COLUMN `time_init` VARCHAR(45) NULL AFTER `date_init`,
ADD COLUMN `date_end` VARCHAR(45) NULL AFTER `time_init`,
ADD COLUMN `time_end` VARCHAR(45) NULL AFTER `date_end`;
COMMIT;

View File

@ -58,7 +58,14 @@ if ($save_log_filter) {
$values = [];
$values['id_name'] = get_parameter('id_name');
$values['text'] = get_parameter('text', '');
$values['period'] = get_parameter('period', '');
$values['custom_date'] = get_parameter('custom_date');
$values['date'] = get_parameter('date');
$values['date_text'] = get_parameter('date_text');
$values['date_units'] = get_parameter('date_units');
$values['date_init'] = get_parameter('date_init');
$values['time_init'] = get_parameter('time_init');
$values['date_end'] = get_parameter('date_end');
$values['time_end'] = get_parameter('time_end');
$values['ip'] = get_parameter('ip', '');
$values['type'] = get_parameter('type', -1);
$values['user'] = get_parameter('user', -1);
@ -91,7 +98,14 @@ if ($update_log_filter) {
$values = [];
$id = get_parameter('id');
$values['text'] = get_parameter('text', '');
$values['period'] = get_parameter('period', '');
$values['custom_date'] = get_parameter('custom_date');
$values['date'] = get_parameter('date');
$values['date_text'] = get_parameter('date_text');
$values['date_units'] = get_parameter('date_units');
$values['date_init'] = get_parameter('date_init');
$values['time_init'] = get_parameter('time_init');
$values['date_end'] = get_parameter('date_end');
$values['time_end'] = get_parameter('time_end');
$values['ip'] = get_parameter('ip', '');
$values['type'] = get_parameter('type', -1);
$values['user'] = get_parameter('user', -1);
@ -211,18 +225,42 @@ function load_filter_values() {
$.each(data,function(i,value){
if (i == 'text'){
$("#text-filter_text").val(value);
}
if (i == 'period'){
$("#filter_period").val(value).change();
}
if (i == 'ip'){
} else if (i == 'ip'){
$("#text-filter_ip").val(value);
}
if (i == 'type'){
} else if (i == 'type'){
$("#filter_type").val(value).change();
}
if (i == 'user'){
} else if (i == 'user'){
$("#filter_user").val(value).change();
} else if (i == 'custom_date'){
$('#hidden-custom_date').val(value).change();
if ($('#hidden-custom_date').val()==='0'){
$('#date_default').show();
$('#date_range').hide();
$('#date_extend').hide();
$('#date').val('".SECONDS_1DAY."').trigger('change');
} else if ($('#hidden-custom_date').val()==='1'){
$('#date_range').show();
$('#date_default').hide();
$('#date_extend').hide();
} else {
$('#date_range').hide();
$('#date_default').hide();
$('#date_extend').show();
}
} else if (i == 'date'){
$('#date').val(value).change();
} else if (i == 'date_end'){
$('#text-date_end').val(value);
} else if (i == 'date_init'){
$('#text-date_init').val(value);
} else if (i == 'date_text'){
$('#text-date_text').val(value);
} else if (i == 'date_units'){
$('#date_units').val(value).change();
} else if (i == 'time_end'){
$('#text-time_end').val(value);
} else if (i == 'time_init'){
$('#text-time_init').val(value);
}
});
}
@ -408,7 +446,14 @@ function save_new_filter() {
"save_log_filter" : 1,
"id_name" : $("#text-id_name").val(),
"text" : $("#text-filter_text").val(),
"period" : $("#filter_period :selected").val(),
"custom_date": $('#hidden-custom_date').val(),
"date": $('#date option:selected').val(),
"date_text": $('#text-date_text').val(),
"date_units": $('#date_units option:selected').val(),
"date_init": $('#text-date_init').val(),
"time_init": $('#text-time_init').val(),
"date_end": $('#text-date_end').val(),
"time_end": $('#text-time_end').val(),
"ip" : $('#text-filter_ip').val(),
"type" : $('#filter_type :selected').val(),
"user" : $('#filter_user :selected').val(),
@ -444,7 +489,14 @@ function save_update_filter() {
"update_log_filter" : 1,
"id" : $("#overwrite_filter :selected").val(),
"text" : $("#text-filter_text").val(),
"period" : $("#filter_period :selected").val(),
"custom_date": $('#hidden-custom_date').val(),
"date": $('#date option:selected').val(),
"date_text": $('#text-date_text').val(),
"date_units": $('#date_units option:selected').val(),
"date_init": $('#text-date_init').val(),
"time_init": $('#text-time_init').val(),
"date_end": $('#text-date_end').val(),
"time_end": $('#text-time_end').val(),
"ip" : $('#text-filter_ip').val(),
"type" : $('#filter_type :selected').val(),
"user" : $('#filter_user :selected').val(),

View File

@ -7393,8 +7393,21 @@ function html_print_select_date_range(
$('#back_default, #back_default_extend').click(function(){
display_default();
});
// To get position must to be showed, hide elements return 0 on offset function.
$('#".$name."_range').show();
$('#".$name."_default').hide();
$('#".$name."_extend').hide();
position_top_init = $('#text-date_init').offset().top + $('#text-date_init').outerHeight();
position_top_end = $('#text-date_end').offset().top + $('#text-date_end').outerHeight();
$('#".$name."_range').hide();
$('#".$name."_extend').hide();
$('#".$name."_default').show();
});
var position_top_init = 0;
var position_top_end = 0;
function display_default(){
$('#".$name."_default').show();
$('#".$name."_range').hide();
@ -7429,6 +7442,7 @@ function html_print_select_date_range(
showAnim: 'slideDown',
firstDay: ".$config['datepicker_first_day'].",
beforeShowDay: function (date) {
show_datepicker = 'date_init';
var date_now = date.getTime();
var date_ini_split = $('[id^=text-date_init]').val().split('/');
var date_ini = new Date(date_ini_split[1]+'/'+date_ini_split[2]+'/'+date_ini_split[0]).getTime();
@ -7450,6 +7464,7 @@ function html_print_select_date_range(
showAnim: 'slideDown',
firstDay: ".$config['datepicker_first_day'].",
beforeShowDay: function (date) {
show_datepicker = 'date_end';
var date_now = date.getTime();
var date_ini_split = $('[id^=text-date_init]').val().split('/');
var date_ini = new Date(date_ini_split[1]+'/'+date_ini_split[2]+'/'+date_ini_split[0]).getTime();
@ -7479,8 +7494,15 @@ function html_print_select_date_range(
$(window).scroll(function(e){
if ($('#date option:selected').val() == 'chose_range'){
if ($('#ui-datepicker-div').html() !== '') {
var css_datepicker = $('#ui-datepicker-div').attr('style').replace('absolute','fixed');
if ($(this).scrollTop() > 0){
var css_datepicker = $('#ui-datepicker-div').attr('style').replace('absolute','fixed');
if (!css_datepicker.includes('px !important')) {
if (show_datepicker == 'date_end'){
css_datepicker += '; top: '+position_top_end+'px !important';
} else {
css_datepicker += '; top: '+position_top_init+'px !important';
}
}
$('#ui-datepicker-div').attr('style', css_datepicker);
}
}

View File

@ -295,7 +295,7 @@ if ($html_menu_export === ENTERPRISE_NOT_HOOK) {
}
$table2->data[0][2] .= html_print_label_input_block(
$table2->data[0][2] = html_print_label_input_block(
__('Date').':<br>',
html_print_select_date_range('date', true, get_parameter('date', SECONDS_1DAY), $date_init, $time_init, date('Y/m/d'), date('H:i:s'), $date_text)
);

View File

@ -4276,10 +4276,17 @@ CREATE TABLE IF NOT EXISTS `tsesion_filter` (
`id_filter` INT NOT NULL AUTO_INCREMENT,
`id_name` TEXT NULL,
`text` TEXT NULL,
`period` TEXT NULL,
`ip` TEXT NULL,
`type` TEXT NULL,
`user` TEXT NULL,
`custom_date` INT NULL,
`date` VARCHAR(45) NULL,
`date_text` VARCHAR(45) NULL,
`date_units` VARCHAR(45) NULL,
`date_init` VARCHAR(45) NULL,
`time_init` VARCHAR(45) NULL,
`date_end` VARCHAR(45) NULL,
`time_end` VARCHAR(45) NULL,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
@ -4331,14 +4338,14 @@ CREATE TABLE IF NOT EXISTS `tsesion_filter_log_viewer` (
`order` VARCHAR(45) NULL,
`search` VARCHAR(255) NULL,
`group_id` INT NULL,
`date_range` TINYINT NULL,
`start_date_defined` VARCHAR(45) NULL,
`start_date_time` VARCHAR(45) NULL,
`start_date_date` VARCHAR(45) NULL,
`start_date_date_range` VARCHAR(45) NULL,
`start_date_time_range` VARCHAR(45) NULL,
`end_date_date_range` VARCHAR(45) NULL,
`end_date_time_range` VARCHAR(45) NULL,
`custom_date` INT NULL,
`date` VARCHAR(45) NULL,
`date_text` VARCHAR(45) NULL,
`date_units` VARCHAR(45) NULL,
`date_init` VARCHAR(45) NULL,
`time_init` VARCHAR(45) NULL,
`date_end` VARCHAR(45) NULL,
`time_end` VARCHAR(45) NULL,
`agent` VARCHAR(255) NULL,
`source` VARCHAR(255) NULL,
`display_mode` INT NULL,