3 <% log_history = stderr_log_history([@object.uuid]) %>
4 <div class="arv-log-event-listener arv-log-event-handler-append-logs arv-job-log-window" id="pipeline_event_log_div" data-object-uuids="<%= @object.uuid %>">
5 <% log_history.each do |entry| %>
15 var logViewer = new List('log-viewer', {
16 valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type'],
20 logViewer.page_offset = 0;
21 logViewer.on("updated", function() { updatePaging(".log-viewer-paging", logViewer, pagesize) } );
22 $(".log-viewer-page-up").on("click", function() { prevPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
23 $(".log-viewer-page-down").on("click", function() { nextPage(logViewer, pagesize, ".log-viewer-paging"); return false; });
25 var taskState = newTaskState();
27 var makeFilter = function() {
29 $(".toggle-filter, .radio-filter").each(function(i, e) {
31 pass.push(e.id.substr(5));
35 return (function(item) {
37 if (item.values().taskid !== "") {
39 if (pass[a] == "all-tasks") { v = true; }
40 else if (pass[a] == "successful-tasks" && taskState[item.values().taskid].outcome == "success") { v = true; }
41 else if (pass[a] == "failed-tasks" && taskState[item.values().taskid].outcome == "failure") { v = true; }
47 if (pass[a] == item.values().type) { return v; }
54 <% logcollection = Collection.find @object.log %>
55 <% if logcollection %>
56 log_size = <%= logcollection.files[0][2] %>
57 log_maxbytes = <%= Rails.configuration.log_viewer_max_bytes %>;
58 logcollection_url = '<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>';
59 $("#log-viewer-download-url").attr('href', logcollection_url);
60 $("#log-viewer-download-pane").show();
61 if (log_size > log_maxbytes) {
62 range_header = { 'Range': 'bytes=0-' + log_maxbytes };
66 $.ajax(logcollection_url, { headers: range_header }).
67 done(function(data, status, jqxhr) {
69 addToLogViewer(logViewer, data.split("\n"), taskState);
70 logViewer.filter(makeFilter());
71 content_range_hdr = jqxhr.getResponseHeader('Content-Range');
72 var v = content_range_hdr && content_range_hdr.match(/bytes \d+-(\d+)\/(.+)/);
73 short_log = v && (v[2] == '*' || parseInt(v[1]) + 1 < v[2]);
74 if (jqxhr.status == 206 && short_log) {
75 $("#log-viewer-overview").html(
76 '<p>Showing only ' + data.length + ' bytes of this log.' +
77 ' Timing information is unavailable since' +
78 ' the full log was not retrieved.</p>'
81 generateJobOverview("#log-viewer-overview", logViewer, taskState);
83 $("#log-viewer .spinner").detach();
85 fail(function(jqxhr, status, error) {
86 $("#log-viewer .spinner").detach();
90 <%# Live log loading not implemented yet. %>
93 $(".toggle-filter, .radio-filter").on("change", function() {
94 logViewer.filter(makeFilter());
97 $("#filter-all").on("click", function() {
98 $(".toggle-filter").each(function(i, f) { f.checked = true; });
99 logViewer.filter(makeFilter());
102 $("#filter-none").on("click", function() {
103 $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
104 logViewer.filter(makeFilter());
107 $("#sort-by-time").on("change", function() {
108 logViewer.sort("id", {sortFunction: sortById});
111 $("#sort-by-task").on("change", function() {
112 logViewer.sort("taskid", {sortFunction: sortByTask});
115 $("#sort-by-node").on("change", function() {
116 logViewer.sort("node", {sortFunction: sortByNode});
119 $("#set-show-failed-only").on("click", function() {
120 $("#sort-by-task").prop("checked", true);
121 $("#show-failed-tasks").prop("checked", true);
122 $("#show-crunch").prop("checked", false);
123 $("#show-task-dispatch").prop("checked", true);
124 $("#show-script-print").prop("checked", true);
125 $("#show-crunchstat").prop("checked", false);
126 logViewer.filter(makeFilter());
127 logViewer.sort("taskid", {sortFunction: sortByTask});
134 <div id="log-viewer">
137 <p id="log-viewer-overview">
138 <% if !logcollection %>
139 The collection containing the job log was not found.
143 <p id="log-viewer-download-pane" style="display:none">
144 <a id="log-viewer-download-url" href="">Download the full log</a>
149 <span class="pull-right">
150 <% if @object.andand.tasks_summary.andand[:failed] and @object.tasks_summary[:failed] > 0 %>
151 <button id="set-show-failed-only" class="btn btn-danger">
152 Show failed task diagnostics only
156 <button id="filter-all" class="btn">
159 <button id="filter-none" class="btn">
165 <input class="search pull-right" style="margin-top: 1em" placeholder="Search" />
168 <div class="radio-inline log-viewer-button" style="margin-left: 10px">
169 <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
171 <div class="radio-inline log-viewer-button">
172 <label><input id="sort-by-node" type="radio" name="sort-radio" > Sort by node</label>
175 <div class="radio-inline log-viewer-button">
176 <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
181 <div class="radio-inline log-viewer-button" style="margin-left: 10px">
182 <label><input id="show-all-tasks" type="radio" name="show-tasks-group" checked="true" class="radio-filter"> Show all tasks</label>
184 <div class="radio-inline log-viewer-button">
185 <label><input id="show-successful-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only successful tasks</label>
187 <div class="radio-inline log-viewer-button">
188 <label><input id="show-failed-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only failed tasks</label>
193 <div class="checkbox-inline log-viewer-button" style="margin-left: 10px">
194 <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch diagnostics</label>
196 <div class="checkbox-inline log-viewer-button">
197 <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
199 <div class="checkbox-inline log-viewer-button">
200 <label><input id="show-task-print" type="checkbox" checked="true" class="toggle-filter"> Show task diagnostics</label>
202 <div class="checkbox-inline log-viewer-button">
203 <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
208 <div class="smart-scroll" data-smart-scroll-padding-bottom="50" style="margin-bottom: 0px">
209 <table class="log-viewer-table">
212 <th class="id" data-sort="id"></th>
213 <th class="timestamp" data-sort="timestamp">Timestamp</th>
214 <th class="node" data-sort="node">Node</th>
215 <th class="slot" data-sort="slot">Slot</th>
216 <th class="type" data-sort="type">Log type</th>
217 <th class="taskid" data-sort="taskid">Task</th>
218 <th class="message" data-sort="message">Message</th>
224 <td class="timestamp"></td>
225 <td class="node"></td>
226 <td class="slot"></td>
227 <td class="type"></td>
228 <td class="taskid"></td>
229 <td class="message"></td>
234 <% if @object.log and logcollection %>
235 <div class="spinner spinner-32px"></div>
240 <div class="log-viewer-paging-div" style="margin-bottom: -15px">
241 <a href="#" class="log-viewer-page-up"><span class='glyphicon glyphicon-arrow-up'></span></a>
242 <span class="log-viewer-paging"></span>
243 <a href="#" class="log-viewer-page-down"><span class='glyphicon glyphicon-arrow-down'></span></a>