diff --git a/server/static/scripts/controllers/builds.js b/server/static/scripts/controllers/builds.js index c05b0ed37..1c0707ddf 100644 --- a/server/static/scripts/controllers/builds.js +++ b/server/static/scripts/controllers/builds.js @@ -75,13 +75,14 @@ /** * BuildCtrl responsible for rendering a build. */ - function BuildCtrl($scope, $routeParams, logs, builds, repos, users, feed) { + function BuildCtrl($scope, $routeParams, $window, logs, builds, repos, users, feed) { var step = parseInt($routeParams.step) || 1; var number = $routeParams.number; var owner = $routeParams.owner; var name = $routeParams.name; var fullName = owner+'/'+name; + var tail = false; // Initiates streaming a build. var stream = function() { @@ -89,8 +90,13 @@ var term = document.getElementById("term"); term.innerHTML = ""; + // subscribes to the build otuput. logs.subscribe(fullName, number, step, function(data){ term.innerHTML += convert.toHtml(data)+"\n"; + if (tail) { + // scrolls to the bottom of the page if enabled + $window.scrollTo(0, $window.document.body.scrollHeight); + } }); } @@ -149,6 +155,10 @@ }); }; + $scope.tail = function() { + tail = !tail; + }; + feed.subscribe(function(event) { if (event.repo.full_name !== fullName) { return; // ignore diff --git a/server/static/scripts/views/build.html b/server/static/scripts/views/build.html index 85668d05d..0d141216f 100644 --- a/server/static/scripts/views/build.html +++ b/server/static/scripts/views/build.html @@ -57,7 +57,8 @@
-
{{ logs }}
+ +
{{ logs }}