3 <div id="log_graph_div"
4 class="arv-log-event-listener"
6 data-object-uuid="<%= @object.uuid %>"></div>
8 <div id="event_log_div"
9 class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window"
10 data-object-uuid="<%= @object.uuid %>"
13 <%# Applying a long throttle suppresses the auto-refresh of this
14 partial that would normally be triggered by arv-log-event. %>
15 <div class="arv-log-refresh-control"
16 data-load-throttle="86486400000" <%# 1001 nights %>
24 var logViewer = new List('log-viewer', {
25 valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type'],
29 logViewer.page_offset = 0;
30 logViewer.on("updated", function() { updatePaging(".log-viewer-paging", logViewer, pagesize) } );
31 $(".log-viewer-page-up").on("click", function() { prevPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
32 $(".log-viewer-page-down").on("click", function() { nextPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
34 var taskState = newTaskState();
36 var makeFilter = function() {
38 $(".toggle-filter, .radio-filter").each(function(i, e) {
40 pass.push(e.id.substr(5));
44 return (function(item) {
46 if (item.values().taskid !== "") {
48 if (pass[a] == "all-tasks") { v = true; }
49 else if (pass[a] == "successful-tasks" && taskState[item.values().taskid].outcome == "success") { v = true; }
50 else if (pass[a] == "failed-tasks" && taskState[item.values().taskid].outcome == "failure") { v = true; }
56 if (pass[a] == item.values().type) { return v; }
62 <% if @object.log and !@object.log.empty? %>
63 <% logcollection = Collection.find @object.log %>
64 <% if logcollection %>
65 var log_size = <%= logcollection.files[0][2] %>
66 var log_maxbytes = <%= Rails.configuration.log_viewer_max_bytes %>;
67 var logcollection_url = '<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>';
68 $("#log-viewer-download-url").attr('href', logcollection_url);
69 $("#log-viewer-download-pane").show();
71 if (log_size > log_maxbytes) {
72 headers['Range'] = 'bytes=0-' + log_maxbytes;
74 var ajax_opts = { dataType: 'text', headers: headers };
78 $.ajax(logcollection_url, ajax_opts).done(done).fail(fail);
80 function done(data, status, jqxhr) {
81 if (jqxhr.getResponseHeader('Content-Type').indexOf('application/json') === 0) {
82 // The browser won't allow a redirect-with-cookie response
83 // because keep-web isn't same-origin with us. Instead, we
84 // assure keep-web it's OK to respond with the content
85 // immediately by setting the token in the request body
86 // instead and adding disposition=attachment.
87 logcollection_url = JSON.parse(data).href;
88 var queryAt = logcollection_url.indexOf('?api_token=');
90 ajax_opts.method = 'POST';
92 api_token: logcollection_url.slice(queryAt+11),
93 disposition: 'attachment',
95 logcollection_url = logcollection_url.slice(0, queryAt);
100 addToLogViewer(logViewer, data.split("\n"), taskState);
101 logViewer.filter(makeFilter());
102 content_range_hdr = jqxhr.getResponseHeader('Content-Range');
103 var v = content_range_hdr && content_range_hdr.match(/bytes \d+-(\d+)\/(.+)/);
104 short_log = v && (v[2] == '*' || parseInt(v[1]) + 1 < v[2]);
105 if (jqxhr.status == 206 && short_log) {
106 $("#log-viewer-overview").html(
107 '<p>Showing only ' + data.length + ' bytes of this log.' +
108 ' Timing information is unavailable since' +
109 ' the full log was not retrieved.</p>'
112 generateJobOverview("#log-viewer-overview", logViewer, taskState);
114 $("#log-viewer .spinner").detach();
116 function fail(jqxhr, status, error) {
117 // TODO: tell the user about the error
118 console.log('load_log failed: status='+status+' error='+error);
119 $("#log-viewer .spinner").detach();
123 <%# Live log loading not implemented yet. %>
126 $(".toggle-filter, .radio-filter").on("change", function() {
127 logViewer.filter(makeFilter());
130 $("#filter-all").on("click", function() {
131 $(".toggle-filter").each(function(i, f) { f.checked = true; });
132 logViewer.filter(makeFilter());
135 $("#filter-none").on("click", function() {
136 $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
137 logViewer.filter(makeFilter());
140 $("#sort-by-time").on("change", function() {
141 logViewer.sort("id", {sortFunction: sortById});
144 $("#sort-by-task").on("change", function() {
145 logViewer.sort("taskid", {sortFunction: sortByTask});
148 $("#sort-by-node").on("change", function() {
149 logViewer.sort("node", {sortFunction: sortByNode});
152 $("#set-show-failed-only").on("click", function() {
153 $("#sort-by-task").prop("checked", true);
154 $("#show-failed-tasks").prop("checked", true);
155 $("#show-crunch").prop("checked", false);
156 $("#show-task-dispatch").prop("checked", true);
157 $("#show-script-print").prop("checked", true);
158 $("#show-crunchstat").prop("checked", false);
159 logViewer.filter(makeFilter());
160 logViewer.sort("taskid", {sortFunction: sortByTask});
167 <div id="log-viewer">
170 <p id="log-viewer-overview">
171 <% if !logcollection %>
172 The collection containing the job log was not found.
176 <p id="log-viewer-download-pane" style="display:none">
177 <a id="log-viewer-download-url" href="">Download the full log</a>
182 <span class="pull-right">
183 <% if @object.andand.tasks_summary.andand[:failed] and @object.tasks_summary[:failed] > 0 %>
184 <button id="set-show-failed-only" class="btn btn-danger">
185 Show failed task diagnostics only
189 <button id="filter-all" class="btn">
192 <button id="filter-none" class="btn">
198 <input class="search pull-right" style="margin-top: 1em" placeholder="Search" />
201 <div class="radio-inline log-viewer-button" style="margin-left: 10px">
202 <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
204 <div class="radio-inline log-viewer-button">
205 <label><input id="sort-by-node" type="radio" name="sort-radio" > Sort by node</label>
208 <div class="radio-inline log-viewer-button">
209 <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
214 <div class="radio-inline log-viewer-button" style="margin-left: 10px">
215 <label><input id="show-all-tasks" type="radio" name="show-tasks-group" checked="true" class="radio-filter"> Show all tasks</label>
217 <div class="radio-inline log-viewer-button">
218 <label><input id="show-successful-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only successful tasks</label>
220 <div class="radio-inline log-viewer-button">
221 <label><input id="show-failed-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only failed tasks</label>
226 <div class="checkbox-inline log-viewer-button" style="margin-left: 10px">
227 <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch diagnostics</label>
229 <div class="checkbox-inline log-viewer-button">
230 <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
232 <div class="checkbox-inline log-viewer-button">
233 <label><input id="show-task-print" type="checkbox" checked="true" class="toggle-filter"> Show task diagnostics</label>
235 <div class="checkbox-inline log-viewer-button">
236 <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
241 <div class="smart-scroll" data-smart-scroll-padding-bottom="50" style="margin-bottom: 0px">
242 <table class="log-viewer-table">
245 <th class="id" data-sort="id"></th>
246 <th class="timestamp" data-sort="timestamp">Timestamp</th>
247 <th class="node" data-sort="node">Node</th>
248 <th class="slot" data-sort="slot">Slot</th>
249 <th class="type" data-sort="type">Log type</th>
250 <th class="taskid" data-sort="taskid">Task</th>
251 <th class="message" data-sort="message">Message</th>
257 <td class="timestamp"></td>
258 <td class="node"></td>
259 <td class="slot"></td>
260 <td class="type"></td>
261 <td class="taskid"></td>
262 <td class="message"></td>
267 <% if @object.log and logcollection %>
268 <div class="spinner spinner-32px"></div>
273 <div class="log-viewer-paging-div" style="margin-bottom: -15px">
274 <a href="#" class="log-viewer-page-up"><span class='glyphicon glyphicon-arrow-up'></span></a>
275 <span class="log-viewer-paging"></span>
276 <a href="#" class="log-viewer-page-down"><span class='glyphicon glyphicon-arrow-down'></span></a>