提交 513a1249 编写于 作者: K kohsuke

implemented #210.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1405 71c3de6d-444a-0410-be80-ed276b4c234a
上级 88106b45
......@@ -21,9 +21,23 @@ import java.io.File;
import javax.servlet.http.HttpServletResponse;
/**
* Utility functions used in views.
*
* <p>
* An instance of this class is created for each request.
*
* @author Kohsuke Kawaguchi
*/
public class Functions {
private int iota=0;
/**
* Generates an unique ID.
*/
public String generateId() {
return "id"+iota++;
}
public static boolean isModel(Object o) {
return o instanceof ModelObject;
}
......
......@@ -6,6 +6,9 @@ import org.kohsuke.stapler.StaplerResponse;
import javax.servlet.ServletException;
import java.io.IOException;
import hudson.Functions;
import hudson.Util;
/**
* Thread that executes builds.
......@@ -114,6 +117,23 @@ public class Executor extends Thread {
return num;
}
/**
* Computes a human-readable text that shows the expected remaining time
* until the build completes.
*/
public String getEstimatedRemainingTime() {
Build b = build.getProject().getLastSuccessfulBuild();
if(b==null) return "N/A";
long duration = b.getDuration();
if(duration==0) return "N/A";
long eta = duration-(System.currentTimeMillis()-startTime);
if(eta<=0) return "N/A";
return Util.getTimeSpanString(eta);
}
/**
* Stops the current build.
*/
......
......@@ -53,7 +53,7 @@
<tr><td></td><td style="padding:0">
<table class="middle-align">
<tr><td>
<t:progressBar pos="${build.executor.progress}" href="${link}console"/>
<t:buildProgressBar build="${build}"/>
</td><td style="padding:0">
<a href="${link}stop"><img src="${rootURL}/images/16x16/stop.gif" alt="[cancel]"/></a>
</td></tr>
......
......@@ -9,7 +9,7 @@
<td>
Progress:
</td><td>
<t:progressBar pos="${it.executor.progress}"/>
<t:buildProgressBar build="${it}"/>
</td><td>
<a href="stop"><img src="${rootURL}/images/16x16/stop.gif" alt="[cancel]" /></a>
</td>
......
<!--
Progress bar for a build in progress.
Attributes:
@build: build in progress
-->
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:set var="id" value="${h.generateId()}"/>
<t:progressBar id="${id}" pos="${build.executor.progress}" href="${rootURL}/${build.url}console"/>
<script>
new YAHOO.widget.Tooltip("tooltip-${id}", {
context:"${id}",
text:"Started ${build.timestampString} ago&lt;br> Estimated remaining time: ${build.executor.estimatedRemainingTime}",
showDelay:500 } );
</script>
</j:jelly>
......@@ -43,7 +43,7 @@
<j:otherwise>
<td class="pane" width="70%">
<div nowrap="true">Building <a href="${rootURL}/${e.currentBuild.url}">${e.currentBuild}</a></div>
<t:progressBar pos="${e.progress}" href="${rootURL}/${e.currentBuild.url}console"/>
<t:buildProgressBar build="${e.currentBuild}"/>
</td>
<td class="pane" width="16" align="center" valign="middle">
<a href="${rootURL}/computers/${cloop.index}/executors/${eloop.index}/stop"><img src="${rootURL}/images/16x16/stop.gif" alt="terminate this build" /></a>
......
......@@ -7,7 +7,10 @@
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<x:element name="table">
<x:attribute name="class">progress-bar</x:attribute>
<j:if test="${href!=null}">
<j:if test="${attrs.id!=null}">
<x:attribute name="id">${id}</x:attribute>
</j:if>
<j:if test="${href!=null}">
<x:attribute name="style">cursor:pointer</x:attribute>
<x:attribute name="onclick">window.location='${href}'</x:attribute>
<!-- note that this won't take effect in browsers that don't let JavaScript change status bar, like Firefox. -->
......
......@@ -22,14 +22,12 @@
<script src="${rootURL}/scripts/sortable.js" type="text/javascript"></script>
<script src="${rootURL}/scripts/hudson-behavior.js" type="text/javascript"></script>
<!-- include YUI scripts
<j:set var="yuiSuffix" value="${h.yuiSuffix}" />
<script src="${rootURL}/scripts/yui/yahoo-${yuiSuffix}.js"></script>
<script src="${rootURL}/scripts/yui/dom-${yuiSuffix}.js"></script>
<script src="${rootURL}/scripts/yui/event-${yuiSuffix}.js"></script>
<script src="${rootURL}/scripts/yui/container-${yuiSuffix}.js"></script>
<link rel="stylesheet" href="${rootURL}/scripts/yui/container.css" type="text/css"/>
-->
<meta name="ROBOTS" content="INDEX,NOFOLLOW" />
<j:set var="mode" value="header" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册