From ec7504f9258dbae4ccd5050e5cc8168486fbff77 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 1 Jan 2016 16:33:28 -0500 Subject: [PATCH 1/3] Translate ServerId to Server in Log record before sending back --- web/ajax/log.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/web/ajax/log.php b/web/ajax/log.php index c01fd8dae..1ddb91ab2 100644 --- a/web/ajax/log.php +++ b/web/ajax/log.php @@ -31,6 +31,13 @@ switch ( $_REQUEST['task'] ) if ( !canView( 'System' ) ) ajaxError( 'Insufficient permissions to view log entries' ); + $servers = Server::find_all(); + $servers_by_Id = array(); + # There is probably a better way to do this. + foreach ( $servers as $server ) { + $servers_by_Id[$server->Id()] = $server; + } + $minTime = isset($_POST['minTime'])?$_POST['minTime']:NULL; $maxTime = isset($_POST['maxTime'])?$_POST['maxTime']:NULL; $limit = isset($_POST['limit'])?$_POST['limit']:100; @@ -66,6 +73,7 @@ switch ( $_REQUEST['task'] ) $logs = array(); foreach ( dbFetchAll( $sql, NULL, $values ) as $log ) { $log['DateTime'] = preg_replace( '/^\d+/', strftime( "%Y-%m-%d %H:%M:%S", intval($log['TimeKey']) ), $log['TimeKey'] ); + $log['Server'] = $log['ServerId'] ? $servers_by_Id[$log['ServerId']]->Name() : ''; $logs[] = $log; } $options = array(); From 468f997e4c5404af1d3893f511b27d64800cf6f9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 1 Jan 2016 16:36:29 -0500 Subject: [PATCH 2/3] Soft error, with logging when the filter element doesn't exist --- web/skins/classic/views/js/log.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/skins/classic/views/js/log.js b/web/skins/classic/views/js/log.js index 011c4beb0..8288916dd 100644 --- a/web/skins/classic/views/js/log.js +++ b/web/skins/classic/views/js/log.js @@ -244,6 +244,12 @@ function updateFilterSelectors() function( values, key ) { var selector = $('filter['+key+']'); + if ( ! selector ) { + if ( window.console && window.console.log ) { + window.console.log("No selector foudn for " + key ); + } + continue; + } selector.options.length = 1; if ( key == 'Level' ) { From cf7e1688722c49ae11a50c1d2181124b8e7a94de Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 1 Jan 2016 17:10:37 -0500 Subject: [PATCH 3/3] Fix populating the server filter and then fix filtering by server. Also introduce robustness and consolel ogging when a filter doesn't exist --- web/ajax/log.php | 6 ++++++ web/skins/classic/views/js/log.js | 21 ++++++++++++++++++--- web/skins/classic/views/log.php | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/web/ajax/log.php b/web/ajax/log.php index 1ddb91ab2..1e565424c 100644 --- a/web/ajax/log.php +++ b/web/ajax/log.php @@ -104,6 +104,12 @@ switch ( $_REQUEST['task'] ) else $options[$field][$value] = "DB".$value; } + elseif ( $field == 'ServerId' ) + { + foreach( dbFetchAll( $sql, $field, array_values($fieldValues) ) as $value ) + $options['ServerId'][$value] = $value ? $servers_by_Id[$value]->Name() : ''; + + } else { foreach( dbFetchAll( $sql, $field, array_values( $fieldValues ) ) as $value ) diff --git a/web/skins/classic/views/js/log.js b/web/skins/classic/views/js/log.js index 8288916dd..e6f7fa30e 100644 --- a/web/skins/classic/views/js/log.js +++ b/web/skins/classic/views/js/log.js @@ -22,7 +22,7 @@ var logTimeout = maxSampleTime; var firstLoad = true; var initialDisplayLimit = 200; var sortReversed = false; -var filterFields = [ 'Component', 'Server', 'Pid', 'Level', 'File', 'Line']; +var filterFields = [ 'Component', 'ServerId', 'Pid', 'Level', 'File', 'Line']; var options = {}; function buildFetchParms( parms ) @@ -163,6 +163,12 @@ function filterLog() function( field ) { var selector = $('filter['+field+']'); + if ( ! selector ) { + if ( window.console && window.console.log ) { + window.console.log("No selector found for " + field ); + } + return; + } var value = selector.get('value'); if ( value ) filter[field] = value; @@ -246,9 +252,9 @@ function updateFilterSelectors() var selector = $('filter['+key+']'); if ( ! selector ) { if ( window.console && window.console.log ) { - window.console.log("No selector foudn for " + key ); + window.console.log("No selector found for " + key ); } - continue; + return; } selector.options.length = 1; if ( key == 'Level' ) @@ -259,6 +265,15 @@ function updateFilterSelectors() selector.options[selector.options.length] = new Option( value, label ); } ); + } + else if ( key == 'ServerId' ) + { + Object.each(values, + function( value, label ) + { + selector.options[selector.options.length] = new Option( value, label ); + } + ); } else { diff --git a/web/skins/classic/views/log.php b/web/skins/classic/views/log.php index 93b2c0b39..50ba58d42 100644 --- a/web/skins/classic/views/log.php +++ b/web/skins/classic/views/log.php @@ -54,7 +54,7 @@ xhtmlHeaders(__FILE__, translate('SystemLog') );
- - +