2883: Added big red "show failed tasks" button.
[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 = newTaskState();
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] == "all-tasks") { v = true; }
23         else if (pass[a] == "successful-tasks" && taskState[item.values().taskid].outcome == "success") { v = true; }
24         else if (pass[a] == "failed-tasks" && taskState[item.values().taskid].outcome == "failure") { v = true; }
25       }
26     } else {
27       v = true;
28     }
29     for (a in pass) {
30       if (pass[a] == item.values().type) { return v; }
31     }
32     return false;
33   });
34 }
35
36 <% if @object.log %>
37 <% logcollection = Collection.find @object.log %>
38
39 $.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>').
40   done(function(data, status, jqxhr) {
41     logViewer.filter();
42     addToLogViewer(logViewer, data.split("\n"), taskState);
43     logViewer.filter(makeFilter());
44     generateJobOverview("#log-viewer-overview", logViewer, taskState);
45     $("#logloadspinner").detach();
46   });
47 <% else %>
48   <%# Live log loading not implemented yet. %>
49 <% end %>
50
51 $(".toggle-filter").on("change", function() {
52   logViewer.filter(makeFilter());
53 });
54
55 $("#filter-all").on("click", function() {
56   $(".toggle-filter").each(function(i, f) { f.checked = true; });
57   logViewer.filter(makeFilter());
58 });
59
60 $("#filter-none").on("click", function() {
61   $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
62   logViewer.filter(makeFilter());
63 });
64
65 $("#sort-by-time").on("change", function() {
66   logViewer.sort("id", {sortFunction: sortById});
67 });
68
69 $("#sort-by-task").on("change", function() {
70   logViewer.sort("taskid", {sortFunction: sortByTask});
71 });
72
73 $("#sort-by-node").on("change", function() {
74   logViewer.sort("node", {sortFunction: sortByNode});
75 });
76
77 $("#set-show-failed-only").on("click", function() {
78   $("#sort-by-task").prop("checked", true);
79   $("#show-failed-tasks").prop("checked", true);
80   $("#show-crunch").prop("checked", false);
81   $("#show-task-dispatch").prop("checked", true);
82   $("#show-task-output").prop("checked", true);
83   $("#show-crunchstat").prop("checked", false);
84   logViewer.filter(makeFilter());
85   logViewer.sort("taskid", {sortFunction: sortByTask});
86 });
87
88 })();
89
90 </script>
91
92 <div id="log-viewer">
93
94   <h3>Summary</h3>
95   <div id="log-viewer-overview"></div>
96
97   <% if @object.tasks_summary[:failed] > 0 %>
98     <button id="set-show-failed-only" class="btn btn-danger" style="margin-top: 1em">
99       Show failed task output only
100     </button>
101  <% end %>
102
103   <div class="h3">Log
104
105 <span class="pull-right">
106     <button id="filter-all" class="btn">
107       Select all
108     </button>
109     <button id="filter-none" class="btn">
110       Select none
111     </button>
112 </span>
113 </div>
114
115   <div>
116     <div class="radio-inline log-viewer-button" style="margin-left: 10px">
117       <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
118     </div>
119     <div class="radio-inline log-viewer-button">
120       <label><input id="sort-by-node" type="radio" name="sort-radio" > Sort by node</label>
121     </div>
122
123     <div class="radio-inline log-viewer-button">
124       <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
125     </div>
126   </div>
127
128   <div>
129     <div class="radio-inline log-viewer-button" style="margin-left: 10px">
130       <label><input id="show-all-tasks" type="radio" name="show-tasks-group" checked="true" class="toggle-filter"> Show all tasks</label>
131     </div>
132     <div class="radio-inline log-viewer-button">
133       <label><input id="show-successful-tasks" type="radio" name="show-tasks-group" class="toggle-filter"> Only successful tasks</label>
134     </div>
135     <div class="radio-inline log-viewer-button">
136       <label><input id="show-failed-tasks" type="radio" name="show-tasks-group" class="toggle-filter"> Only failed tasks</label>
137     </div>
138   </div>
139
140   <div>
141     <div class="checkbox-inline log-viewer-button" style="margin-left: 10px">
142       <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch output</label>
143     </div>
144     <div class="checkbox-inline log-viewer-button">
145       <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
146     </div>
147     <div class="checkbox-inline log-viewer-button">
148       <label><input id="show-task-output" type="checkbox" checked="true" class="toggle-filter"> Show task output</label>
149     </div>
150     <div class="checkbox-inline log-viewer-button">
151       <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
152     </div>
153
154   </div>
155
156   <table class="log-viewer-table">
157     <thead>
158       <tr>
159         <th class="id" data-sort="id"></th>
160         <th class="timestamp" data-sort="timestamp">Timestamp</th>
161         <th class="node"  data-sort="node">Node</th>
162         <th class="slot"  data-sort="slot">Slot</th>
163         <th class="type" data-sort="type">Log type</th>
164         <th class="taskid"  data-sort="taskid">Task</th>
165         <th class="message" data-sort="message">Message</th>
166       </tr>
167     </thead>
168     <tbody class="list">
169       <tr>
170         <td class="id"></td>
171         <td class="timestamp"></td>
172         <td class="node"></td>
173         <td class="slot"></td>
174         <td class="type"></td>
175         <td class="taskid"></td>
176         <td class="message"></td>
177       </tr>
178     </tbody>
179   </table>
180
181 </div>
182
183 <% if !@object.log %>
184   This job is still running.  The job log will be available when the job is complete.
185 <% end %>
186
187 <%= image_tag 'ajax-loader.gif', id: "logloadspinner" %>