2883: Distinguish between complete/incomplete and success/failure.
[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 })();
78
79 </script>
80
81 <div id="log-viewer">
82
83   <h3>Overview</h3>
84   <div id="log-viewer-overview"></div>
85
86   <div class="h3">Log
87
88 <span class="pull-right">
89     <button id="filter-all" class="btn">
90       Select all
91     </button>
92     <button id="filter-none" class="btn">
93       Select none
94     </button>
95 </span>
96 </div>
97
98   <div>
99     <div class="radio-inline log-viewer-button" style="margin-left: 10px">
100       <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
101     </div>
102     <div class="radio-inline log-viewer-button">
103       <label><input id="sort-by-node" type="radio" name="sort-radio" > Sort by node</label>
104     </div>
105
106     <div class="radio-inline log-viewer-button">
107       <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
108     </div>
109   </div>
110
111   <div>
112     <div class="radio-inline log-viewer-button" style="margin-left: 10px">
113       <label><input id="show-all-tasks" type="radio" name="show-tasks-group" checked="true" class="toggle-filter"> Show all tasks</label>
114     </div>
115     <div class="radio-inline log-viewer-button">
116       <label><input id="show-successful-tasks" type="radio" name="show-tasks-group" class="toggle-filter"> Only successful tasks</label>
117     </div>
118     <div class="radio-inline log-viewer-button">
119       <label><input id="show-failed-tasks" type="radio" name="show-tasks-group" class="toggle-filter"> Only failed tasks</label>
120     </div>
121   </div>
122
123   <div>
124     <div class="checkbox-inline log-viewer-button" style="margin-left: 10px">
125       <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch output</label>
126     </div>
127     <div class="checkbox-inline log-viewer-button">
128       <label><input id="show-job-status" type="checkbox" checked="true" class="toggle-filter"> Show job status</label>
129     </div>
130     <div class="checkbox-inline log-viewer-button">
131       <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
132     </div>
133     <div class="checkbox-inline log-viewer-button">
134       <label><input id="show-task-output" type="checkbox" checked="true" class="toggle-filter"> Show task output</label>
135     </div>
136     <div class="checkbox-inline log-viewer-button">
137       <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
138     </div>
139
140   </div>
141
142   <table class="log-viewer-table">
143     <thead>
144       <tr>
145         <th class="id" data-sort="id"></th>
146         <th class="timestamp" data-sort="timestamp">Timestamp</th>
147         <th class="node"  data-sort="node">Node</th>
148         <th class="slot"  data-sort="slot">Slot</th>
149         <th class="type" data-sort="type">Log type</th>
150         <th class="taskid"  data-sort="taskid">Task</th>
151         <th class="message" data-sort="message">Message</th>
152       </tr>
153     </thead>
154     <tbody class="list">
155       <tr>
156         <td class="id"></td>
157         <td class="timestamp"></td>
158         <td class="node"></td>
159         <td class="slot"></td>
160         <td class="type"></td>
161         <td class="taskid"></td>
162         <td class="message"></td>
163       </tr>
164     </tbody>
165   </table>
166
167 </div>
168
169 <% if !@object.log %>
170   This job is still running.  The job log will be available when the job is complete.
171 <% end %>
172
173 <%= image_tag 'ajax-loader.gif', id: "logloadspinner" %>