From 40750437f3c04d864625f85046c4bf9bfb3f4255 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 12 Mar 2012 22:26:33 +0000 Subject: [PATCH] [MRM-1580] system status page button to refresh some stats. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1299908 13f79535-47bb-0310-9956-ffa450edef68 --- .../ConsumerScanningStatisticsComparator.java | 41 +++++++++++++++ .../main/webapp/js/archiva/general-admin.js | 51 ++++++++++++------- .../js/archiva/templates/general-admin.html | 10 ++-- 3 files changed, 79 insertions(+), 23 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ConsumerScanningStatisticsComparator.java diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ConsumerScanningStatisticsComparator.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ConsumerScanningStatisticsComparator.java new file mode 100644 index 000000000..34b0e598e --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ConsumerScanningStatisticsComparator.java @@ -0,0 +1,41 @@ +package org.apache.archiva.rest.services.utils; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.rest.api.model.ConsumerScanningStatistics; + +import java.util.Comparator; + +/** + * @author Olivier Lamy + */ +public class ConsumerScanningStatisticsComparator + implements Comparator +{ + public static final ConsumerScanningStatisticsComparator INSTANCE = new ConsumerScanningStatisticsComparator(); + + public int compare( ConsumerScanningStatistics one, ConsumerScanningStatistics two ) + { + if ( one == two ) + { + return 0; + } + return one.getConsumerKey().compareTo( two.getConsumerKey() ); + } +} diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js index 96818a33b..493f1063c 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js @@ -594,11 +594,13 @@ $(function() { } displayCacheEntries=function(){ + var divContent = $("#main-content #status_caches"); + divContent.html(smallSpinnerImg()); $.ajax("restServices/archivaServices/systemStatusService/cacheEntries", { type: "GET", success: function(data){ var cacheEntries=mapCacheEntries(data); - $("#main-content #status_caches").html($("#status_caches_tmpl" ).tmpl({cacheEntries: cacheEntries})); + divContent.html($("#status_caches_tmpl" ).tmpl({cacheEntries: cacheEntries})); } }); } @@ -655,24 +657,44 @@ $(function() { this.newFileCount=newFileCount; } - displaySystemStatus=function(){ - screenChange(); - var mainContent=$("#main-content"); - mainContent.html($("#system-status-main").tmpl()); - - var versionInfo=$.i18n.prop('system-status.header.version.buildNumber')+": "+window.archivaRuntimeInfo.buildNumber - +" - "+$.i18n.prop('system-status.header.version.timestampStr')+": "+window.archivaRuntimeInfo.timestampStr; - mainContent.find("#status_version_info").html(versionInfo); + displayScanningStats=function(){ + var divContent = $("#main-content #status_scanning"); + divContent.html(smallSpinnerImg()); + $.ajax("restServices/archivaServices/systemStatusService/repositoryScannerStatistics", { + type: "GET", + success: function(data){ + var stats= mapRepositoryScannerStatisticsList(data); + $.log("size:"+data.length); + divContent.html($("#status_scanning_tmpl").tmpl({repositoryScannerStatisticsList:stats})); + } + }); + } + displayMemoryUsage=function(){ + var divContent = $("#main-content #status_memory_info"); + divContent.html(smallSpinnerImg()); $.ajax("restServices/archivaServices/systemStatusService/memoryStatus", { type: "GET", dataType: "text", success: function(data){ var memUsage = data; $.log("memUsage:"+memUsage); - mainContent.find("#status_memory_info" ).html(memUsage); + divContent.html(memUsage); } }); + } + + displaySystemStatus=function(){ + screenChange(); + var mainContent=$("#main-content"); + mainContent.html($("#system-status-main").tmpl()); + + var versionInfo=$.i18n.prop('system-status.header.version.buildNumber')+": "+window.archivaRuntimeInfo.buildNumber + +" - "+$.i18n.prop('system-status.header.version.timestampStr')+": "+window.archivaRuntimeInfo.timestampStr; + mainContent.find("#status_version_info").html(versionInfo); + + displayMemoryUsage(); + $.ajax("restServices/archivaServices/systemStatusService/currentServerTime/"+encodeURIComponent(usedLang()), { type: "GET", dataType: "text", @@ -691,14 +713,7 @@ $(function() { } }); - $.ajax("restServices/archivaServices/systemStatusService/repositoryScannerStatistics", { - type: "GET", - success: function(data){ - var stats= mapRepositoryScannerStatisticsList(data); - $.log("size:"+data.length); - mainContent.find("#status_scanning" ).html($("#status_scanning_tmpl").tmpl({repositoryScannerStatisticsList:stats})); - } - }); + displayScanningStats(); displayCacheEntries(); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html index 6ce314f4b..7454f96d9 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html @@ -322,21 +322,21 @@
@@ -451,8 +451,8 @@ ${consumerScanningStatistics.consumerKey} ${consumerScanningStatistics.count} - ${consumerScanningStatistics.average} - ${consumerScanningStatistics.time} + ${consumerScanningStatistics.average}ms + ${consumerScanningStatistics.time}ms {{/each}} -- 2.39.5