Added new date filters. Ticket #3946.

This commit is contained in:
Daniel Maya 2016-08-19 11:23:09 +02:00
parent f3f3b6704f
commit e32c606fb0
6 changed files with 79 additions and 25 deletions

View File

@ -52,3 +52,9 @@ ALTER TABLE tplanned_downtime_agents ADD COLUMN `manually_disabled` tinyint(1) D
-- Table `tlink`
-- ---------------------------------------------------------------------
UPDATE `tlink` SET `link` = 'http://library.pandorafms.com/' WHERE `name` = 'Module library';
-- ---------------------------------------------------------------------
-- Table `tevent_filter`
-- ---------------------------------------------------------------------
ALTER TABLE tevent_filter ADD COLUMN `date_from` date DEFAULT NULL;
ALTER TABLE tevent_filter ADD COLUMN `date_to` date DEFAULT NULL;

View File

@ -51,3 +51,9 @@ ALTER TABLE tplanned_downtime_agents ADD COLUMN manually_disabled NUMBER(5, 0) D
-- Table `tlink`
-- ---------------------------------------------------------------------
UPDATE tlink SET link = 'http://library.pandorafms.com/' WHERE name = 'Module library';
-- ---------------------------------------------------------------------
-- Table `tevent_filter`
-- ---------------------------------------------------------------------
ALTER TABLE tevent_filter ADD COLUMN date_from date DEFAULT NULL;
ALTER TABLE tevent_filter ADD COLUMN date_to date DEFAULT NULL;

View File

