Make sure to always load initial logs and to only ask for the latest log entries on initial load

This commit is contained in:
Joseph Schorr 2014-02-11 16:56:39 -05:00
parent ea45c3b77f
commit fadf4001c0

View file

@ -729,7 +729,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
$scope.commands = null;
$scope.commandMap = {};
$scope.logs = null;
$scope.logStartIndex = 0;
$scope.logStartIndex = null;
$scope.currentBuild = build;
if (opt_updateURL) {
@ -746,6 +746,9 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
$scope.adjustLogHeight();
}, 1);
// Load the first set of logs.
getBuildStatusAndLogs();
// If the build is currently processing, start the build timer.
checkPollTimer();
};
@ -789,7 +792,8 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
for (var i = 0; i < logs.length; ++i) {
var entry = logs[i];
if (entry['is_command']) {
var existing = $scope.commandMap[entry['message']];
var index = startIndex + i;
var existing = $scope.commandMap[index];
if (existing) {
currentCommand = existing;
continue;
@ -797,12 +801,13 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
currentCommand = {
'message': entry['message'],
'index': startIndex + i
'index': index
};
$scope.commands.push(currentCommand);
$scope.commandMap[entry['message']] = currentCommand;
$scope.commandMap[index] = currentCommand;
continue;
}
if (!currentCommand.logs) {
currentCommand.logs = [];
}