ensure always using buffered streaming

This commit is contained in:
Brad Rydzewski 2015-09-29 23:11:27 -07:00
parent 895919cf24
commit 9790f1a015

View file

@ -4,15 +4,38 @@ function JobViewModel(repo, build, job, status) {
var self = this; var self = this;
self.status = status; self.status = status;
self.stream = function() {
$( "#output" ).html("");
var buf = new Drone.Buffer();
buf.start(document.getElementById("output"));
$( "#tail" ).show();
$( "#tail" ).click(function() {
buf.autoFollow = !buf.autoFollow;
if (buf.autoFollow) {
$( "#tail i" ).text("pause");
$( "#tail" ).show();
// scroll to the bottom of the page
window.scrollTo(0, document.body.scrollHeight);
} else {
$( "#tail i" ).text("expand_more");
$( "#tail" ).show();
}
})
Stream(repo, build, job, function(out){
buf.write(out);
});
};
if (status !== "running" && status !== "pending") { if (status !== "running" && status !== "pending") {
Logs(repo, build, job); Logs(repo, build, job);
} }
if (status === "running") { if (status === "running") {
Stream(repo, build, job, function(out){ self.stream();
$( "#output" ).append(out);
});
} }
$("#restart").click(function() { $("#restart").click(function() {
@ -51,30 +74,7 @@ function JobViewModel(repo, build, job, status) {
// if the status has changed we should start // if the status has changed we should start
// streaming the build contents. // streaming the build contents.
if (before !== after && after === "running") { if (before !== after && after === "running") {
$( "#output" ).html(""); self.stream();
var buf = new Drone.Buffer();
buf.start(document.getElementById("output"));
$( "#tail" ).show();
$( "#tail" ).click(function() {
buf.autoFollow = !buf.autoFollow;
if (buf.autoFollow) {
$( "#tail i" ).text("pause");
$( "#tail" ).show();
// scroll to the bottom of the page
window.scrollTo(0, document.body.scrollHeight);
} else {
$( "#tail i" ).text("expand_more");
$( "#tail" ).show();
}
})
Stream(repo, build, job, function(out){
buf.write(out);
});
} }
// if the status is changes to complete, we can show // if the status is changes to complete, we can show