From 6359da32962fea3334116798fddc552e5073bb69 Mon Sep 17 00:00:00 2001 From: Eichin David Date: Fri, 24 Oct 2014 23:25:56 +0200 Subject: [PATCH 1/4] fixed missing live console output bug on rebuild --- server/worker/docker/docker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/worker/docker/docker.go b/server/worker/docker/docker.go index ad1f3bf5..d00f7752 100644 --- a/server/worker/docker/docker.go +++ b/server/worker/docker/docker.go @@ -68,7 +68,7 @@ func (d *Docker) Do(c context.Context, r *worker.Work) { commitc := pubsub.Register(c, "_global") commitc.Publish(r) stdoutc := pubsub.RegisterOpts(c, r.Commit.ID, pubsub.ConsoleOpts) - defer stdoutc.Close() + defer pubsub.Unregister(c, r.Commit.ID) // create a special buffer that will also // write to a websocket channel From 2d74e4ed04baa14bbd43373b87826db7a1f409d5 Mon Sep 17 00:00:00 2001 From: Eichin David Date: Sat, 25 Oct 2014 21:34:27 +0200 Subject: [PATCH 2/4] quick fix for reloading page if succesfully started a rebuild of a commit --- server/app/scripts/app.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/server/app/scripts/app.js b/server/app/scripts/app.js index 5334513c..263821c2 100644 --- a/server/app/scripts/app.js +++ b/server/app/scripts/app.js @@ -226,7 +226,7 @@ app.controller("AccountReposController", function($scope, $http, user) { }); -app.controller("CommitController", function($scope, $http, $routeParams, stdout, feed) { +app.controller("CommitController", function($scope, $http, $route, $routeParams, stdout, feed) { var remote = $routeParams.remote; var owner = $routeParams.owner; @@ -234,12 +234,30 @@ app.controller("CommitController", function($scope, $http, $routeParams, stdout, var branch = $routeParams.branch; var commit = $routeParams.commit; $scope.console=''; + + var handleOutput = function(id, clearConsole) { + var lineFormatter = new Drone.LineFormatter(); + var el = document.querySelector('#output'); + if(clearConsole === true) { + el.innerHTML = ''; + } + stdout.subscribe(id, function(out){ + angular.element(el).append(lineFormatter.format(out)); + if ($scope.following) { + window.scrollTo(0, document.body.scrollHeight); + } + }); + } feed.subscribe(function(item) { if (item.commit.sha == commit && item.commit.branch == branch) { + if(item.commit.status == "Started") { + handleOutput(item.commit.id, true); + } $scope.commit = item.commit; $scope.$apply(); + } else { // we trigger an toast notification so the // user is aware another build started @@ -274,14 +292,8 @@ app.controller("CommitController", function($scope, $http, $routeParams, stdout, return; } - var lineFormatter = new Drone.LineFormatter(); - var el = document.querySelector('#output'); - stdout.subscribe(data.id, function(out){ - angular.element(el).append(lineFormatter.format(out)); - if ($scope.following) { - window.scrollTo(0, document.body.scrollHeight); - } - }); + handleOutput(data.id, false); + }). error(function(data, status, headers, config) { console.log(data); @@ -297,7 +309,7 @@ app.controller("CommitController", function($scope, $http, $routeParams, stdout, } $scope.rebuildCommit = function() { - $http({method: 'POST', url: '/api/repos/'+remote+'/'+owner+'/'+name+'/'+'branches/'+branch+'/'+'commits/'+commit+'?action=rebuild' }) + $http({method: 'POST', url: '/api/repos/'+remote+'/'+owner+'/'+name+'/'+'branches/'+branch+'/'+'commits/'+commit+'?action=rebuild' }); } From 961c53f6cf5ec6fdbb3526bf3d48e9e68982306b Mon Sep 17 00:00:00 2001 From: Eichin David Date: Sun, 26 Oct 2014 01:33:10 +0200 Subject: [PATCH 3/4] hide rebuild button if in Started or Pending state --- server/app/views/commit.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/app/views/commit.html b/server/app/views/commit.html index 5b27deb0..6ca5465f 100644 --- a/server/app/views/commit.html +++ b/server/app/views/commit.html @@ -37,7 +37,7 @@