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/09/09 14:00:33 UTC

svn commit: r1623777 - in /incubator/sirona/trunk/server/reporting: reporting-api/src/main/java/org/apache/sirona/reporting/web/sessions/ reporting-ui/src/main/webapp/ reporting-ui/src/main/webapp/js/ reporting-ui/src/main/webapp/js/app/controllers/ re...

Author: olamy
Date: Tue Sep  9 12:00:32 2014
New Revision: 1623777

URL: http://svn.apache.org/r1623777
Log:
sessions report

Added:
    incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/sessions/
    incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/sessions/SessionsReports.java   (with props)
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-sessions.js   (with props)
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/sessions.html   (with props)
Modified:
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/index.html
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-jta.js
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/main.js
    incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js

Added: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/sessions/SessionsReports.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/sessions/SessionsReports.java?rev=1623777&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/sessions/SessionsReports.java (added)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/sessions/SessionsReports.java Tue Sep  9 12:00:32 2014
@@ -0,0 +1,43 @@
+package org.apache.sirona.reporting.web.sessions;
+
+import org.apache.sirona.Role;
+import org.apache.sirona.counters.Unit;
+import org.apache.sirona.reporting.web.Graph;
+import org.apache.sirona.repositories.Repositories;
+import org.apache.sirona.repositories.Repository;
+import org.apache.sirona.web.session.SessionGauge;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @since 0.3
+ */
+@Path( "/sessions" )
+public class SessionsReports
+{
+
+    @GET
+    @Path( "/{start}/{end}" )
+    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+    public List<Graph> sessions( @PathParam( "start" ) final long start, @PathParam( "end" ) final long end )
+    {
+
+        List<Graph> graphs = new ArrayList<Graph>();
+
+        for ( final Role gauge : Repositories.findByPrefixAndUnit( SessionGauge.SESSIONS_PREFIX, Unit.UNARY ) )
+        {
+
+            graphs.add( new Graph( "Sessions-" + gauge.getName(), Graph.DEFAULT_COLOR, //
+                                   Repository.INSTANCE.getGaugeValues( start, end, gauge ) ) );
+        }
+
+        return graphs;
+    }
+
+}

Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/sessions/SessionsReports.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/sessions/SessionsReports.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/index.html?rev=1623777&r1=1623776&r2=1623777&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/index.html (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/index.html Tue Sep  9 12:00:32 2014
@@ -78,6 +78,9 @@
               <a href="#jta">JTA</a>
             </li>
             <li>
+              <a href="#sessions">Sessions</a>
+            </li>
+            <li>
               <a href="#threads">Threads</a>
             </li>
           </ul>

Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-jta.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-jta.js?rev=1623777&r1=1623776&r2=1623777&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-jta.js (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-jta.js Tue Sep  9 12:00:32 2014
@@ -22,9 +22,9 @@ define(['jquery','angular','bootstrap','
   var dayDuration = 24 * 3600 * 1000;
 
 
-  var jvmControllers = angular.module('jtaControllers', ['sironaServices','ui.bootstrap','ui.bootstrap.datetimepicker']);
+  var jtaControllers = angular.module('jtaControllers', ['sironaServices','ui.bootstrap','ui.bootstrap.datetimepicker']);
 
-  jvmControllers.controller( 'jtaHomeCtrl', ['$scope','jtaCommits','jtaRollbacks','jtaActives',
+  jtaControllers.controller( 'jtaHomeCtrl', ['$scope','jtaCommits','jtaRollbacks','jtaActives',
     function ( $scope,jtaCommits,jtaRollbacks,jtaActives){
 
       console.log("jtaHomeCtrl");

Added: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-sessions.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-sessions.js?rev=1623777&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-sessions.js (added)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-sessions.js Tue Sep  9 12:00:32 2014
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+'use strict';
+
+/* Controllers */
+define(['jquery','angular','bootstrap','services','morris','ui-bootstrap','datetimepicker'], function (){
+
+  var dayDuration = 24 * 3600 * 1000;
+
+
+  var sessionsControllers = angular.module('sessionsControllers', ['sironaServices','ui.bootstrap','ui.bootstrap.datetimepicker']);
+
+  sessionsControllers.controller( 'sessionsHomeCtrl', ['$scope','sessions',
+    function ( $scope,sessions){
+
+      console.log("jtaHomeCtrl");
+      $scope.data={};
+      $scope.data.startDate = new Date();
+      $scope.data.startDate.setTime($scope.data.startDate.getTime() - dayDuration);
+
+
+      $scope.data.endDate = new Date();
+
+      $scope.data.format = 'dd/MM/yyyy HH:mm:ss';
+
+      jQuery("#dropdown-enddate").dropdown();
+      jQuery("#dropdown-startdate").dropdown();
+
+      var drawSessions = function(){
+        sessions.query({start: $scope.data.startDate.getTime(),end: $scope.data.endDate.getTime()} ).$promise.then( function ( results ){
+          $scope.commitsResults = toMorrisFormat( results.data );
+          jQuery("#sessions").empty();
+          Morris.Line({
+                        element: 'sessions',
+                        data: $scope.commitsResults,
+                        xkey: 'x',
+                        ykeys: 'y',
+                        labels: [results.label],
+                        xLabelFormat: function ( ret ){
+                          var date = new Date();
+                          date.setTime($scope.commitsResults[ret.x].x);
+                          return date.toLocaleString();
+                        },
+                        parseTime: false,
+                        hideHover: 'auto'
+                      });
+          });
+      };
+
+
+
+
+      $scope.updateGraphs = function(){
+        drawSessions();
+      };
+
+      $scope.updateGraphs();
+
+  }]);
+
+
+  var toMorrisFormat=function(reportResult){
+    if (reportResult==null){
+      console.log("reportResult==null");
+      return [];
+    }
+    var values = [];
+    angular.forEach(reportResult, function(key,value) {
+      this.push({x:value,y: key});
+    }, values);
+
+
+    return values;
+  }
+
+});
+
+
+
+
+

Propchange: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-sessions.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-sessions.js
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js?rev=1623777&r1=1623776&r2=1623777&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/services/services.js Tue Sep  9 12:00:32 2014
@@ -145,4 +145,12 @@ define(['angular','angular-resource'], f
     }
   ]);
 
+  sironaServices.factory('sessions', ['$resource',
+    function($resource){
+      return $resource('restServices/sironaServices/sessions/:start/:end',
+                       {start:'@start',end:'@end'},
+                       {query: {method:'GET', params:{},isArray:true}});
+    }
+  ]);
+
 });
\ No newline at end of file

Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/main.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/main.js?rev=1623777&r1=1623776&r2=1623777&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/main.js (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/main.js Tue Sep  9 12:00:32 2014
@@ -43,6 +43,7 @@ require.config({
     'controllers-status': 'app/controllers/controllers-status',
     'controllers-jmx': 'app/controllers/controllers-jmx',
     'controllers-jta': 'app/controllers/controllers-jta',
+    'controllers-sessions': 'app/controllers/controllers-sessions',
     'services': 'app/services/services',
     'sirona': 'sirona',
     'morris': 'plugins/morris/morris-0.5.0.min',

Modified: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js?rev=1623777&r1=1623776&r2=1623777&view=diff
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js (original)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/sirona.js Tue Sep  9 12:00:32 2014
@@ -18,7 +18,8 @@
 'use strict';
 
 define(['jquery','controllers','controllers-jvm','controllers-threads','controllers-gauges','angular-route',
-         'bootstrap','datetimepicker','controllers-report','controllers-status','controllers-jmx','controllers-jta'],
+         'bootstrap','datetimepicker','controllers-report','controllers-status','controllers-jmx','controllers-jta',
+         'controllers-sessions'],
        function (jquery,controllers) {
 
   var sirona = angular.module('sirona', [
@@ -30,7 +31,8 @@ define(['jquery','controllers','controll
     'gaugesControllers',
     'statusControllers',
     'jmxControllers',
-    'jtaControllers'
+    'jtaControllers',
+    'sessionsControllers'
   ]);
 
   sirona.config(['$routeProvider','$logProvider',
@@ -109,6 +111,12 @@ define(['jquery','controllers','controll
                controller: 'jmxDetailCtrl'
              }
         ).
+        when('/sessions',
+             {
+               templateUrl: 'partials/sessions.html',
+               controller: 'sessionsHomeCtrl'
+             }
+        ).
         otherwise({
           redirectTo: '/home'
         });

Added: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/sessions.html
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/sessions.html?rev=1623777&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/sessions.html (added)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/sessions.html Tue Sep  9 12:00:32 2014
@@ -0,0 +1,70 @@
+<!--
+  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.
+-->
+<div class="row">
+  <div class="col-lg-2">
+  </div>
+  <div class="col-lg-4">
+    <div class="dropdown">
+      <label for="datetimepicker-from">From</label>
+      <a class="dropdown-toggle" id="dropdown-startdate" role="button" data-toggle="dropdown" data-target="#" href="#">
+        <button type="button" class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></button>
+      </a>
+      <input type="text" class="form-control" data-ng-model="data.startDate" id="datetimepicker-from" disabled>
+      <ul class="dropdown-menu" role="menu" aria-labelledby="dropdown-enddate">
+        <li>
+          <datetimepicker data-ng-model="data.startDate" data-datetimepicker-config="{  }"/>
+        </li>
+      </ul>
+    </div>
+  </div>
+  <div class="col-lg-4">
+    <div class="dropdown">
+      <label for="datetimepicker-to">To</label>
+      <a class="dropdown-toggle" id="dropdown-enddate" role="button" data-toggle="dropdown" data-target="#" href="#">
+        <button type="button" class="btn btn-default"><i class="glyphicon glyphicon-calendar"></i></button>
+      </a>
+      <input type="text" class="form-control" data-ng-model="data.endDate" id="datetimepicker-to" disabled>
+      <ul class="dropdown-menu" role="menu" aria-labelledby="dropdown-enddate">
+        <li>
+          <datetimepicker data-ng-model="data.endDate" data-datetimepicker-config="{  }"/>
+        </li>
+      </ul>
+    </div>
+  </div>
+  <div class="col-lg-2">
+    <button type="button" class="btn btn-primary" ng-click="updateGraphs()">Update</button>
+  </div>
+</div>
+<div class="row">
+  <div class="col-lg-12">
+    <div class="panel panel-primary">
+      <div class="panel-heading">
+        <h3 class="panel-title">
+          <i class="icon-bar-chart"></i>Sessions
+        </h3>
+      </div>
+      <div class="panel-body">
+        <div class="row">
+          <div id="sessions"><i class="fa fa-spinner fa-spin"></i></div>
+        </div>
+      </div>
+
+    </div>
+
+  </div>
+
+</div>
\ No newline at end of file

Propchange: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/sessions.html
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/sessions.html
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision