continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From batkin...@apache.org
Subject svn commit: r1659455 - in /continuum/trunk: ./ continuum-webapp/ continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ continuum-webapp/src/main/resources/ continuum-webapp/src/main/webapp/WEB-INF/jsp/
Date Fri, 13 Feb 2015 04:59:03 GMT
Author: batkinson
Date: Fri Feb 13 04:59:02 2015
New Revision: 1659455

URL: http://svn.apache.org/r1659455
Log:
[CONTINUUM-1171] Added ability to 'tail' build command output when in progress.

Modified:
    continuum/trunk/continuum-webapp/pom.xml
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
    continuum/trunk/continuum-webapp/src/main/resources/struts.xml
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp
    continuum/trunk/pom.xml

Modified: continuum/trunk/continuum-webapp/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/pom.xml?rev=1659455&r1=1659454&r2=1659455&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/pom.xml (original)
+++ continuum/trunk/continuum-webapp/pom.xml Fri Feb 13 04:59:02 2015
@@ -576,7 +576,10 @@
     <dependency>
       <groupId>org.apache.struts</groupId>
       <artifactId>struts2-spring-plugin</artifactId>
-      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.struts</groupId>
+      <artifactId>struts2-json-plugin</artifactId>
     </dependency>
     <dependency>
       <groupId>javax.servlet</groupId>

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java?rev=1659455&r1=1659454&r2=1659455&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
(original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
Fri Feb 13 04:59:02 2015
@@ -49,7 +49,7 @@ import java.util.Map;
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  */
-@Component( role = com.opensymphony.xwork2.Action.class, hint = "buildResult", instantiationStrategy
= "per-lookup"  )
+@Component( role = com.opensymphony.xwork2.Action.class, hint = "buildResult", instantiationStrategy
= "per-lookup" )
 public class BuildResultAction
     extends AbstractBuildAction
 {
@@ -287,4 +287,9 @@ public class BuildResultAction
     {
         this.distributedBuildManager = distributedBuildManager;
     }
+
+    public boolean isBuildInProgress()
+    {
+        return buildResult.getState() == ContinuumProjectState.BUILDING;
+    }
 }

Modified: continuum/trunk/continuum-webapp/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/resources/struts.xml?rev=1659455&r1=1659454&r2=1659455&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/resources/struts.xml (original)
+++ continuum/trunk/continuum-webapp/src/main/resources/struts.xml Fri Feb 13 04:59:02 2015
@@ -32,7 +32,7 @@
   <!-- Include plexus-security xwork configurations. -->
   <include file="struts-security.xml"/>
 
-  <package name="default" extends="struts-default">
+  <package name="default" extends="json-default">
 
     <interceptors>
       <interceptor-stack name="defaultStack">
@@ -496,6 +496,15 @@
       </result>
     </action>
 
+    <action name="buildOutputJSON" class="buildResult">
+      <result type="json">
+        <param name="includeProperties">
+          ^buildInProgress$,
+          ^buildOutput$
+        </param>
+      </result>
+    </action>
+
     <action name="removeBuildResult" class="buildResult" method="remove">
       <interceptor-ref name="storeStack">
         <param name="tokenSession.includeMethods">remove</param>

Modified: continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp?rev=1659455&r1=1659454&r2=1659455&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp (original)
+++ continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/buildResult.jsp Fri Feb 13
04:59:02 2015
@@ -27,6 +27,56 @@
   <s:i18n name="localization.Continuum">
     <head>
         <title><s:text name="buildResult.page.title"/></title>
+        <script type="text/javascript">
+          <s:url id="outputAsyncUrl" action="buildOutputJSON" escapeAmp="false">
+            <s:param name="projectId" value="projectId"/>
+            <s:param name="buildId" value="buildId"/>
+          </s:url>
+          jQuery(document).ready(function($) {
+
+            var buildInProgress = <s:property value="buildInProgress" />;
+            var outputUrl = '<s:property value="#outputAsyncUrl" escapeHtml="false" />';
+            var refreshPending = false;
+
+            var $ta = $('#outputArea');
+
+            function scrollToBottom($textArea) {
+              var newHeight = $textArea.attr('scrollHeight');
+              $textArea.attr('scrollTop', newHeight);
+            }
+
+            function isScrolledToBottom($textArea) {
+              return $textArea.attr('scrollHeight') - $textArea.attr('clientHeight') == $textArea.attr('scrollTop')
+            }
+
+            // Scroll text area to bottom on page load
+            scrollToBottom($ta);
+
+            setInterval(function() {
+              if (buildInProgress && !refreshPending) {
+                refreshPending = true;
+                var autoScroll = isScrolledToBottom($ta);
+                $.ajax({
+                  url: outputUrl,
+                  contentType: 'application/json;charset=utf-8',
+                  success: function(data) {
+                    parsed = JSON.parse(data);
+                    $ta.html(parsed.buildOutput);
+                    if (autoScroll) {
+                      scrollToBottom($ta);
+                    }
+                    if (!parsed.buildInProgress) {
+                      location.reload();  // reload page when complete
+                    }
+                  },
+                  complete: function() {
+                    refreshPending = false;
+                  }
+                });
+              }
+            }, 5000);
+          });
+        </script>
     </head>
     <body>
       <div id="h3">
@@ -266,7 +316,7 @@
                 <s:param name="buildId" value="buildId"/>
               </s:url>
               <s:a href="%{buildOutputTextUrl}"><s:text name="buildResult.buildOutput.text"/></s:a>
-              <div class="cmd-output pre-wrap"><s:property value="buildOutput"/></div>
+              <div id="outputArea" class="cmd-output pre-wrap"><s:property value="buildOutput"/></div>
             </s:else>
           </p>
         </s:else>

Modified: continuum/trunk/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/pom.xml?rev=1659455&r1=1659454&r2=1659455&view=diff
==============================================================================
--- continuum/trunk/pom.xml (original)
+++ continuum/trunk/pom.xml Fri Feb 13 04:59:02 2015
@@ -1220,6 +1220,17 @@
           </exclusion>
         </exclusions>
       </dependency>
+      <dependency>
+        <groupId>org.apache.struts</groupId>
+        <artifactId>struts2-json-plugin</artifactId>
+        <version>${struts.version}</version>
+        <exclusions>
+          <exclusion>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+          </exclusion>
+        </exclusions>
+      </dependency>
       <!--
         Plexus Redback Dependencies
         -->



Mime
View raw message