]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1580] system status page button to refresh some stats.
authorOlivier Lamy <olamy@apache.org>
Mon, 12 Mar 2012 22:26:33 +0000 (22:26 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 12 Mar 2012 22:26:33 +0000 (22:26 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1299908 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ConsumerScanningStatisticsComparator.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/general-admin.html

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 (file)
index 0000000..34b0e59
--- /dev/null
@@ -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<ConsumerScanningStatistics>
+{
+    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() );
+    }
+}
index 96818a33b752acc29f1e8e8df0683d38de224b4a..493f1063c57db11cfe7d08999485675ad14177be 100644 (file)
@@ -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();
   }
index 6ce314f4bb5b670d6d00b1f81697d213d42ae24a..7454f96d9536b1da14d77d2759d30522a25ddefb 100644 (file)
   </div>
 
   <div class="page-header">
-    <h4>${$.i18n.prop('system-status.header.scanning')}</h4>
+    <h4>${$.i18n.prop('system-status.header.scanning')}&nbsp;<a href="#" onclick="displayScanningStats()"><img src="images/view-refresh.png"/></a></h4>
   </div>
   <div id="status_scanning">
     <img src="images/small-spinner.gif"/>
   </div>
 
   <div class="page-header">
-    <h4>${$.i18n.prop('system-status.header.caches')}</h4>
+    <h4>${$.i18n.prop('system-status.header.caches')}&nbsp;<a href="#" onclick="displayCacheEntries()"><img src="images/view-refresh.png"/></a></h4>
   </div>
   <div id="status_caches">
       <img src="images/small-spinner.gif"/>
   </div>
 
   <div class="page-header">
-    <h4>${$.i18n.prop('system-status.header.memory')}</h4>
+    <h4>${$.i18n.prop('system-status.header.memory')}&nbsp;<a href="#" onclick="displayMemoryUsage()"><img src="images/view-refresh.png"/></a></h4>
   </div>
   <div id="status_memory_info">
     <img src="images/small-spinner.gif"/>
                 <tr>
                   <td>${consumerScanningStatistics.consumerKey}</td>
                   <td>${consumerScanningStatistics.count}</td>
-                  <td>${consumerScanningStatistics.average}</td>
-                  <td>${consumerScanningStatistics.time}</td>
+                  <td>${consumerScanningStatistics.average}ms</td>
+                  <td>${consumerScanningStatistics.time}ms</td>
                 </tr>
                 {{/each}}
               </tbody>