portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r1678028 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main: java/org/apache/jetspeed/jetapp/ webapp/WEB-INF/ webapp/jetapp/scripts/
Date Wed, 06 May 2015 15:31:18 GMT
Author: taylor
Date: Wed May  6 15:31:17 2015
New Revision: 1678028

URL: http://svn.apache.org/r1678028
Log:
JS2-1320: improve charts, adding mouse over to page chart. Refactored JetApp portlets to no
longer use portlet filters

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppChartPortlet.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppPortlet.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppPortletFilter.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/wro.xml
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/jetapp/scripts/chartControllers.js

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppChartPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppChartPortlet.java?rev=1678028&r1=1678027&r2=1678028&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppChartPortlet.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppChartPortlet.java
Wed May  6 15:31:17 2015
@@ -50,6 +50,7 @@ public class JetAppChartPortlet extends
             addJavaScript(response, request.getContextPath() + pair[0], pair[1]);
         }
 
+        includeAngluar(request, response);
     }
 
 }

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppPortlet.java?rev=1678028&r1=1678027&r2=1678028&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppPortlet.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppPortlet.java
Wed May  6 15:31:17 2015
@@ -51,6 +51,15 @@ public class JetAppPortlet extends Gener
 
     protected static Log log = LogFactory.getLog(JetAppPortlet.class);
 
+    // aggregation flags to limit contributions per page
+    protected final static String JETAPP_ANGULAR_FLAG = "jetapp.angular.flag";
+    protected final static String JETAPP_HEADERS_FLAG = "jetapp.headers.flag";
+
+    // Angular Bootstrap script
+    protected final String ANGULAR = "<script>\n    angular.element(document).ready(function()
{\n" +
+            "        angular.bootstrap(document, ['j2admin']);\n" +
+            "    });\n</script>\n";
+
     // Web Resource IDs
     protected static final String J2_ADMIN_CSS_ID = "j2admin_css";
     protected static final String J2_ADMIN_EXTERNAL_SCRIPT_ID = "j2admin_ext_script";
@@ -80,7 +89,7 @@ public class JetAppPortlet extends Gener
             { "/jetapp/scripts/StatisticsRestServices.js", "j2admin_statistics"},
             { "/jetapp/app.js", "j2admin_app"},
             { "/jetapp/scripts/controllers.js", "j2admin_controllers"},
-            { "/jetapp/scripts/chartControllers.js", "j2admin_chart_ontrollers"},
+            { "/jetapp/scripts/chartControllers.js", "j2admin_chart_controllers"},
             { "/jetapp/scripts/directives.js", "j2admin_directives"},
             { "/jetapp/scripts/filters.js", "j2admin_filters"}
     };
@@ -152,6 +161,17 @@ public class JetAppPortlet extends Gener
             addJavaScript(response, request.getContextPath() + pair[0], pair[1]);
         }
 
+        includeAngluar(request, response);
+    }
+
+    protected void includeAngluar(RenderRequest request, RenderResponse response) {
+        // contribute Angular once
+        try {
+            response.getWriter().write(ANGULAR.toCharArray());
+        }
+        catch (IOException e) {
+            log.error("Failed to include Angular bits", e);
+        }
     }
 
     public String createError(int httpCode, String message) throws IOException {
@@ -179,6 +199,7 @@ public class JetAppPortlet extends Gener
             }
         return null;
     }
+
     // JBossAS7...
     //        try {
     //            return (HttpServletRequest) PolicyContext.getContext("javax.servlet.http.HttpServletRequest");
@@ -188,15 +209,14 @@ public class JetAppPortlet extends Gener
     //        }
 
 
-    protected final static String GW_DASHBOARD_PORTLET_FLAG = "gw.dashboard.portlet.flag";
 
     protected boolean alreadyContributedHeaders(RenderRequest renderRequest) {
         HttpServletRequest request = getServletRequest(renderRequest);
         if (request == null)
             return false;
-        Boolean contributed = (Boolean)request.getAttribute(GW_DASHBOARD_PORTLET_FLAG);
+        Boolean contributed = (Boolean)request.getAttribute(JETAPP_HEADERS_FLAG);
         if (contributed == null || contributed == false) {
-            request.setAttribute(GW_DASHBOARD_PORTLET_FLAG, Boolean.TRUE);
+            request.setAttribute(JETAPP_HEADERS_FLAG, Boolean.TRUE);
             return false;
         }
         return true;
@@ -220,6 +240,7 @@ public class JetAppPortlet extends Gener
 
     }
 
