]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1574] display repo stats
authorOlivier Lamy <olamy@apache.org>
Thu, 19 Jan 2012 22:10:18 +0000 (22:10 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 19 Jan 2012 22:10:18 +0000 (22:10 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1233596 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArchivaRepositoryStatistics.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/utilities-system-monitor.png [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/repositories.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/repositories.html

index 7b55e64ff6f6b99c6362b0043a5dc0283741dd1d..92c2fb00daee66137138269b47896cca1f25653e 100644 (file)
@@ -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()
     {
index 87f589179f62698c1f33fbfeaaaeb47a93a3b73a..4860a3c3271cea1ef19988a1ff4773aa2624fa2d 100644 (file)
@@ -181,7 +181,8 @@ public class DefaultManagedRepositoriesService
             {
                 ArchivaRepositoryStatistics archivaRepositoryStatistics =
                     new BeanReplicator().replicateBean( stats, ArchivaRepositoryStatistics.class );
-
+                archivaRepositoryStatistics.setDuration( archivaRepositoryStatistics.getScanEndTime().getTime()
+                                                             - archivaRepositoryStatistics.getScanStartTime().getTime() );
                 return archivaRepositoryStatistics;
             }
 
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/utilities-system-monitor.png b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/utilities-system-monitor.png
new file mode 100644 (file)
index 0000000..8734e77
Binary files /dev/null and b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/images/utilities-system-monitor.png differ
index fd7c0a1f451ac1a4dc367107d152423c4c86f250..550399286f81c9bf310052cdf9332be8fd72c159 100644 (file)
@@ -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");
index 4dad3912117411abfa24765b98beb16ba4289570..2d3618d9fe2602086d4bc25c99c6b16a18443af8 100644 (file)
@@ -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>
                 <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) }">
   </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