diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 148dfd64e9..12a53246c1 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -21,9 +21,23 @@ import java.io.File; import javax.servlet.http.HttpServletResponse; /** + * Utility functions used in views. + * + *

+ * 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; } diff --git a/core/src/main/java/hudson/model/Executor.java b/core/src/main/java/hudson/model/Executor.java index 4ed48d08c8..8af955004a 100644 --- a/core/src/main/java/hudson/model/Executor.java +++ b/core/src/main/java/hudson/model/Executor.java @@ -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. */ diff --git a/core/src/main/resources/hudson/model/Job/buildHistory.jelly b/core/src/main/resources/hudson/model/Job/buildHistory.jelly index 340d671873..98f6bc6815 100644 --- a/core/src/main/resources/hudson/model/Job/buildHistory.jelly +++ b/core/src/main/resources/hudson/model/Job/buildHistory.jelly @@ -53,7 +53,7 @@ diff --git a/core/src/main/resources/lib/hudson/buildCaption.jelly b/core/src/main/resources/lib/hudson/buildCaption.jelly index 17e5c16a40..a6f45cb8ca 100644 --- a/core/src/main/resources/lib/hudson/buildCaption.jelly +++ b/core/src/main/resources/lib/hudson/buildCaption.jelly @@ -9,7 +9,7 @@ diff --git a/core/src/main/resources/lib/hudson/buildProgressBar.jelly b/core/src/main/resources/lib/hudson/buildProgressBar.jelly new file mode 100644 index 0000000000..4bcc41ce04 --- /dev/null +++ b/core/src/main/resources/lib/hudson/buildProgressBar.jelly @@ -0,0 +1,16 @@ + + + + + + diff --git a/core/src/main/resources/lib/hudson/executors.jelly b/core/src/main/resources/lib/hudson/executors.jelly index de59a63700..62f42b046f 100644 --- a/core/src/main/resources/lib/hudson/executors.jelly +++ b/core/src/main/resources/lib/hudson/executors.jelly @@ -43,7 +43,7 @@
- + [cancel]
Progress: - + [cancel] - + terminate this build diff --git a/core/src/main/resources/lib/hudson/progressBar.jelly b/core/src/main/resources/lib/hudson/progressBar.jelly index ba95b51df3..9d7b710c3f 100644 --- a/core/src/main/resources/lib/hudson/progressBar.jelly +++ b/core/src/main/resources/lib/hudson/progressBar.jelly @@ -7,7 +7,10 @@ progress-bar - + + ${id} + + cursor:pointer window.location='${href}' diff --git a/core/src/main/resources/lib/layout/layout.jelly b/core/src/main/resources/lib/layout/layout.jelly index 77eced6a61..39e2d70ca9 100644 --- a/core/src/main/resources/lib/layout/layout.jelly +++ b/core/src/main/resources/lib/layout/layout.jelly @@ -22,14 +22,12 @@ -