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 @@
|
- |
| Progress: |
- |
|
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 @@
+
+
Building ${e.currentBuild}
- |
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 @@
|