archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1233596 - in /archiva/trunk/archiva-modules/archiva-web: archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/ archiva-webapp-js/sr...
Date Thu, 19 Jan 2012 22:10:19 GMT
Author: olamy
Date: Thu Jan 19 22:10:18 2012
New Revision: 1233596

URL: http://svn.apache.org/viewvc?rev=1233596&view=rev
Log:
[MRM-1574] display repo stats

Added:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/utilities-system-monitor.png
  (with props)
Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRepositoryStatistics.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRepositoryStatistics.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRepositoryStatistics.java?rev=1233596&r1=1233595&r2=1233596&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRepositoryStatistics.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRepositoryStatistics.java
Thu Jan 19 22:10:18 2012
@@ -44,6 +44,8 @@ public class ArchivaRepositoryStatistics
 
     private long newFileCount;
 
+    private long duration;
+
     public ArchivaRepositoryStatistics()
     {
         // no op
@@ -129,6 +131,16 @@ public class ArchivaRepositoryStatistics
         this.newFileCount = newFileCount;
     }
 
+    public void setDuration( long duration )
+    {
+        this.duration = duration;
+    }
+
+    public long getDuration()
+    {
+        return duration;
+    }
+
     @Override
     public String toString()
     {

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java?rev=1233596&r1=1233595&r2=1233596&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java
Thu Jan 19 22:10:18 2012
@@ -181,7 +181,8 @@ public class DefaultManagedRepositoriesS
             {
                 ArchivaRepositoryStatistics archivaRepositoryStatistics =
                     new BeanReplicator().replicateBean( stats, ArchivaRepositoryStatistics.class
);
-
+                archivaRepositoryStatistics.setDuration( archivaRepositoryStatistics.getScanEndTime().getTime()
+                                                             - archivaRepositoryStatistics.getScanStartTime().getTime()
);
                 return archivaRepositoryStatistics;
             }
 

Added: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/utilities-system-monitor.png
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/utilities-system-monitor.png?rev=1233596&view=auto
==============================================================================
Binary file - no diff available.

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/utilities-system-monitor.png
------------------------------------------------------------------------------
    svn:mime-type = image/png

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js?rev=1233596&r1=1233595&r2=1233596&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
Thu Jan 19 22:10:18 2012
@@ -92,6 +92,37 @@ $(function() {
 
   }
 
+  ArchivaRepositoryStatistics=function(scanEndTime,scanStartTime,totalArtifactCount,totalArtifactFileSize,totalFileCount,
+                                       totalGroupCount,totalProjectCount,newFileCount,duration,managedRepository){
+    //private Date scanEndTime;
+    this.scanEndTime = ko.observable(scanEndTime);
+
+    //private Date scanStartTime;
+    this.scanStartTime = ko.observable(scanStartTime);
+
+    //private long totalArtifactCount;
+    this.totalArtifactCount = ko.observable(totalArtifactCount);
+
+    //private long totalArtifactFileSize;
+    this.totalArtifactFileSize = ko.observable(totalArtifactFileSize);
+
+    //private long totalFileCount;
+    this.totalFileCount = ko.observable(totalFileCount);
+
+    //private long totalGroupCount;
+    this.totalGroupCount = ko.observable(totalGroupCount);
+
+    //private long totalProjectCount;
+    this.totalProjectCount = ko.observable(totalProjectCount);
+
+    //private long newFileCount;
+    this.newFileCount = ko.observable(newFileCount);
+
+    this.duration = ko.observable(duration);
+
+    this.managedRepository = managedRepository;
+  }
+
   ManagedRepositoryViewModel=function(managedRepository, update, managedRepositoriesViewModel){
     this.managedRepository=managedRepository;
     this.managedRepositoriesViewModel = managedRepositoriesViewModel;
@@ -296,7 +327,53 @@ $(function() {
           $("#managed-repository-delete-warning-tmpl").tmpl(managedRepository));
     }
 
+    showStats=function(managedRepository){
+      if ($(calculatePopoverId(managedRepository)).html()){
+        // we ask stats all the time ? if yes uncomment return
+        return;
+        //$(calculatePopoverId(managedRepository)).html("");
+      }
+      var curRepo=managedRepository;
+      var url = "restServices/archivaServices/managedRepositoriesService/getManagedRepositoryStatistics/"+managedRepository.id();
+      $.ajax(url,
+        {
+          type: "GET",
+          dataType: 'json',
+          success: function(data) {
+            if (data.archivaRepositoryStatistics==null){
+              return;
+            }
+            var archivaRepositoryStatistics=mapArchivaRepositoryStatistics(data.archivaRepositoryStatistics);
+            archivaRepositoryStatistics.managedRepository=curRepo;
+            $("#managedrepository-stats-"+curRepo.id()).append($("#managed-repository-stats-tmpl").tmpl(archivaRepositoryStatistics));
+            $("#managedrepository-stats-img-"+curRepo.id()).attr("data-content",$(calculatePopoverId(curRepo)).html());
+            $("#managedrepository-stats-img-"+curRepo.id()).popover(
+                {
+                  placement: "left",
+                  html: true
+                }
+            );
+            //$(calculatePopoverId(managedRepository)).show();
+            $("#managedrepository-stats-img-"+curRepo.id()).popover('show')
+
+          },
+          error: function(data) {
+            var res = $.parseJSON(data.responseText);
+            displayRestError(res);
+          },
+          complete: function(){
+           }
+        }
+      );
+    }
+
+    hideStats=function(managedRepository){
 
+    }
+
+    calculatePopoverId=function(managedRepository){
+      return "#managedrepository-stats-"+managedRepository.id() + " #managedrepository-stats-"+managedRepository.id()+"-popover";
+    }
 
   }
 
@@ -369,12 +446,23 @@ $(function() {
     return mappedManagedRepositories;
   }
   mapManagedRepository=function(data){
-
+    if (data==null){
+      return null;
+    }
     return new ManagedRepository(data.id,data.name,data.layout,data.indexDirectory,data.location,data.snapshots,data.releases,
                                  data.blockRedeployments,data.cronExpression,
                                  data.scanned,data.daysOlder,data.retentionCount,data.deleteReleasedSnapshots,data.stageRepoNeeded);
   }
 
+  mapArchivaRepositoryStatistics=function(data){
+    if (data==null){
+      return null;
+    }
+    return new ArchivaRepositoryStatistics(data.scanEndTime,data.scanStartTime,data.totalArtifactCount,data.totalArtifactFileSize,
+                                           data.totalFileCount,data.totalGroupCount,data.totalProjectCount,data.newFileCount,
+                                           data.duration,data.managedRepository)
+  }
+
   activateManagedRepositoriesGridTab=function(){
     $("#main-content #managed-repository-edit-li").removeClass("active");
     $("#main-content #managed-repository-edit").removeClass("active");

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html?rev=1233596&r1=1233595&r2=1233596&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html
Thu Jan 19 22:10:18 2012
@@ -67,6 +67,7 @@
         <th>Releases</th>
         <th>Snapshots</th>
         <th>Scan</th>
+        <th>Stats</th>
         <th>${$.i18n.prop('edit')}</th>
         <th>${$.i18n.prop('delete')}</th>
       </tr>
@@ -97,6 +98,11 @@
                 <img src="images/view-refresh.png" title="${$.i18n.prop('managedrepository.scan.now')}"/>
               </a>
             </td>
+            <td id="managedrepository-stats-${row.id()}">
+              <img src="images/utilities-system-monitor.png" title="${$.i18n.prop('managedrepository.stats')}"
+                   data-bind="event: { mouseover: function(){ showStats(row) }, mouseout:
function(){ hideStats(row) },}"
+                   id="managedrepository-stats-img-${row.id()}"/>
+            </td>
             <td><a href="#" data-bind="click: function(){ editManagedRepository(row)
}">${$.i18n.prop('edit')}</a></td>
             <td>
               <a href="#" data-bind="click: function(){ removeManagedRepository(row) }">
@@ -244,8 +250,15 @@
   </div>
 </script>
 <script id="managed-repository-scan-now-modal-tmpl" type='text/x-jquery-tmpl'>
-      <div>
-        ${$.i18n.prop('managedrepository.scan.all')}: <input type="checkbox" id="managed-repository-scan-now-all">
-      </div>
-
+  <div>
+    ${$.i18n.prop('managedrepository.scan.all')}: <input type="checkbox" id="managed-repository-scan-now-all">
+  </div>
+</script>
+<script id="managed-repository-stats-tmpl" type='text/x-jquery-tmpl'>
+  <div id="managedrepository-stats-${managedRepository.id()}-popover" style="display:none">
+    <div>${$.i18n.prop('managedrepository.stats.endTime')}: ${scanEndTime()}</div>
+    <div>${$.i18n.prop('managedrepository.stats.duration')}: ${duration()}</div>
+    <div>${$.i18n.prop('managedrepository.stats.totalFileCount')}: ${totalFileCount()}</div>
+    <div>${$.i18n.prop('managedrepository.stats.newFileCount')}: ${newFileCount()}</div>
+  </div>
 </script>
\ No newline at end of file



Mime
View raw message