You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sirona.apache.org by ol...@apache.org on 2014/08/25 07:27:44 UTC

svn commit: r1620256 - in /incubator/sirona/trunk/server/reporting: reporting-api/src/main/java/org/apache/sirona/reporting/web/counters/ reporting-ui/src/main/webapp/js/app/controllers/ reporting-ui/src/main/webapp/partials/

Author: olamy
Date: Mon Aug 25 05:27:44 2014
New Revision: 1620256

URL: http://svn.apache.org/r1620256
Log:
add conversion parameter

Modified:
    incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/counters/CountersService.java
    incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/counters/KeyInfo.java
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-report.js
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/report.html

Modified: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/counters/CountersService.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/counters/CountersService.java?rev=1620256&r1=1620255&r2=1620256&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/counters/CountersService.java (original)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/counters/CountersService.java Mon Aug 25 05:27:44 2014
@@ -26,6 +26,7 @@ import javax.ws.rs.GET;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -40,20 +41,48 @@ public class CountersService
 
     @GET
     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
-    public List<CounterInfo> all()
+    public List<CounterInfo> all( @QueryParam( "unit" ) String unitName )
     {
         Collection<Counter> counters = Repository.INSTANCE.counters();
 
         List<CounterInfo> out = new ArrayList<CounterInfo>( counters.size() );
 
+        Unit unit = null;
+
+        if ( unitName != null )
+        {
+            unit = Unit.get( unitName );
+        }
+
         for ( Counter counter : counters )
         {
-            out.add( new CounterInfo( new KeyInfo( counter.getKey() ), MetricData.Hits.value( counter ), //
-                                      MetricData.Max.value( counter ), MetricData.Mean.value( counter ), //
-                                      MetricData.Min.value( counter ), MetricData.StandardDeviation.value( counter ), //
-                                      MetricData.Sum.value( counter ), MetricData.Variance.value( counter ), //
-                                      MetricData.Concurrency.value( counter ),
-                                      MetricData.MaxConcurrency.value( counter ) ) ); //
+            Unit currentUnit = counter.getKey().getRole().getUnit();
+            if ( unit == null )
+            {
+                out.add( new CounterInfo( new KeyInfo( counter.getKey() ), //
+                                          MetricData.Hits.value( counter ), //
+                                          MetricData.Max.value( counter ), //
+                                          MetricData.Mean.value( counter ), //
+                                          MetricData.Min.value( counter ), //
+                                          MetricData.StandardDeviation.value( counter ), //
+                                          MetricData.Sum.value( counter ), //
+                                          MetricData.Variance.value( counter ), //
+                                          MetricData.Concurrency.value( counter ), //
+                                          MetricData.MaxConcurrency.value( counter ) ) ); //
+            }
+            else
+            {
+                out.add( new CounterInfo( new KeyInfo( counter.getKey() ).unitName( unit.getName() ), //
+                                          MetricData.Hits.value( counter ), //
+                                          unit.convert( MetricData.Max.value( counter ), currentUnit ), //
+                                          unit.convert( MetricData.Mean.value( counter ), currentUnit ), //
+                                          unit.convert( MetricData.Min.value( counter ), currentUnit ), //
+                                          unit.convert( MetricData.StandardDeviation.value( counter ), currentUnit ), //
+                                          unit.convert( MetricData.Sum.value( counter ), currentUnit ), //
+                                          unit.convert( MetricData.Variance.value( counter ), currentUnit ), //
+                                          MetricData.Concurrency.value( counter ), //
+                                          MetricData.MaxConcurrency.value( counter ) ) ); //
+            }
         }
 
         return out;

Modified: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/counters/KeyInfo.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/counters/KeyInfo.java?rev=1620256&r1=1620255&r2=1620256&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/counters/KeyInfo.java (original)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/counters/KeyInfo.java Mon Aug 25 05:27:44 2014
@@ -32,7 +32,7 @@ public class KeyInfo
 
     private final String roleName;
 
-    private final String unitName;
+    private String unitName;
 
     public KeyInfo( Counter.Key key )
     {
@@ -58,6 +58,17 @@ public class KeyInfo
         return unitName;
     }
 
+    public void setUnitName( String unitName )
+    {
+        this.unitName = unitName;
+    }
+
+    public KeyInfo unitName( String unitName )
+    {
+        this.unitName = unitName;
+        return this;
+    }
+
     @Override
     public String toString()
     {

Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-report.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-report.js?rev=1620256&r1=1620255&r2=1620256&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-report.js (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-report.js Mon Aug 25 05:27:44 2014
@@ -28,7 +28,7 @@ define(['jquery','angular','bootstrap','
     function ( $scope,$routeParams,$http,counters){
 
       $scope.colDefs = [
-        {field: 'name', displayName: 'Counter'},
+        {field: 'name', displayName: 'Counter',enableFiltering: true},
         {field: 'roleName', displayName: 'Role', cellTemplate:"<div class='ngCellText'>{{row.getProperty(col.field)}} ({{row.getProperty('unitName')}})</div>"},
         {field: 'hits', displayName: 'Hits'},
         {field: 'max', displayName: 'Max'},
@@ -50,16 +50,17 @@ define(['jquery','angular','bootstrap','
       };
 
       $scope.gridOptions={
+        enableFiltering: true,
         enablePaging: true,
         pagingOptions: $scope.pagingOptions,
         showFooter: true,
-        showGroupPanel: true,
+        showHeader: true,
         jqueryUITheme: false,
         columnDefs: 'colDefs',
         plugins: [new ngGridFlexibleHeightPlugin(), new ngGridCsvExportPlugin(csvOpts)]
       };
 
-      $http.get('restServices/sironaServices/counters')
+      $http.get('restServices/sironaServices/counters?unit=ms') //
           .success(function(data) {
                      $scope.counters = data;
                    });

Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/report.html
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/report.html?rev=1620256&r1=1620255&r2=1620256&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/report.html (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/report.html Mon Aug 25 05:27:44 2014
@@ -16,6 +16,6 @@
 -->
     <!-- ng-style="getTableStyle()" -->
 
-<div ng-grid="gridOptions">
+<div ng-grid="gridOptions" class="grid">
 
 </div>