@ -58,7 +58,9 @@ if ($id) {
$event_view_hr = $filter['event_view_hr'];
$id_user_ack = $filter['id_user_ack'];
$group_rep = $filter['group_rep'];
$date_from = str_replace("-","/",$filter['date_from']);
$date_to = str_replace("-","/",$filter['date_to']);
$tag_with_json = $filter['tag_with'];
$tag_with_json_clean = io_safe_output($tag_with_json);
$tag_with_base64 = base64_encode($tag_with_json_clean) ;
@ -95,6 +97,9 @@ else {
$event_view_hr = '';
$id_user_ack = '';
$group_rep = '';
$date_from = '';
$date_to = '';
$tag_with_json = $tag_with_json_clean = json_encode(array());
$tag_with_base64 = base64_encode($tag_with_json);
$tag_without_json = $tag_without_json_clean = json_encode(array());
@ -117,7 +122,9 @@ if($update || $create) {
$event_view_hr = get_parameter('event_view_hr', '');
$id_user_ack = get_parameter('id_user_ack', '');
$group_rep = get_parameter('group_rep', '');
$date_from = get_parameter('date_from', '');
$date_to = get_parameter('date_to', '');
$tag_with_base64 = get_parameter('tag_with', json_encode(array()));
$tag_with_json = io_safe_input(base64_decode($tag_with_base64));
@ -143,6 +150,8 @@ if($update || $create) {
'group_rep' => $group_rep,
'tag_with' => $tag_with_json,
'tag_without' => $tag_without_json,
'date_from' => $date_from,
'date_to' => $date_to,
'filter_only_alert' => $filter_only_alert);
}
@ -289,6 +298,11 @@ $table->data[11][0] = '<b>' . __('Repeated') . '</b>';
$table->data[11][1] = html_print_select ($repeated_sel, "group_rep",
$group_rep, '', '', '', true);
$table ->data[12][0] = '<b>' . __('Date from') . '</b>';
$table ->data[12][1] = html_print_input_text ('date_from', $date_from, '', 15, 10, true);
$table ->data[13][0] = '<b>' . __('Date to') . '</b>';
$table ->data[13][1] = html_print_input_text ('date_to', $date_to, '', 15, 10, true);
$tag_with = json_decode($tag_with_json_clean, true);
if (empty($tag_with)) {
@ -328,38 +342,38 @@ $remove_with_tag_disabled = empty($tag_with_temp);
$add_without_tag_disabled = empty($tags_select_without);
$remove_without_tag_disabled = empty($tag_without_temp);
$table->colspan[13][0] = '2';
$table->data[13][0] = '<b>' . __('Events with following tags') . '</b>';
$table->data[14][0] = html_print_select ($tags_select_with, 'select_with',
$table->colspan[14][0] = '2';
$table->data[14][0] = '<b>' . __('Events with following tags') . '</b>';
$table->data[15][0] = html_print_select ($tags_select_with, 'select_with',
'', '', '', 0, true, false, true, '', false, 'width: 220px;');
$table->data[14][1] = html_print_button(__('Add'), 'add_whith',
$table->data[15][1] = html_print_button(__('Add'), 'add_whith',
$add_with_tag_disabled, '', 'class="add sub"', true);
$table->data[15][0] = html_print_select ($tag_with_temp,
$table->data[16][0] = html_print_select ($tag_with_temp,
'tag_with_temp', array(), '', '', 0, true, true,
true, '', false, "width: 220px; height: 50px;");
$table->data[15][0] .= html_print_input_hidden('tag_with',
$table->data[16][0] .= html_print_input_hidden('tag_with',
$tag_with_base64, true);
$table->data[15][1] = html_print_button(__('Remove'),
$table->data[16][1] = html_print_button(__('Remove'),
'remove_whith', $remove_with_tag_disabled, '', 'class="delete sub"', true);
$table->colspan[16][0] = '2';
$table->data[16][0] = '<b>' . __('Events without following tags') . '</b>';
$table->data[17][0] = html_print_select ($tags_select_without, 'select_without',
$table->colspan[17][0] = '2';
$table->data[17][0] = '<b>' . __('Events without following tags') . '</b>';
$table->data[18][0] = html_print_select ($tags_select_without, 'select_without',
'', '', '', 0, true, false, true, '', false, 'width: 220px;');
$table->data[17][1] = html_print_button(__('Add'), 'add_whithout',
$table->data[18][1] = html_print_button(__('Add'), 'add_whithout',
$add_without_tag_disabled, '', 'class="add sub"', true);
$table->data[18][0] = html_print_select ($tag_without_temp,
$table->data[19][0] = html_print_select ($tag_without_temp,
'tag_without_temp', array(), '', '', 0, true, true,
true, '', false, "width: 220px; height: 50px;");
$table->data[18][0] .= html_print_input_hidden('tag_without',
$table->data[19][0] .= html_print_input_hidden('tag_without',
$tag_without_base64, true);
$table->data[18][1] = html_print_button(__('Remove'), 'remove_whithout',
$table->data[19][1] = html_print_button(__('Remove'), 'remove_whithout',
$remove_without_tag_disabled, '', 'class="delete sub"', true);
$table->data[19][0] = '<b>' . __('Alert events') . '</b>';
$table->data[19][1] = html_print_select(
$table->data[20][0] = '<b>' . __('Alert events') . '</b>';
$table->data[20][1] = html_print_select(
array(
'-1' => __('All'),
'0' => __('Filter alert events'),
@ -368,8 +382,8 @@ $table->data[19][1] = html_print_select(
if (!is_metaconsole()) {
echo $id_agent_module;
$table->data[20][0] = '<b>' . __('Module search') . '</b>';
$table->data[20][1] .= html_print_autocomplete_modules('module_search',
$table->data[21][0] = '<b>' . __('Module search') . '</b>';
$table->data[21][1] .= html_print_autocomplete_modules('module_search',
$text_module, false, $id_agent_module, true, '', array(), true);
}
@ -405,6 +419,8 @@ var val_none = 0;
var text_none = "<?php echo __('None'); ?>";
$(document).ready( function() {
$("#text-date_from, #text-date_to").datepicker({dateFormat: "<?php echo DATE_FORMAT_JS; ?>"});
$("#button-add_whith").click(function() {
click_button_add_tag("with");
});

View File

@ -77,7 +77,9 @@ if (is_ajax()) {
$values['tag_without'] = get_parameter('tag_without', io_json_mb_encode(array()));
$values['filter_only_alert'] = get_parameter('filter_only_alert');
$values['id_group_filter'] = get_parameter('id_group_filter');
$values['date_from'] = get_parameter('date_from');
$values['date_to'] = get_parameter('date_to');
$exists = (bool)db_get_value_filter(
'id_filter', 'tevent_filter', $values);
@ -115,7 +117,9 @@ if (is_ajax()) {
$values['tag_without'] = get_parameter('tag_without', io_json_mb_encode(array()));
$values['filter_only_alert'] = get_parameter('filter_only_alert');
$values['id_group_filter'] = get_parameter('id_group_filter');
$values['date_from'] = get_parameter('date_from');
$values['date_to'] = get_parameter('date_to');
$result = db_process_sql_update('tevent_filter',
$values, array('id_filter' => $id));
@ -957,6 +961,20 @@ $(document).ready( function() {
$("#filter_only_alert").val(val);
if (i == 'id_group_filter')
$("#id_group_filter").val(val);
if (i == 'date_from'){
if((val == '0000-00-00') || (val == null)) {
$("#text-date_from").val('');
} else {
$("#text-date_from").val(val.replace(/\-/g,"/"));
}
}
if (i == 'date_to'){
if((val == '0000-00-00') || (val == null)) {
$("#text-date_to").val('');
} else {
$("#text-date_to").val(val.replace(/\-/g,"/"));
}
}
});
reorder_tags_inputs();
// Update the info with the loaded filter
@ -1020,7 +1038,9 @@ $(document).ready( function() {
"tag_with": Base64.decode($("#hidden-tag_with").val()),
"tag_without": Base64.decode($("#hidden-tag_without").val()),
"filter_only_alert" : $("#filter_only_alert").val(),
"id_group_filter": $("#id_group_filter").val()
"id_group_filter": $("#id_group_filter").val(),
"date_from": $("#text-date_from").val(),
"date_to": $("#text-date_to").val()
},
function (data) {
$(".info_box").hide();
@ -1115,7 +1135,9 @@ $(document).ready( function() {
"tag_with" : Base64.decode($("#hidden-tag_with").val()),
"tag_without" : Base64.decode($("#hidden-tag_without").val()),
"filter_only_alert" : $("#filter_only_alert").val(),
"id_group_filter": $("#id_group_filter").val()
"id_group_filter": $("#id_group_filter").val(),
"date_from": $("#text-date_from").val(),
"date_to": $("#text-date_to").val()
},
function (data) {
$(".info_box").hide();

View File

@ -1918,6 +1918,8 @@ CREATE TABLE tevent_filter (
group_rep NUMBER(10, 0) DEFAULT 0,
tag_with CLOB,
tag_without CLOB,
date_from DATE DEFAULT NULL,
date_to DATE DEFAULT NULL,
filter_only_alert NUMBER(10, 0) DEFAULT -1
);

View File

@ -1713,7 +1713,9 @@ CREATE TABLE IF NOT EXISTS `tevent_filter` (
`group_rep` int(10) NOT NULL default 0,
`tag_with` text NOT NULL,
`tag_without` text NOT NULL,
`filter_only_alert` int(10) NOT NULL default -1,
`filter_only_alert` int(10) NOT NULL default -1,
`date_from` date default NULL,
`date_to` date default NULL,
PRIMARY KEY (`id_filter`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;