X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6bcb827b1405ce8ca5d767108bc4356ecc2972f4..2b699dec710d1f0719ec0471bc711a467ac34a95:/apps/workbench/app/views/jobs/_show_log.html.erb?ds=sidebyside diff --git a/apps/workbench/app/views/jobs/_show_log.html.erb b/apps/workbench/app/views/jobs/_show_log.html.erb index 8082d6f5a4..7d67b74210 100644 --- a/apps/workbench/app/views/jobs/_show_log.html.erb +++ b/apps/workbench/app/views/jobs/_show_log.html.erb @@ -1,11 +1,14 @@ <% if !@object.log %> -<% log_history = stderr_log_history([@object.uuid]) %> +
Showing only ' + data.length + ' bytes of this log.' + - ' Timing information is unavailable since' + - ' the full log was not retrieved.
' - ); - } else { - generateJobOverview("#log-viewer-overview", logViewer, taskState); + var ajax_opts = { dataType: 'text', headers: headers }; + load_log(); + + function load_log() { + $.ajax(logcollection_url, ajax_opts).done(done).fail(fail); + } + function done(data, status, jqxhr) { + if (jqxhr.getResponseHeader('Content-Type').indexOf('application/json') === 0) { + // The browser won't allow a redirect-with-cookie response + // because keep-web isn't same-origin with us. Instead, we + // assure keep-web it's OK to respond with the content + // immediately by setting the token in the request body + // instead and adding disposition=attachment. + logcollection_url = JSON.parse(data).href; + var queryAt = logcollection_url.indexOf('?api_token='); + if (queryAt >= 0) { + ajax_opts.method = 'POST'; + ajax_opts.data = { + api_token: logcollection_url.slice(queryAt+11), + disposition: 'attachment', + }; + logcollection_url = logcollection_url.slice(0, queryAt); } - $("#log-viewer .spinner").detach(); - }). - fail(function(jqxhr, status, error) { - $("#log-viewer .spinner").detach(); - }); + return load_log(); + } + logViewer.filter(); + addToLogViewer(logViewer, data.split("\n"), taskState); + logViewer.filter(makeFilter()); + content_range_hdr = jqxhr.getResponseHeader('Content-Range'); + var v = content_range_hdr && content_range_hdr.match(/bytes \d+-(\d+)\/(.+)/); + short_log = v && (v[2] == '*' || parseInt(v[1]) + 1 < v[2]); + if (jqxhr.status == 206 && short_log) { + $("#log-viewer-overview").html( + 'Showing only ' + data.length + ' bytes of this log.' + + ' Timing information is unavailable since' + + ' the full log was not retrieved.
' + ); + } else { + generateJobOverview("#log-viewer-overview", logViewer, taskState); + } + $("#log-viewer .spinner").detach(); + } + function fail(jqxhr, status, error) { + // TODO: tell the user about the error + console.log('load_log failed: status='+status+' error='+error); + $("#log-viewer .spinner").detach(); + } <% end %> <% else %> <%# Live log loading not implemented yet. %>