Always show the current build at the top of the list

This commit is contained in:
Joseph Schorr 2014-02-14 18:46:20 -05:00
parent 55d846061e
commit 0ceeb6f8e7
3 changed files with 13 additions and 5 deletions

View file

@ -1143,6 +1143,13 @@ quayApp.directive('dockerAuthDialog', function () {
});
quayApp.filter('reverse', function() {
return function(items) {
return items.slice().reverse();
};
});
quayApp.filter('bytes', function() {
return function(bytes, precision) {
if (!bytes || isNaN(parseFloat(bytes)) || !isFinite(bytes)) return 'Unknown';

View file

@ -827,7 +827,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
// Find the build.
for (var i = 0; i < $scope.builds.length; ++i) {
if ($scope.builds[i].id == buildId) {
$scope.setCurrentBuildInternal($scope.builds[i], opt_updateURL);
$scope.setCurrentBuildInternal(i, $scope.builds[i], opt_updateURL);
return;
}
}
@ -843,7 +843,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
return setup + stream + teardown;
};
$scope.setCurrentBuildInternal = function(build, opt_updateURL) {
$scope.setCurrentBuildInternal = function(index, build, opt_updateURL) {
if (build == $scope.currentBuild) { return; }
stopPollTimer();
@ -853,6 +853,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
$scope.currentParentEntry = null;
$scope.currentBuild = build;
$scope.currentBuildIndex = index;
if (opt_updateURL) {
if (build) {
@ -934,7 +935,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
ApiService.getRepoBuildStatus(null, params, true).then(function(resp) {
// Note: We use extend here rather than replacing as Angular is depending on the
// root build object to remain the same object.
$.extend(true, $scope.currentBuild, resp);
$.extend(true, $scope.builds[$scope.currentBuildIndex], resp);
checkPollTimer();
// Load the updated logs for the build.
@ -985,7 +986,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
if ($location.search().current) {
$scope.setCurrentBuild($location.search().current, false);
} else if ($scope.builds.length > 0) {
$scope.setCurrentBuild($scope.builds[0].id, true);
$scope.setCurrentBuild($scope.builds[$scope.builds.length - 1].id, true);
}
});
};

View file

@ -19,7 +19,7 @@
<!-- Side tabs -->
<div class="col-sm-2">
<ul class="nav nav-pills nav-stacked">
<li ng-class="currentBuild == build ? 'active' : ''" ng-repeat="build in builds">
<li ng-class="currentBuild == build ? 'active' : ''" ng-repeat="build in builds | reverse">
<a class="build-tab-link" href="javascript:void(0)" ng-click="setCurrentBuild(build.id, true)">
<span class="phase-icon" ng-class="build.phase"></span>
<span>{{ build.display_name }}</span>