From 38ca2a5e0282e41fef9bb3f1771669ec8e1230cb Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Fri, 7 Jun 2013 09:13:08 +0000 Subject: [PATCH] 2013-06-07 Sergio Martin * include/ajax/module.php include/javascript/jquery.ui.datepicker.js operation/tree.php operation/agentes/datos_agente.php: Added range filter to raw data view in tree view * operation/netflow/nf_live_view.php: Fix help popup in metaconsole view git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8269 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 11 ++++ pandora_console/include/ajax/module.php | 56 ++++++++++++++++--- .../javascript/jquery.ui.datepicker.js | 1 - .../operation/agentes/datos_agente.php | 4 +- .../operation/netflow/nf_live_view.php | 2 +- pandora_console/operation/tree.php | 34 ++++++++++- 6 files changed, 94 insertions(+), 14 deletions(-) delete mode 100644 pandora_console/include/javascript/jquery.ui.datepicker.js diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 2ab682c15c..8a07f09bdd 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,14 @@ +2013-06-07 Sergio Martin + + * include/ajax/module.php + include/javascript/jquery.ui.datepicker.js + operation/tree.php + operation/agentes/datos_agente.php: Added range filter + to raw data view in tree view + + * operation/netflow/nf_live_view.php: Fix help popup + in metaconsole view + 2013-06-06 Sergio Martin * include/functions_config.php: Replaced netflow and diff --git a/pandora_console/include/ajax/module.php b/pandora_console/include/ajax/module.php index eb117c9e59..9787832b60 100644 --- a/pandora_console/include/ajax/module.php +++ b/pandora_console/include/ajax/module.php @@ -67,7 +67,13 @@ if ($get_module_detail) { $conexion = mysql_connect ($server['dbhost'], $server['dbuser'], $server['dbpass']); $select_db = mysql_select_db ($server['dbname'], $conexion); } - + + $selection_mode = get_parameter('selection_mode', 'fromnow'); + $date_from = (string) get_parameter ('date_from', date ('Y-m-j')); + $time_from = (string) get_parameter ('time_from', date ('h:iA')); + $date_to = (string) get_parameter ('date_to', date ('Y-m-j')); + $time_to = (string) get_parameter ('time_to', date ('h:iA')); + $formtable->width = '98%'; $formtable->class = "databox"; $formtable->data = array (); @@ -88,10 +94,26 @@ if ($get_module_detail) { SECONDS_2YEARS =>__('2 years'), SECONDS_3YEARS =>__('3 years')); - $formtable->data[0][0] = __('Select period:'); + $formtable->data[0][0] = html_print_radio_button_extended ("selection_mode", 'fromnow', '', $selection_mode, false, '', 'style="margin-right: 15px;"', true) . __("Choose a time from now"); $formtable->data[0][1] = html_print_select ($periods, 'period', $period, '', '', 0, true, false, false); - $formtable->data[0][2] = "". html_print_image ("images/refresh.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . ""; + $formtable->data[0][2] = ''; + $formtable->data[0][3] = "". html_print_image ("images/refresh.png", true, array ("style" => 'vertical-align: middle;', "border" => "0" )) . ""; + $formtable->rowspan[0][3] = 2; + $formtable->cellstyle[0][3] = 'vertical-align: middle;'; + $formtable->data[1][0] = html_print_radio_button_extended ("selection_mode", 'range','', $selection_mode, false, '', 'style="margin-right: 15px;"', true) . __("Specify time range"); + $formtable->data[1][1] = __('Timestamp from:'); + + $formtable->data[1][2] = html_print_input_text ('date_from', $date_from, '', 10, 10, true); + $formtable->data[1][2] .= html_print_input_text ('time_from', $time_from, '', 9, 7, true); + + $formtable->data[1][1] .= '
'; + $formtable->data[1][1] .= __('Timestamp to:'); + + $formtable->data[1][2] .= '
'; + $formtable->data[1][2] .= html_print_input_text ('date_to', $date_to, '', 10, 10, true); + $formtable->data[1][2] .= html_print_input_text ('time_to', $time_to, '', 9, 7, true); + html_print_table($formtable); $moduletype_name = modules_get_moduletype_name (modules_get_agentmodule_type ($module_id)); @@ -101,11 +123,19 @@ if ($get_module_detail) { $columns = array (); + $datetime_from = strtotime ($date_from.' '.$time_from); + $datetime_to = strtotime ($date_to.' '.$time_to); + if ($moduletype_name == "log4x") { $table->width = "100%"; - $sql_body = sprintf ("FROM tagente_datos_log4x WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); - + if ($selection_mode == "fromnow") { + $sql_body = sprintf ("FROM tagente_datos_log4x WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); + } + else { + $sql_body = sprintf ("FROM tagente_datos_log4x WHERE id_agente_modulo = %d AND utimestamp >= %d AND utimestamp <= %d ORDER BY utimestamp DESC", $module_id, $datetime_from, $datetime_to); + } + $columns = array( "Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "center" ), "Sev" => array("severity", "modules_format_data", "align" => "center", "width" => "70px"), @@ -115,7 +145,13 @@ if ($get_module_detail) { } else if (preg_match ("/string/", $moduletype_name)) { - $sql_body = sprintf (" FROM tagente_datos_string WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); + if ($selection_mode == "fromnow") { + $sql_body = sprintf (" FROM tagente_datos_string WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); + } + else { + $sql_body = sprintf (" FROM tagente_datos_string WHERE id_agente_modulo = %d AND utimestamp >= %d AND utimestamp <= %d ORDER BY utimestamp DESC", $module_id, $datetime_from, $datetime_to); + } + $columns = array( "Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "left"), "Data" => array("datos", "modules_format_data", "align" => "left"), @@ -123,8 +159,12 @@ if ($get_module_detail) { ); } else { - - $sql_body = sprintf (" FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); + if ($selection_mode == "fromnow") { + $sql_body = sprintf (" FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, get_system_time () - $period); + } + else { + $sql_body = sprintf (" FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp >= %d AND utimestamp <= %d ORDER BY utimestamp DESC", $module_id, $datetime_from, $datetime_to); + } $columns = array( "Timestamp" => array("utimestamp", "modules_format_timestamp", "align" => "left"), diff --git a/pandora_console/include/javascript/jquery.ui.datepicker.js b/pandora_console/include/javascript/jquery.ui.datepicker.js deleted file mode 100644 index 129c863aed..0000000000 --- a/pandora_console/include/javascript/jquery.ui.datepicker.js +++ /dev/null @@ -1 +0,0 @@ -(function($){function Datepicker(){this.debug=false;this._nextId=0;this._inst=[];this._curInst=null;this._disabledInputs=[];this._datepickerShowing=false;this._inDialog=false;this.regional=[];this.regional[""]={clearText:"Clear",clearStatus:"Erase the current date",closeText:"Close",closeStatus:"Close without change",prevText:"<Prev",prevStatus:"Show the previous month",nextText:"Next>",nextStatus:"Show the next month",currentText:"Today",currentStatus:"Show the current month",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],monthStatus:"Show a different month",yearStatus:"Show a different year",weekHeader:"Wk",weekStatus:"Week of the year",dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],dayStatus:"Set DD as first week day",dateStatus:"Select DD, M d",dateFormat:"yy-mm-dd",firstDay:0,initStatus:"Select a date",isRTL:false};this._defaults={showOn:"focus",showAnim:"show",defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:false,closeAtTop:true,mandatory:false,hideIfNoPrevNext:false,changeMonth:true,changeYear:true,yearRange:"-10:+10",changeFirstDay:true,showOtherMonths:false,showWeeks:false,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",showStatus:false,statusForDate:this.dateStatus,minDate:null,maxDate:null,speed:"normal",beforeShowDay:null,beforeShow:null,onSelect:null,onClose:null,numberOfMonths:1,stepMonths:1,rangeSelect:false,rangeSeparator:" - "};$.extend(this._defaults,this.regional[""]);this._datepickerDiv=$('
');}$.extend(Datepicker.prototype,{markerClassName:"hasDatepicker",log:function(){if(this.debug){console.log.apply("",arguments);}},_register:function(inst){var id=this._nextId++;this._inst[id]=inst;return id;},_getInst:function(id){return this._inst[id]||id;},setDefaults:function(settings){extendRemove(this._defaults,settings||{});return this;},_attachDatepicker:function(target,settings){var inlineSettings=null;for(attrName in this._defaults){var attrValue=target.getAttribute("date:"+attrName);if(attrValue){inlineSettings=inlineSettings||{};try{inlineSettings[attrName]=eval(attrValue);}catch(err){inlineSettings[attrName]=attrValue;}}}var nodeName=target.nodeName.toLowerCase();var instSettings=(inlineSettings?$.extend(settings||{},inlineSettings||{}):settings);if(nodeName=="input"){var inst=(inst&&!inlineSettings?inst:new DatepickerInstance(instSettings,false));this._connectDatepicker(target,inst);}else{if(nodeName=="div"||nodeName=="span"){var inst=new DatepickerInstance(instSettings,true);this._inlineDatepicker(target,inst);}}},_destroyDatepicker:function(target){var nodeName=target.nodeName.toLowerCase();var calId=target._calId;target._calId=null;var $target=$(target);if(nodeName=="input"){$target.siblings(".ui-datepicker-append").replaceWith("").end().siblings(".ui-datepicker-trigger").replaceWith("").end().removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress);var wrapper=$target.parents(".ui-datepicker-wrap");if(wrapper){wrapper.replaceWith(wrapper.html());}}else{if(nodeName=="div"||nodeName=="span"){$target.removeClass(this.markerClassName).empty();}}if($("input[_calId="+calId+"]").length==0){this._inst[calId]=null;}},_enableDatepicker:function(target){target.disabled=false;$(target).siblings("button.ui-datepicker-trigger").each(function(){this.disabled=false;}).end().siblings("img.ui-datepicker-trigger").css({opacity:"1.0",cursor:""});this._disabledInputs=$.map(this._disabledInputs,function(value){return(value==target?null:value);});},_disableDatepicker:function(target){target.disabled=true;$(target).siblings("button.ui-datepicker-trigger").each(function(){this.disabled=true;}).end().siblings("img.ui-datepicker-trigger").css({opacity:"0.5",cursor:"default"});this._disabledInputs=$.map($.datepicker._disabledInputs,function(value){return(value==target?null:value);});this._disabledInputs[$.datepicker._disabledInputs.length]=target;},_isDisabledDatepicker:function(target){if(!target){return false;}for(var i=0;i-1);},_connectDatepicker:function(target,inst){var input=$(target);if(input.is("."+this.markerClassName)){return;}var appendText=inst._get("appendText");var isRTL=inst._get("isRTL");if(appendText){if(isRTL){input.before(''+appendText);}else{input.after(''+appendText);}}var showOn=inst._get("showOn");if(showOn=="focus"||showOn=="both"){input.focus(this._showDatepicker);}if(showOn=="button"||showOn=="both"){input.wrap('');var buttonText=inst._get("buttonText");var buttonImage=inst._get("buttonImage");var trigger=$(inst._get("buttonImageOnly")?$("").addClass("ui-datepicker-trigger").attr({src:buttonImage,alt:buttonText,title:buttonText}):$("