Fix multiple loading of build logs in new superuser panel

Also adds an error message if the logs fail to load
This commit is contained in:
Joseph Schorr 2017-01-30 13:56:53 -05:00
parent 8a842d286f
commit fcdf966c9f
3 changed files with 17 additions and 10 deletions

View file

@ -9,10 +9,12 @@
<i class="fa fa-plus" style="margin-right: 6px;"></i>Get Logs
</button>
</div>
<div class="resource-view" resource="buildResource" error-message="'Cannot find or load build'"
ng-show="buildId">
<div class="build-logs-view"
build="build"
use-timestamps="showLogTimestamps"
build-updated="setUpdatedBuild(build)"
is-super-user="true"
ng-show="build"></div>
</div>
</div>

View file

@ -164,6 +164,10 @@ angular.module('quay').directive('buildLogsView', function () {
getBuildStatusAndLogs(build, callback);
};
// Make sure to cancel any existing watchers first.
stopWatching();
// Register a new poll channel to start watching.
$scope.pollChannel = AngularPollChannel.create($scope, conductStatusAndLogRequest, 5 * 1000 /* 5s */);
$scope.pollChannel.start();
};

View file

@ -14,17 +14,18 @@ angular.module('quay').directive('superUserBuildLogs', function () {
controller: function ($scope, $element, ApiService) {
$scope.buildParams = {};
$scope.showLogTimestamps = true;
$scope.buildId = null;
$scope.loadBuild = function () {
var params = {
'build_uuid': $scope.buildParams.buildUuid
};
ApiService.getRepoBuildSuperUserAsResource(params).get(function (build) {
$scope.buildId = $scope.buildParams.buildUuid;
$scope.buildResource = ApiService.getRepoBuildSuperUserAsResource(params).get(function (build) {
$scope.build = build;
});
};
$scope.setUpdatedBuild = function (build) {
$scope.build = build;
};
}
};
return directiveDefinitionObject;