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 08:42:56 UTC

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

Author: olamy
Date: Tue Sep  9 06:42:55 2014
New Revision: 1623673

URL: http://svn.apache.org/r1623673
Log:
better with adding files

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

Added: incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/jta/JTAReports.java
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/jta/JTAReports.java?rev=1623673&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/jta/JTAReports.java (added)
+++ incubator/sirona/trunk/server/reporting/reporting-api/src/main/java/org/apache/sirona/reporting/web/jta/JTAReports.java Tue Sep  9 06:42:55 2014
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+package org.apache.sirona.reporting.web.jta;
+
+import org.apache.sirona.Role;
+import org.apache.sirona.counters.Unit;
+import org.apache.sirona.reporting.web.Graph;
+import org.apache.sirona.repositories.Repository;
+
+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.SortedMap;
+
+/**
+ * @since 0.3
+ */
+@Path( "/jtareports" )
+public class JTAReports
+{
+
+    // copied to avoid classloading issue depending on the deployment, see org.apache.sirona.jta.JTAGauges
+    private static final Role COMMITED = new Role( "jta-commited", Unit.UNARY );
+
+    private static final Role ROLLBACKED = new Role( "jta-rollbacked", Unit.UNARY );
+
+    private static final Role ACTIVE = new Role( "jta-active", Unit.UNARY );
+
+    @GET
+    @Path( "/commits/{start}/{end}" )
+    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+    public Graph commit( @PathParam( "start" ) final long start, @PathParam( "end" ) final long end )
+    {
+        final SortedMap<Long, Double> gaugeValues = Repository.INSTANCE.getGaugeValues( start, end, COMMITED );
+        return new Graph( "Commits", Graph.DEFAULT_COLOR, gaugeValues );
+
+    }
+
+    @GET
+    @Path( "/rollbacks/{start}/{end}" )
+    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+    public Graph rollback( @PathParam( "start" ) final long start, @PathParam( "end" ) final long end )
+    {
+        final SortedMap<Long, Double> gaugeValues = Repository.INSTANCE.getGaugeValues( start, end, ROLLBACKED );
+        return new Graph( "Rollbacks", Graph.DEFAULT_COLOR, gaugeValues );
+
+    }
+
+    @GET
+    @Path( "/actives/{start}/{end}" )
+    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+    public Graph active( @PathParam( "start" ) final long start, @PathParam( "end" ) final long end )
+    {
+        final SortedMap<Long, Double> gaugeValues = Repository.INSTANCE.getGaugeValues( start, end, ACTIVE );
+        return new Graph( "Actives", Graph.DEFAULT_COLOR, gaugeValues );
+
+    }
+
+}

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

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

Added: 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=1623673&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-jta.js (added)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/js/app/controllers/controllers-jta.js Tue Sep  9 06:42:55 2014
@@ -0,0 +1,138 @@
+/*
+ * 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 jvmControllers = angular.module('jtaControllers', ['sironaServices','ui.bootstrap','ui.bootstrap.datetimepicker']);
+
+  jvmControllers.controller( 'jtaHomeCtrl', ['$scope','jtaCommits','jtaRollbacks','jtaActives',
+    function ( $scope,jtaCommits,jtaRollbacks,jtaActives){
+
+      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 drawCommits = function(){
+        jtaCommits.query({start: $scope.data.startDate.getTime(),end: $scope.data.endDate.getTime()} ).$promise.then( function ( results ){
+          $scope.commitsResults = toMorrisFormat( results.data );
+          jQuery("#commits").empty();
+          Morris.Line({
+                        element: 'commits',
+                        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'
+                      });
+          });
+      };
+
+
+      var drawRollbacks = function(){
+        jtaRollbacks.query({start: $scope.data.startDate.getTime(),end: $scope.data.endDate.getTime()} ).$promise.then( function ( results ){
+          $scope.rollbacksResults = toMorrisFormat( results.data );
+          jQuery("#rollbacks").empty();
+          Morris.Line({
+                        element: 'rollbacks',
+                        data: $scope.rollbacksResults,
+                        xkey: 'x',
+                        ykeys: 'y',
+                        labels: [results.label],
+                        xLabelFormat: function ( ret ){
+                          var date = new Date();
+                          date.setTime($scope.rollbacksResults[ret.x].x);
+                          return date.toLocaleString();
+                        },
+                        parseTime: false,
+                        hideHover: 'auto'
+                      });
+        });
+      };
+
+
+      var drawActives = function(){
+        jtaActives.query({start: $scope.data.startDate.getTime(),end: $scope.data.endDate.getTime()} ).$promise.then( function ( results ){
+          $scope.activesResults = toMorrisFormat( results.data );
+          jQuery("#actives").empty();
+          Morris.Line({
+                        element: 'actives',
+                        data: $scope.activesResults,
+                        xkey: 'x',
+                        ykeys: 'y',
+                        labels: [results.label],
+                        xLabelFormat: function ( ret ){
+                          var date = new Date();
+                          date.setTime($scope.activesResults[ret.x].x);
+                          return date.toLocaleString();
+                        },
+                        parseTime: false,
+                        hideHover: 'auto'
+                      });
+        });
+      };
+
+      $scope.updateGraphs = function(){
+        drawCommits();
+        drawRollbacks();
+        drawActives();
+      };
+
+      $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-jta.js
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/jta.html
URL: http://svn.apache.org/viewvc/incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/jta.html?rev=1623673&view=auto
==============================================================================
--- incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/jta.html (added)
+++ incubator/sirona/trunk/server/reporting/reporting-ui/src/main/webapp/partials/jta.html Tue Sep  9 06:42:55 2014
@@ -0,0 +1,96 @@
+<!--
+  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-4">
+    <div class="panel panel-primary">
+      <div class="panel-heading">
+        <h3 class="panel-title">
+          <i class="icon-bar-chart"></i>Commits
+        </h3>
+      </div>
+      <div class="panel-body">
+        <div class="row">
+          <div id="commits"><i class="fa fa-spinner fa-spin"></i></div>
+        </div>
+      </div>
+
+    </div>
+
+  </div>
+  <div class="col-lg-4">
+    <div class="panel panel-primary">
+      <div class="panel-heading">
+        <h3 class="panel-title">
+          <i class="icon-bar-chart"></i>Rollbacks
+        </h3>
+      </div>
+      <div class="panel-body">
+        <div id="rollbacks"><i class="fa fa-spinner fa-spin"></i></div>
+      </div>
+    </div>
+
+  </div>
+  <div class="col-lg-4">
+    <div class="panel panel-primary">
+      <div class="panel-heading">
+        <h3 class="panel-title">
+          <i class="icon-bar-chart"></i>Actives
+        </h3>
+      </div>
+      <div class="panel-body">
+        <div id="actives"><i class="fa fa-spinner fa-spin"></i></div>
+      </div>
+    </div>
+
+  </div>
+
+</div>
\ No newline at end of file

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

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