From e2ce3914e2cac92d39a0997171825596968a34dc Mon Sep 17 00:00:00 2001 From: Stefan Matheis Date: Tue, 5 Mar 2013 15:02:39 +0000 Subject: [PATCH] SOLR-4526: Admin UI depends on optional system info git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1452835 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 3 ++ solr/webapp/web/js/scripts/index.js | 68 +++++++++++++++++------------ 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 8a2c4d8b555..c8c2a5229d9 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -239,6 +239,9 @@ Optimizations * SOLR-4529: Improve Admin UI Dashboard legibility (Felix Buenemann via steffkes) +* SOLR-4526: Admin UI depends on optional system info (Felix Buenemann via + steffkes) + Other Changes ---------------------- diff --git a/solr/webapp/web/js/scripts/index.js b/solr/webapp/web/js/scripts/index.js index fa8fef53f15..3cc2de5f75b 100644 --- a/solr/webapp/web/js/scripts/index.js +++ b/solr/webapp/web/js/scripts/index.js @@ -97,8 +97,8 @@ var system_info = function( element, system_data ) { // -- usage - var load_average = ( system_data['system']['uptime'] || '' ).match( /load average: (.+)/ ); - if( load_average && load_average[1] ) + var load_average = ( system_data['system']['uptime'] || '' ).match( /load averages?: (\d+[.,]\d\d),? (\d+[.,]\d\d),? (\d+[.,]\d\d)/ ); + if( load_average ) { var hl = $( '#system h2', element ); @@ -106,20 +106,20 @@ var system_info = function( element, system_data ) .remove(); hl - .append( ' ' + load_average[1].split( ', ' ).join( ' ' ).esc() + '' ); + .append( ' ' + load_average.slice( 1 ).join( ' ' ).replace( /,/g, '.' ).esc() + '' ); } // -- physical-memory-bar var bar_holder = $( '#physical-memory-bar', element ); - if( !system_data['system']['totalPhysicalMemorySize'] ) + if( system_data['system']['totalPhysicalMemorySize'] === undefined || system_data['system']['freePhysicalMemorySize'] === undefined ) { bar_holder.hide(); } else { bar_holder.show(); - + var bar_data = { 'max' : parse_memory_value( system_data['system']['totalPhysicalMemorySize'] ), 'total' : parse_memory_value( system_data['system']['totalPhysicalMemorySize'] - system_data['system']['freePhysicalMemorySize'] ) @@ -131,7 +131,7 @@ var system_info = function( element, system_data ) // -- swap-space-bar var bar_holder = $( '#swap-space-bar', element ); - if( !system_data['system']['totalSwapSpaceSize'] ) + if( system_data['system']['totalSwapSpaceSize'] === undefined || system_data['system']['freeSwapSpaceSize'] === undefined ) { bar_holder.hide(); } @@ -147,10 +147,10 @@ var system_info = function( element, system_data ) generate_bar( bar_holder, bar_data, true ); } - // -- swap-space-bar + // -- file-descriptor-bar var bar_holder = $( '#file-descriptor-bar', element ); - if( !system_data['system']['maxFileDescriptorCount'] ) + if( system_data['system']['maxFileDescriptorCount'] === undefined || system_data['system']['openFileDescriptorCount'] === undefined ) { bar_holder.hide(); } @@ -172,32 +172,42 @@ var system_info = function( element, system_data ) // -- memory-bar - var jvm_memory = $.extend - ( - { - 'free' : null, - 'total' : null, - 'max' : null, - 'used' : null, - 'raw' : { + var bar_holder = $( '#jvm-memory-bar', element ); + if( system_data['jvm']['memory'] === undefined ) + { + bar_holder.hide(); + } + else + { + bar_holder.show(); + + var jvm_memory = $.extend + ( + { 'free' : null, 'total' : null, 'max' : null, 'used' : null, - 'used%' : null - } - }, - system_data['jvm']['memory'] - ); - - var bar_holder = $( '#jvm-memory-bar', element ); - var bar_data = { - 'max' : parse_memory_value( jvm_memory['raw']['max'] || jvm_memory['max'] ), - 'total' : parse_memory_value( jvm_memory['raw']['total'] || jvm_memory['total'] ), - 'used' : parse_memory_value( jvm_memory['raw']['used'] || jvm_memory['used'] ) - }; + 'raw' : { + 'free' : null, + 'total' : null, + 'max' : null, + 'used' : null, + 'used%' : null + } + }, + system_data['jvm']['memory'] + ); + + var bar_data = { + 'max' : parse_memory_value( jvm_memory['raw']['max'] || jvm_memory['max'] ), + 'total' : parse_memory_value( jvm_memory['raw']['total'] || jvm_memory['total'] ), + 'used' : parse_memory_value( jvm_memory['raw']['used'] || jvm_memory['used'] ) + }; + + generate_bar( bar_holder, bar_data, true ); + } - generate_bar( bar_holder, bar_data, true ); } // #/