Merge branch 'master' into 3188-remove-selected-button
[arvados.git] / apps / workbench / app / views / jobs / _show_log.html.erb
1 <% if !@object.log %>
2
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| %>
6     <%=entry%><br/>
7   <% end %>
8 </div>
9
10 <% else %>
11
12 <script>
13 (function() {
14 var pagesize = 1000;
15 var logViewer = new List('log-viewer', {
16   valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type'],
17   page: pagesize
18 });
19
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; });
24
25 var taskState = newTaskState();
26
27 var makeFilter = function() {
28   var pass = [];
29   $(".toggle-filter, .radio-filter").each(function(i, e) {
30     if (e.checked) {
31       pass.push(e.id.substr(5));
32     }
33   });
34
35   return (function(item) {
36     var v = false;
37     if (item.values().taskid !== "") {
38       for (a in pass) {
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; }
42       }
43     } else {
44       v = true;
45     }
46     for (a in pass) {
47       if (pass[a] == item.values().type) { return v; }
48     }
49     return false;
50   });
51 }
52
53 <% if @object.log %>
54   <% logcollection = Collection.find @object.log %>
55   <% if logcollection %>
56     $.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>').
57         done(function(data, status, jqxhr) {
58             logViewer.filter();
59             addToLogViewer(logViewer, data.split("\n"), taskState);
60             logViewer.filter(makeFilter());
61             generateJobOverview("#log-viewer-overview", logViewer, taskState);
62             $("#log-viewer .spinner").detach();
63         }).
64         fail(function(jqxhr, status, error) {
65             $("#log-viewer .spinner").detach();
66         });
67   <% end %>
68 <% else %>
69   <%# Live log loading not implemented yet. %>
70 <% end %>
71
72 $(".toggle-filter, .radio-filter").on("change", function() {
73   logViewer.filter(makeFilter());
74 });
75
76 $("#filter-all").on("click", function() {
77   $(".toggle-filter").each(function(i, f) { f.checked = true; });
78   logViewer.filter(makeFilter());
79 });
80
81 $("#filter-none").on("click", function() {
82   $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
83   logViewer.filter(makeFilter());
84 });
85
86 $("#sort-by-time").on("change", function() {
87   logViewer.sort("id", {sortFunction: sortById});
88 });
89
90 $("#sort-by-task").on("change", function() {
91   logViewer.sort("taskid", {sortFunction: sortByTask});
92 });
93
94 $("#sort-by-node").on("change", function() {
95   logViewer.sort("node", {sortFunction: sortByNode});
96 });
97
98 $("#set-show-failed-only").on("click", function() {
99   $("#sort-by-task").prop("checked", true);
100   $("#show-failed-tasks").prop("checked", true);
101   $("#show-crunch").prop("checked", false);
102   $("#show-task-dispatch").prop("checked", true);
103   $("#show-script-print").prop("checked", true);
104   $("#show-crunchstat").prop("checked", false);
105   logViewer.filter(makeFilter());
106   logViewer.sort("taskid", {sortFunction: sortByTask});
107 });
108
109 })();
110
111 </script>
112
113 <div id="log-viewer">
114
115   <h3>Summary</h3>
116   <p id="log-viewer-overview">
117     <% if !logcollection %>
118       The collection containing the job log was not found.
119     <% end %>
120   </p>
121
122   <div class="h3">Log
123
124     <span class="pull-right">
125       <% if @object.andand.tasks_summary.andand[:failed] and @object.tasks_summary[:failed] > 0 %>
126         <button id="set-show-failed-only" class="btn btn-danger">
127           Show failed task diagnostics only
128         </button>
129       <% end %>
130
131       <button id="filter-all" class="btn">
132         Select all
133       </button>
134       <button id="filter-none" class="btn">
135         Select none
136       </button>
137     </span>
138   </div>
139
140   <input class="search pull-right" style="margin-top: 1em" placeholder="Search" />
141
142   <div>
143     <div class="radio-inline log-viewer-button" style="margin-left: 10px">
144       <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
145     </div>
146     <div class="radio-inline log-viewer-button">
147       <label><input id="sort-by-node" type="radio" name="sort-radio" > Sort by node</label>
148     </div>
149
150     <div class="radio-inline log-viewer-button">
151       <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
152     </div>
153   </div>
154
155   <div>
156     <div class="radio-inline log-viewer-button" style="margin-left: 10px">
157       <label><input id="show-all-tasks" type="radio" name="show-tasks-group" checked="true" class="radio-filter"> Show all tasks</label>
158     </div>
159     <div class="radio-inline log-viewer-button">
160       <label><input id="show-successful-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only successful tasks</label>
161     </div>
162     <div class="radio-inline log-viewer-button">
163       <label><input id="show-failed-tasks" type="radio" name="show-tasks-group" class="radio-filter"> Only failed tasks</label>
164     </div>
165   </div>
166
167   <div>
168     <div class="checkbox-inline log-viewer-button" style="margin-left: 10px">
169       <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch diagnostics</label>
170     </div>
171     <div class="checkbox-inline log-viewer-button">
172       <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
173     </div>
174     <div class="checkbox-inline log-viewer-button">
175       <label><input id="show-task-print" type="checkbox" checked="true" class="toggle-filter"> Show task diagnostics</label>
176     </div>
177     <div class="checkbox-inline log-viewer-button">
178       <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
179     </div>
180
181   </div>
182
183   <div class="smart-scroll" data-smart-scroll-padding-bottom="50" style="margin-bottom: 0px">
184     <table class="log-viewer-table">
185       <thead>
186         <tr>
187           <th class="id" data-sort="id"></th>
188           <th class="timestamp" data-sort="timestamp">Timestamp</th>
189           <th class="node"  data-sort="node">Node</th>
190           <th class="slot"  data-sort="slot">Slot</th>
191           <th class="type" data-sort="type">Log type</th>
192           <th class="taskid"  data-sort="taskid">Task</th>
193           <th class="message" data-sort="message">Message</th>
194         </tr>
195       </thead>
196       <tbody class="list">
197         <tr>
198           <td class="id"></td>
199           <td class="timestamp"></td>
200           <td class="node"></td>
201           <td class="slot"></td>
202           <td class="type"></td>
203           <td class="taskid"></td>
204           <td class="message"></td>
205         </tr>
206       </tbody>
207     </table>
208
209     <% if @object.log and logcollection %>
210       <div class="spinner spinner-32px"></div>
211     <% end %>
212
213   </div>
214
215   <div class="log-viewer-paging-div" style="margin-bottom: -15px">
216     <a href="#" class="log-viewer-page-up"><span class='glyphicon glyphicon-arrow-up'></span></a>
217     <span class="log-viewer-paging"></span>
218     <a href="#" class="log-viewer-page-down"><span class='glyphicon glyphicon-arrow-down'></span></a>
219   </div>
220 </div>
221
222 <% end %>