+++ /dev/null
-<%# Copyright (C) The Arvados Authors. All rights reserved.
-
-SPDX-License-Identifier: AGPL-3.0 %>
-
-<% if !@object.log %>
-
-<div id="log_graph_div"
- class="arv-log-event-listener"
- style="display:none"
- data-object-uuid="<%= @object.uuid %>"></div>
-
-<pre id="event_log_div"
- class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window"
- data-object-uuid="<%= @object.uuid %>"
- ><%= @object.stderr_log_lines(Rails.configuration.Workbench.RunningJobLogRecordsToFetch).join("\n") %>
-</pre>
-
-<%# Applying a long throttle suppresses the auto-refresh of this
- partial that would normally be triggered by arv-log-event. %>
-<div class="arv-log-refresh-control"
- data-load-throttle="86486400000" <%# 1001 nights %>
- ></div>
-
-<% else %>
-
-<script>
-(function() {
-var pagesize = 1000;
-var logViewer = new List('log-viewer', {
- valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type'],
- page: pagesize
-});
-
-logViewer.page_offset = 0;
-logViewer.on("updated", function() { updatePaging(".log-viewer-paging", logViewer, pagesize) } );
-$(".log-viewer-page-up").on("click", function() { prevPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
-$(".log-viewer-page-down").on("click", function() { nextPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
-
-var taskState = newTaskState();
-
-var makeFilter = function() {
- var pass = [];
- $(".toggle-filter, .radio-filter").each(function(i, e) {
- if (e.checked) {
- pass.push(e.id.substr(5));
- }
- });
-
- return (function(item) {
- var v = false;
- if (item.values().taskid !== "") {
- for (a in pass) {
- if (pass[a] == "all-tasks") { v = true; }
- else if (pass[a] == "successful-tasks" && taskState[item.values().taskid].outcome == "success") { v = true; }
- else if (pass[a] == "failed-tasks" && taskState[item.values().taskid].outcome == "failure") { v = true; }
- }
- } else {
- v = true;
- }
- for (a in pass) {
- if (pass[a] == item.values().type) { return v; }
- }
- return false;
- });
-}
-
-<% if @object.log and !@object.log.empty? %>
- <% logcollection = Collection.find @object.log %>
- <% if logcollection %>
- var log_size = <%= logcollection.files[0][2] %>
- var log_maxbytes = <%= Rails.configuration.Workbench.LogViewerMaxBytes %>;
- var logcollection_url = '<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>';
- $("#log-viewer-download-url").attr('href', logcollection_url);
- $("#log-viewer-download-pane").show();
- var headers = {};
- if (log_size > log_maxbytes) {
- headers['Range'] = 'bytes=0-' + (log_maxbytes - 1);
- }
- 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);
- }
- 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(
- '<p>Showing only ' + data.length + ' bytes of this log.' +
- ' Timing information is unavailable since' +
- ' the full log was not retrieved.</p>'
- );
- } 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. %>
-<% end %>
-
-$(".toggle-filter, .radio-filter").on("change", function() {
- logViewer.filter(makeFilter());
-});
-
-$("#filter-all").on("click", function() {
- $(".toggle-filter").each(function(i, f) { f.checked = true; });
- logViewer.filter(makeFilter());
-});
-
-$("#filter-none").on("click", function() {
- $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
- logViewer.filter(makeFilter());
-});
-
-$("#sort-by-time").on("change", function() {
- logViewer.sort("id", {sortFunction: sortById});
-});
-
-$("#sort-by-task").on("change", function() {
- logViewer.sort("taskid", {sortFunction: sortByTask});
-});
-
-$("#sort-by-node").on("change", function() {
- logViewer.sort("node", {sortFunction: sortByNode});
-});
-
-$("#set-show-failed-only").on("click", function() {
- $("#sort-by-task").prop("checked", true);
- $("#show-failed-tasks").prop("checked", true);
- $("#show-crunch").prop("checked", false);
- $("#show-task-dispatch").prop("checked", true);
- $("#show-script-print").prop("checked", true);
- $("#show-crunchstat").prop("checked", false);
- logViewer.filter(makeFilter());
- logViewer.sort("taskid", {sortFunction: sortByTask});
-});
-
-})();
-
-</script>
-
-<div id="log-viewer">
-
- <h3>Summary</h3>
- <p id="log-viewer-overview">
- <% if !logcollection %>
- The collection containing the job log was not found.
- <% end %>
- </p>
-
- <p id="log-viewer-download-pane" style="display:none">
- <a id="log-viewer-download-url" href="">Download the full log</a>
- </p>
-
- <div class="h3">Log
-
- <span class="pull-right">
- <% if @object.andand.tasks_summary.andand[:failed] and @object.tasks_summary[:failed] > 0 %>
- <button id="set-show-failed-only" class="btn btn-danger">
- Show failed task diagnostics only
- </button>
- <% end %>
-
- <button id="filter-all" class="btn">
- Select all
- </button>
- <button id="filter-none" class="btn">
- Select none
- </button>
- </span>
- </div>
-
- <input class="search pull-right" style="margin-top: 1em" placeholder="Search" />
-
- <div>
- <div class="radio-inline log-viewer-button" style="margin-left: 10px">
- <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
- </div>
- <div class="radio-inline log-viewer-button">
- <label><input id="sort-by-node" type="radio" name="sort-radio" > Sort by node</label>
- </div>
-
- <div class="radio-inline log-viewer-button">
- <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
- </div>
- </div>
-
- <div>
- <div class="radio-inline log-viewer-button" style="margin-left: 10px">
- <label><input id="show-all-tasks" type="radio" name="show-tasks-group" checked="true" class="radio-filter"> Show all tasks</label>
- </div>
- <div class="radio-inline log-viewer-button">
- <label><input id="show-successful-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only successful tasks</label>
- </div>
- <div class="radio-inline log-viewer-button">
- <label><input id="show-failed-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only failed tasks</label>
- </div>
- </div>
-
- <div>
- <div class="checkbox-inline log-viewer-button" style="margin-left: 10px">
- <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch diagnostics</label>
- </div>
- <div class="checkbox-inline log-viewer-button">
- <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
- </div>
- <div class="checkbox-inline log-viewer-button">
- <label><input id="show-task-print" type="checkbox" checked="true" class="toggle-filter"> Show task diagnostics</label>
- </div>
- <div class="checkbox-inline log-viewer-button">
- <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
- </div>
-
- </div>
-
- <div class="smart-scroll" data-smart-scroll-padding-bottom="50" style="margin-bottom: 0px">
- <table class="log-viewer-table">
- <thead>
- <tr>
- <th class="id" data-sort="id"></th>
- <th class="timestamp" data-sort="timestamp">Timestamp</th>
- <th class="node" data-sort="node">Node</th>
- <th class="slot" data-sort="slot">Slot</th>
- <th class="type" data-sort="type">Log type</th>
- <th class="taskid" data-sort="taskid">Task</th>
- <th class="message" data-sort="message">Message</th>
- </tr>
- </thead>
- <tbody class="list">
- <tr>
- <td class="id"></td>
- <td class="timestamp"></td>
- <td class="node"></td>
- <td class="slot"></td>
- <td class="type"></td>
- <td class="taskid"></td>
- <td class="message"></td>
- </tr>
- </tbody>
- </table>
-
- <% if @object.log and logcollection %>
- <div class="spinner spinner-32px"></div>
- <% end %>
-
- </div>
-
- <div class="log-viewer-paging-div" style="margin-bottom: -15px">
- <a href="#" class="log-viewer-page-up"><span class='glyphicon glyphicon-arrow-up'></span></a>
- <span class="log-viewer-paging"></span>
- <a href="#" class="log-viewer-page-down"><span class='glyphicon glyphicon-arrow-down'></span></a>
- </div>
-
-</div>
-
-<% end %>