Merge pull request #539 from mjschultz/add-follow

Add follow button to stdout
This commit is contained in:
Brad Rydzewski 2014-10-12 18:12:20 -07:00
commit 3d839498a1
5 changed files with 37 additions and 7 deletions

View file

@ -273,15 +273,27 @@ app.controller("CommitController", function($scope, $http, $routeParams, stdout,
var el = document.querySelector('#output'); var el = document.querySelector('#output');
stdout.subscribe(data.id, function(out){ stdout.subscribe(data.id, function(out){
angular.element(el).append(lineFormatter.format(out)); angular.element(el).append(lineFormatter.format(out));
if ($scope.following) {
window.scrollTo(0, document.body.scrollHeight);
}
}); });
}). }).
error(function(data, status, headers, config) { error(function(data, status, headers, config) {
console.log(data); console.log(data);
}); });
$scope.following = false;
$scope.follow = function() {
$scope.following = true;
window.scrollTo(0, document.body.scrollHeight);
}
$scope.unfollow = function() {
$scope.following = false;
}
$scope.rebuildCommit = function() { $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' })
} }
}); });

View file

@ -8,7 +8,7 @@ angular.module('app').service('stdout', ['$window', function($window) {
callback = _callback; callback = _callback;
var proto = ($window.location.protocol == 'https:' ? 'wss' : 'ws'); var proto = ($window.location.protocol == 'https:' ? 'wss' : 'ws');
var route = [proto, "://", $window.location.host, '/api/feed/stdout/', path].join(''); var route = [proto, "://", $window.location.host, '/api/stream/stdout/', path].join('');
websocket = new WebSocket(route); websocket = new WebSocket(route);
websocket.onmessage = function(event) { websocket.onmessage = function(event) {

File diff suppressed because one or more lines are too long

View file

@ -1315,6 +1315,21 @@ nav {
line-height:18px; line-height:18px;
} }
#follow button {
position: fixed;
right: 280px;
bottom: 21px;
z-index: 100;
padding: 0 1em;
border-radius: 7px;
background-color: rgba(238, 238, 238, 0.2);
padding: 0 1em;
cursor: pointer;
font-family: @sans;
border: none;
color: #fff;
}
&[data-result="Pending"]:after, &[data-result="Pending"]:after,
&[data-result="Started"]:after { &[data-result="Started"]:after {
position: absolute; position: absolute;
@ -1540,4 +1555,4 @@ nav {
} }
} }
} }
} }

View file

@ -51,7 +51,10 @@
<span>/</span> <span>/</span>
<a href="#">{{ commit.sha | shortHash}}</a> <a href="#">{{ commit.sha | shortHash}}</a>
</nav> </nav>
<div id="follow">
<button ng-click="follow()" ng-if="following == false">follow</button>
<button ng-click="unfollow()" ng-if="following == true">unfollow</button>
</div>
<pre id="output"></pre> <pre id="output"></pre>
</div> </div>
</div> </div>