+
 }
 
 

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppPortletFilter.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppPortletFilter.java?rev=1678028&r1=1678027&r2=1678028&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppPortletFilter.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/jetapp/JetAppPortletFilter.java
Wed May  6 15:31:17 2015
@@ -63,6 +63,7 @@ public class JetAppPortletFilter impleme
         String useAngular = request.getPreferences().getValue("jetapp", null);
         if (useAngular != null && useAngular.equalsIgnoreCase("true")) {
             if (!alreadyContributedAngular(request)) {
+                response.getWriter().flush();;
                 //response.getWriter().write(ANGULAR.toCharArray());
                 response.getPortletOutputStream().write(ANGULAR.getBytes());
             }

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml?rev=1678028&r1=1678027&r2=1678028&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml Wed
May  6 15:31:17 2015
@@ -2753,10 +2753,6 @@
         <name>rowsPerPage</name>
         <value>20</value>
       </preference>
-      <preference>
-        <name>jetapp</name>
-        <value>true</value>
-      </preference>
     </portlet-preferences>
   </portlet>
 
@@ -2781,10 +2777,6 @@
         <name>View</name>
         <value>/jetapp/charts/chart-memory.html</value>
       </preference>
-        <preference>
-            <name>jetapp</name>
-            <value>true</value>
-        </preference>
     </portlet-preferences>
   </portlet>
 
@@ -2809,10 +2801,6 @@
         <name>View</name>
         <value>/jetapp/charts/chart-pages.html</value>
       </preference>
-      <preference>
-            <name>jetapp</name>
-            <value>true</value>
-      </preference>
     </portlet-preferences>
   </portlet>
 
@@ -2837,10 +2825,6 @@
         <name>View</name>
         <value>/jetapp/charts/chart-users.html</value>
       </preference>
-      <preference>
-            <name>jetapp</name>
-            <value>true</value>
-      </preference>
     </portlet-preferences>
   </portlet>
 
@@ -2865,10 +2849,6 @@
         <name>View</name>
         <value>/jetapp/charts/chart-caches.html</value>
       </preference>
-        <preference>
-            <name>jetapp</name>
-            <value>true</value>
-        </preference>
     </portlet-preferences>
   </portlet>
 
@@ -2893,15 +2873,4 @@
     <portlet-mode>print</portlet-mode>
   </custom-portlet-mode>
 
-  <filter>
-    <filter-name>JetAppPortletFilter</filter-name>
-    <filter-class>org.apache.jetspeed.jetapp.JetAppPortletFilter</filter-class>
-    <lifecycle>RENDER_PHASE</lifecycle>
-  </filter>
-
-  <filter-mapping>
-    <filter-name>JetAppPortletFilter</filter-name>
-    <portlet-name>*</portlet-name>
-  </filter-mapping>
-
 </portlet-app>

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/wro.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/wro.xml?rev=1678028&r1=1678027&r2=1678028&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/wro.xml (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/wro.xml Wed May
 6 15:31:17 2015
@@ -32,10 +32,13 @@
         <js minimize="false">/jetapp/scripts/ServerService.js</js>
         <js minimize="false">/jetapp/scripts/RestApiService.js</js>
         <js minimize="false">/jetapp/scripts/PortletService.js</js>
+        <js minimize="false">/jetapp/scripts/StatisticsRestServices.js</js>
         <js minimize="false">/jetapp/app.js</js>
         <js minimize="false">/jetapp/scripts/controllers.js</js>
+        <js minimize="false">/jetapp/scripts/chartControllers.js</js>
         <js minimize="false">/jetapp/scripts/directives.js</js>
         <js minimize="false">/jetapp/scripts/filters.js</js>
     </group>
 
 </groups>
+

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/jetapp/scripts/chartControllers.js
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/jetapp/scripts/chartControllers.js?rev=1678028&r1=1678027&r2=1678028&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/jetapp/scripts/chartControllers.js
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/jetapp/scripts/chartControllers.js
Wed May  6 15:31:17 2015
@@ -139,11 +139,13 @@ angular.module('j2admin.chartControllers
                     // Process page data:
                     var datum = [{key: "Page Hits", values: []}];
 
-//                    console.log('>>>>>>> pageHits: ' +JSON.stringify($scope.pageHits));
-
                     for (var label in $scope.pageHits.pages) {
-                        datum[0].values.push({label: label, value: $scope.pageHits.pages[label]})
-                        }
+                        var index = label.lastIndexOf("/");
+                        var simpleLabel = (index > -1) ? label.substring(index+1) : label;
+                        index = simpleLabel.lastIndexOf(".psml");
+                        simpleLabel = (index > -1) ? simpleLabel.substring(0, index) :
simpleLabel;
+                        datum[0].values.push({label: simpleLabel, fullLabel: label, value:
$scope.pageHits.pages[label]})
+                    }
 
                     nv.addGraph(function () {
                         var chart = nv.models.discreteBarChart()
@@ -153,9 +155,18 @@ angular.module('j2admin.chartControllers
                             .y(function (d) {
                                 return d.value
                             })
-                            .tooltips(false)        //Don't show tooltips
-                            .showValues(true)       //...instead, show the bar value right
on top of each bar.
-                            .duration(500);
+                            .tooltips(true)
+                            .showValues(true)
+                            .duration(500)
+                            .tooltipContent(function(key, y, e, graph) {
+                                for (var x in datum[0].values) {
+                                    if (datum[0].values[x].label == y) {
+                                        return datum[0].values[x].fullLabel;
+                                    }
+                                }
+                                return y;
+                            });
+
 
                         chart.yAxis.tickFormat(function (d) {
                             return d3.format('g')(d);



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message