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