Fix build logs on Safari by having the client JS handle the redirect manually, rather than the browser itself; Safari doesn't support 302 redirects to another domain inside an XHR.
This commit is contained in:
parent
2b9902b72c
commit
d6a1493d52
3 changed files with 68 additions and 35 deletions
|
@ -288,9 +288,11 @@ class RepositoryBuildLogs(RepositoryParamResource):
|
||||||
build.repository.namespace_user.username != namespace):
|
build.repository.namespace_user.username != namespace):
|
||||||
raise NotFound()
|
raise NotFound()
|
||||||
|
|
||||||
# If the logs have been archived, just redirect to the completed archive
|
# If the logs have been archived, just return a URL of the completed archive
|
||||||
if build.logs_archived:
|
if build.logs_archived:
|
||||||
return redirect(log_archive.get_file_url(build.uuid))
|
return {
|
||||||
|
'logs_url': log_archive.get_file_url(build.uuid)
|
||||||
|
}
|
||||||
|
|
||||||
start = int(request.args.get('start', 0))
|
start = int(request.args.get('start', 0))
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,28 @@ angular.module('quay').directive('buildLogsView', function () {
|
||||||
return endIndex;
|
return endIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var handleLogsData = function(logsData, callback) {
|
||||||
|
// Process the logs we've received.
|
||||||
|
$scope.logStartIndex = processLogs(logsData['logs'], logsData['start'], logsData['total']);
|
||||||
|
|
||||||
|
// If the build status is an error, open the last two log entries.
|
||||||
|
var currentBuild = $scope.currentBuild;
|
||||||
|
if (currentBuild['phase'] == 'error' && $scope.logEntries.length > 1) {
|
||||||
|
var openLogEntries = function(entry) {
|
||||||
|
if (entry.logs) {
|
||||||
|
entry.logs.setVisible(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
openLogEntries($scope.logEntries[$scope.logEntries.length - 2]);
|
||||||
|
openLogEntries($scope.logEntries[$scope.logEntries.length - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the build phase is an error or a complete, then we mark the channel
|
||||||
|
// as closed.
|
||||||
|
callback(currentBuild['phase'] != 'error' && currentBuild['phase'] != 'complete');
|
||||||
|
}
|
||||||
|
|
||||||
var getBuildStatusAndLogs = function(build, callback) {
|
var getBuildStatusAndLogs = function(build, callback) {
|
||||||
var params = {
|
var params = {
|
||||||
'repository': build.repository.namespace + '/' + build.repository.name,
|
'repository': build.repository.namespace + '/' + build.repository.name,
|
||||||
|
@ -88,25 +110,18 @@ angular.module('quay').directive('buildLogsView', function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
ApiService.getRepoBuildLogsAsResource(params, true).withOptions(options).get(function(resp) {
|
ApiService.getRepoBuildLogsAsResource(params, true).withOptions(options).get(function(resp) {
|
||||||
// Process the logs we've received.
|
// If we get a logs url back, then we need to make another XHR request to retrieve the
|
||||||
$scope.logStartIndex = processLogs(resp['logs'], resp['start'], resp['total']);
|
// data.
|
||||||
|
if (resp['logs_url']) {
|
||||||
// If the build status is an error, open the last two log entries.
|
$.ajax({
|
||||||
var currentBuild = $scope.currentBuild;
|
url: resp['logs_url'],
|
||||||
if (currentBuild['phase'] == 'error' && $scope.logEntries.length > 1) {
|
}).done(function(r) {
|
||||||
var openLogEntries = function(entry) {
|
handleLogsData(r, callback);
|
||||||
if (entry.logs) {
|
});
|
||||||
entry.logs.setVisible(true);
|
return;
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
openLogEntries($scope.logEntries[$scope.logEntries.length - 2]);
|
|
||||||
openLogEntries($scope.logEntries[$scope.logEntries.length - 1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the build phase is an error or a complete, then we mark the channel
|
handleLogsData(resp, callback);
|
||||||
// as closed.
|
|
||||||
callback(currentBuild['phase'] != 'error' && currentBuild['phase'] != 'complete');
|
|
||||||
}, function() {
|
}, function() {
|
||||||
callback(false);
|
callback(false);
|
||||||
});
|
});
|
||||||
|
|
|
@ -186,6 +186,28 @@
|
||||||
return endIndex;
|
return endIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var handleLogsData = function(logsData, callback) {
|
||||||
|
// Process the logs we've received.
|
||||||
|
$scope.logStartIndex = processLogs(logsData['logs'], logsData['start'], logsData['total']);
|
||||||
|
|
||||||
|
// If the build status is an error, open the last two log entries.
|
||||||
|
var currentBuild = $scope.currentBuild;
|
||||||
|
if (currentBuild['phase'] == 'error' && $scope.logEntries.length > 1) {
|
||||||
|
var openLogEntries = function(entry) {
|
||||||
|
if (entry.logs) {
|
||||||
|
entry.logs.setVisible(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
openLogEntries($scope.logEntries[$scope.logEntries.length - 2]);
|
||||||
|
openLogEntries($scope.logEntries[$scope.logEntries.length - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the build phase is an error or a complete, then we mark the channel
|
||||||
|
// as closed.
|
||||||
|
callback(currentBuild['phase'] != 'error' && currentBuild['phase'] != 'complete');
|
||||||
|
};
|
||||||
|
|
||||||
var getBuildStatusAndLogs = function(build, callback) {
|
var getBuildStatusAndLogs = function(build, callback) {
|
||||||
var params = {
|
var params = {
|
||||||
'repository': namespace + '/' + name,
|
'repository': namespace + '/' + name,
|
||||||
|
@ -217,24 +239,18 @@
|
||||||
ApiService.getRepoBuildLogsAsResource(params, true).withOptions(options).get(function(resp) {
|
ApiService.getRepoBuildLogsAsResource(params, true).withOptions(options).get(function(resp) {
|
||||||
if (build != $scope.currentBuild) { callback(false); return; }
|
if (build != $scope.currentBuild) { callback(false); return; }
|
||||||
|
|
||||||
// Process the logs we've received.
|
// If we get a logs url back, then we need to make another XHR request to retrieve the
|
||||||
$scope.logStartIndex = processLogs(resp['logs'], resp['start'], resp['total']);
|
// data.
|
||||||
|
if (resp['logs_url']) {
|
||||||
// If the build status is an error, open the last two log entries.
|
$.ajax({
|
||||||
if (currentBuild['phase'] == 'error' && $scope.logEntries.length > 1) {
|
url: resp['logs_url'],
|
||||||
var openLogEntries = function(entry) {
|
}).done(function(r) {
|
||||||
if (entry.logs) {
|
handleLogsData(r, callback);
|
||||||
entry.logs.setVisible(true);
|
});
|
||||||
}
|
return;
|
||||||
};
|
|
||||||
|
|
||||||
openLogEntries($scope.logEntries[$scope.logEntries.length - 2]);
|
|
||||||
openLogEntries($scope.logEntries[$scope.logEntries.length - 1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the build phase is an error or a complete, then we mark the channel
|
handleLogsData(resp, callback);
|
||||||
// as closed.
|
|
||||||
callback(currentBuild['phase'] != 'error' && currentBuild['phase'] != 'complete');
|
|
||||||
}, function() {
|
}, function() {
|
||||||
callback(false);
|
callback(false);
|
||||||
});
|
});
|
||||||
|
|
Reference in a new issue