2883: Moved addToLogViewer function out of the template and into assets and
[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 makeFilter = function() {
9   var pass = [];
10   $(".toggle-filter").each(function(i, e) {
11     if (e.checked) {
12       pass.push(e.id.substr(5));
13     }
14   });
15   return (function(item) {
16     for (a in pass) {
17       if (pass[a] == item.values().type) { return true; }
18     }
19     return false;
20   });
21 }
22
23 <% if @object.log %>
24 <% logcollection = Collection.find @object.log %>
25
26 $.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>').
27   done(function(data, status, jqxhr) {
28     logViewer.filter();
29     addToLogViewer(logViewer, data.split("\n"));
30     logViewer.filter(makeFilter());
31     $("#logloadspinner").detach();
32   });
33 <% else %>
34   <%# Live log loading not implemented yet. %>
35 <% end %>
36
37 $(".toggle-filter").on("change", function() {
38   logViewer.filter(makeFilter());
39 });
40
41 $("#filter-all").on("click", function() {
42   $(".toggle-filter").each(function(i, f) { f.checked = true; });
43   logViewer.filter(makeFilter());
44 });
45
46 $("#filter-none").on("click", function() {
47   $(".toggle-filter").each(function(i, f) { f.checked = false; console.log(f); });
48   logViewer.filter(makeFilter());
49 });
50
51 $("#sort-by-time").on("change", function() {
52   logViewer.sort("id");
53 });
54
55 $("#sort-by-task").on("change", function() {
56   logViewer.sort("taskid");
57 });
58
59 })();
60
61 </script>
62
63 <div id="log-viewer">
64
65     <div class="radio-inline">
66       <label><input id="sort-by-time" type="radio" name="sort-radio" checked> Sort by time</label>
67     </div>
68     <div class="radio-inline">
69       <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
70     </div>
71 <br>
72   <div class="checkbox-inline">
73     <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch output</label>
74   </div>
75   <div class="checkbox-inline">
76     <label><input id="show-job-status" type="checkbox" checked="true" class="toggle-filter"> Show job status</label>
77   </div>
78   <div class="checkbox-inline">
79     <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
80   </div>
81   <div class="checkbox-inline">
82     <label><input id="show-task-output" type="checkbox" checked="true" class="toggle-filter"> Show task output</label>
83   </div>
84   <div class="checkbox-inline">
85     <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
86   </div>
87
88 <div 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 </div>
96
97   <table class="log-viewer-table">
98     <thead>
99       <tr>
100         <th class="id" data-sort="id"></th>
101         <th class="timestamp" data-sort="timestamp">Timestamp</th>
102         <th class="type" data-sort="type">Log type</th>
103         <th class="taskid"  data-sort="taskid">Task</th>
104         <th class="message" data-sort="message">Message</th>
105       </tr>
106     </thead>
107     <tbody class="list">
108       <tr>
109         <td class="id"></td>
110         <td class="timestamp"></td>
111         <td class="type"></td>
112         <td class="taskid"></td>
113         <td class="message"></td>
114       </tr>
115     </tbody>
116   </table>
117
118 </div>
119
120 <% if !@object.log %>
121   This job is still running.  The job log will be available when the job is complete.
122 <% end %>
123
124 <%= image_tag 'ajax-loader.gif', id: "logloadspinner" %>