2883: Fixes secondary key sort bug. Adds filtering on successful/failed tasks.
[arvados.git] / apps / workbench / app / views / jobs / _show_log.html.erb
1 <script>
2 (function() {
3 var logViewer = new List('log-viewer', {
4   valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type'],
5   page: 10000,
6 });
7
8 var taskState = {};
9
10 var makeFilter = function() {
11   var pass = [];
12   $(".toggle-filter").each(function(i, e) {
13     if (e.checked) {
14       pass.push(e.id.substr(5));
15     }
16   });
17
18   return (function(item) {
19     var v = false;
20     if (item.values().taskid !== "") {
21       for (a in pass) {
22         if (pass[a] == "successful-tasks" && taskState[item.values().taskid] == "success") { v = true; }
23         if (pass[a] == "failed-tasks" && taskState[item.values().taskid] == "failure") { v = true; }
24       }
25     } else {
26       v = true;
27     }
28     for (a in pass) {
29       if (pass[a] == item.values().type) { return v; }
30     }
31     return false;
32   });
33 }
34
35 <% if @object.log %>
36 <% logcollection = Collection.find @object.log %>
37
38 $.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>').
39   done(function(data, status, jqxhr) {
40     logViewer.filter();
41     addToLogViewer(logViewer, data.split("\n"), taskState);
42     logViewer.filter(makeFilter());
43     $("#logloadspinner").detach();
44   });
45 <% else %>
46   <%# Live log loading not implemented yet. %>
47 <% end %>
48
49 $(".toggle-filter").on("change", function() {
50   logViewer.filter(makeFilter());
51 });
52
53 $("#filter-all").on("click", function() {
54   $(".toggle-filter").each(function(i, f) { f.checked = true; });
55   logViewer.filter(makeFilter());
56 });
57
58 $("#filter-none").on("click", function() {
59   $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
60   logViewer.filter(makeFilter());
61 });
62
63 $("#sort-by-time").on("change", function() {
64   logViewer.sort("id");
65 });
66
67 $("#sort-by-task").on("change", function() {
68   logViewer.sort("taskid", {sortFunction: sortByTaskThenId});
69 });
70
71 })();
72
73 </script>
74
75 <div id="log-viewer">
76
77     <div class="radio-inline">
78       <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
79     </div>
80     <div class="radio-inline">
81       <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
82     </div>
83
84   <div class="checkbox-inline">
85     <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch output</label>
86   </div>
87   <div class="checkbox-inline">
88     <label><input id="show-job-status" type="checkbox" checked="true" class="toggle-filter"> Show job status</label>
89   </div>
90   <div class="checkbox-inline">
91     <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
92   </div>
93   <div class="checkbox-inline">
94     <label><input id="show-task-output" type="checkbox" checked="true" class="toggle-filter"> Show task output</label>
95   </div>
96   <div class="checkbox-inline">
97     <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
98   </div>
99   <div class="checkbox-inline">
100     <label><input id="show-successful-tasks" type="checkbox" checked="true" class="toggle-filter"> Show successful tasks</label>
101   </div>
102   <div class="checkbox-inline">
103     <label><input id="show-failed-tasks" type="checkbox" checked="true" class="toggle-filter"> Show failed tasks</label>
104   </div>
105
106 <div class="pull-right">
107     <button id="filter-all" class="btn">
108       Select all
109     </button>
110     <button id="filter-none" class="btn">
111       Select none
112     </button>
113 </div>
114
115   <table class="log-viewer-table">
116     <thead>
117       <tr>
118         <th class="id" data-sort="id"></th>
119         <th class="timestamp" data-sort="timestamp">Timestamp</th>
120         <th class="type" data-sort="type">Log type</th>
121         <th class="taskid"  data-sort="taskid">Task</th>
122         <th class="message" data-sort="message">Message</th>
123       </tr>
124     </thead>
125     <tbody class="list">
126       <tr>
127         <td class="id"></td>
128         <td class="timestamp"></td>
129         <td class="type"></td>
130         <td class="taskid"></td>
131         <td class="message"></td>
132       </tr>
133     </tbody>
134   </table>
135
136 </div>
137
138 <% if !@object.log %>
139   This job is still running.  The job log will be available when the job is complete.
140 <% end %>
141
142 <%= image_tag 'ajax-loader.gif', id: "logloadspinner" %>