[MRM-1580] system status page display current server time.

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1299622 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-03-12 11:00:36 +00:00
parent ec23b66369
commit eee8044673
5 changed files with 47 additions and 17 deletions

View File

@ -23,6 +23,7 @@
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@ -40,4 +41,11 @@ public interface SystemStatusService
String getMemoryStatus() String getMemoryStatus()
throws ArchivaRestServiceException; throws ArchivaRestServiceException;
@Path( "currentServerTime/{locale}" )
@GET
@Produces( MediaType.TEXT_PLAIN )
@RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
String getCurrentServerTime( @PathParam( "locale" ) String locale )
throws ArchivaRestServiceException;
} }

View File

@ -22,11 +22,15 @@
import org.apache.archiva.rest.api.services.SystemStatusService; import org.apache.archiva.rest.api.services.SystemStatusService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
/** /**
* @author Olivier Lamy * @author Olivier Lamy
* @since 1.4-M3 * @since 1.4-M3
*/ */
@Service("systemStatusService#rest") @Service( "systemStatusService#rest" )
public class DefaultSystemStatusService public class DefaultSystemStatusService
implements SystemStatusService implements SystemStatusService
{ {
@ -45,4 +49,11 @@ private static String formatMemory( long l )
{ {
return l / ( 1024 * 1024 ) + "M"; return l / ( 1024 * 1024 ) + "M";
} }
public String getCurrentServerTime( String locale )
throws ArchivaRestServiceException
{
SimpleDateFormat sdf = new SimpleDateFormat( "EEE, d MMM yyyy HH:mm:ss Z", new Locale( locale ) );
return sdf.format( new Date() );
}
} }

View File

@ -566,14 +566,22 @@ $(function() {
screenChange(); screenChange();
var mainContent=$("#main-content"); var mainContent=$("#main-content");
mainContent.html($("#system-status-main").tmpl()); mainContent.html($("#system-status-main").tmpl());
mainContent.find("#status_memory_info" ).html(smallSpinnerImg());
$.ajax("restServices/archivaServices/systemStatusService/memoryStatus", { $.ajax("restServices/archivaServices/systemStatusService/memoryStatus", {
type: "GET", type: "GET",
dataType: "text", dataType: "text",
success: function(data){ success: function(data){
var memUsage = data; var memUsage = data;
$.log("memUsage:"+memUsage); $.log("memUsage:"+memUsage);
mainContent.find("#status_memory_info" ).html($("#memory-info-tmpl" ).tmpl({memoryUsage: memUsage})); mainContent.find("#status_memory_info" ).html(memUsage);
}
});
$.ajax("restServices/archivaServices/systemStatusService/currentServerTime/"+encodeURIComponent(usedLang()), {
type: "GET",
dataType: "text",
success: function(data){
var curTime=data;
$.log("currentServerTime:"+curTime);
mainContent.find("#status_current_time").html(curTime);
} }
}); });
} }

View File

@ -20,11 +20,16 @@
$(function() { $(function() {
// load i18n resources from rest call // load i18n resources from rest call
var browserLang = $.i18n.browserLang(); usedLang=function(){
var requestLang = $.urlParam('request_lang'); var browserLang = $.i18n.browserLang();
if (requestLang) { var requestLang = $.urlParam('request_lang');
browserLang=requestLang; if (requestLang) {
browserLang=requestLang;
}
return browserLang;
} }
var browserLang = usedLang();
$.log("use browserLang:"+browserLang); $.log("use browserLang:"+browserLang);
// -- archiva // -- archiva
// load default // load default

View File

@ -314,48 +314,46 @@ <h3>${$.i18n.prop('network-configuration.header')}</h3>
<h4>${$.i18n.prop('system-status.header.queues')}</h4> <h4>${$.i18n.prop('system-status.header.queues')}</h4>
</div> </div>
<div id="status_queues"> <div id="status_queues">
Queues <img src="images/small-spinner.gif"/>
</div> </div>
<div class="page-header"> <div class="page-header">
<h4>${$.i18n.prop('system-status.header.scanning')}</h4> <h4>${$.i18n.prop('system-status.header.scanning')}</h4>
</div> </div>
<div id="status_scanning"> <div id="status_scanning">
repos scanning <img src="images/small-spinner.gif"/>
</div> </div>
<div class="page-header"> <div class="page-header">
<h4>${$.i18n.prop('system-status.header.caches')}</h4> <h4>${$.i18n.prop('system-status.header.caches')}</h4>
</div> </div>
<div id="status_caches"> <div id="status_caches">
caches <img src="images/small-spinner.gif"/>
</div> </div>
<div class="page-header"> <div class="page-header">
<h4>${$.i18n.prop('system-status.header.memory')}</h4> <h4>${$.i18n.prop('system-status.header.memory')}</h4>
</div> </div>
<div id="status_memory_info"> <div id="status_memory_info">
memory <img src="images/small-spinner.gif"/>
</div> </div>
<div class="page-header"> <div class="page-header">
<h4>${$.i18n.prop('system-status.header.current.time')}</h4> <h4>${$.i18n.prop('system-status.header.current.time')}</h4>
</div> </div>
<div div="status_current_time"> <div id="status_current_time">
current time <img src="images/small-spinner.gif"/>
</div> </div>
<div class="page-header"> <div class="page-header">
<h4>${$.i18n.prop('system-status.header.version.info')}</h4> <h4>${$.i18n.prop('system-status.header.version.info')}</h4>
</div> </div>
<div id="status_version_info"> <div id="status_version_info">
version info <img src="images/small-spinner.gif"/>
</div> </div>
</script> </script>
<div id="memory-info-tmpl">
${memoryUsage}
</div>