2883: Moved addToLogViewer function out of the template and into assets and
[arvados.git] / apps / workbench / app / views / jobs / _show_log.html.erb
index 175b280b92eedf17f282aea5dff9bcad0daca39e..717eb71ad1234c1003f54b1c403833fa60ebe258 100644 (file)
@@ -1,49 +1,8 @@
 <script>
-
-function addToLogViewer(logViewer, lines) {
-  var re = /((\d\d\d\d)-(\d\d)-(\d\d))_((\d\d):(\d\d):(\d\d)) ([a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}) (\d+) (\d+)? (.*)/;
-  for (var a in lines) {
-    var v = lines[a].match(re);
-    if (v != null) {
-    v11 = v[11];
-    if (typeof v[11] === 'undefined') {
-      v11 = '&nbsp;';
-    }
-
-  var message = v[12];
-  var type = "";
-  if (v11 != '&nbsp;') {
-    if (/^stderr /.test(message)) {
-        type = "task-output";
-    } else {
-        type = "task-dispatch";
-    }
-  } else {
-    if (/^status: /.test(message)) {
-        type = "job-progress";
-    } else {
-        type = "crunch";
-    }
-  }
-
-    logViewer.add({
-      id: logViewer.items.length,
-      timestamp: v[1] + " " + v[5],
-      taskid: v11,
-      message: message,
-      type: type
-    });
-
-    } else {
-      console.log("Did not parse: " + lines[a]);
-    }
-  }
-  logViewer.update();
-}
-
 (function() {
 var logViewer = new List('log-viewer', {
-  valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type']
+  valueNames: [ 'id', 'timestamp', 'taskid', 'message', 'type'],
+  page: 10000,
 });
 
 var makeFilter = function() {
@@ -61,6 +20,7 @@ var makeFilter = function() {
   });
 }
 
+<% if @object.log %>
 <% logcollection = Collection.find @object.log %>
 
 $.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>').
@@ -70,6 +30,9 @@ $.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>').
     logViewer.filter(makeFilter());
     $("#logloadspinner").detach();
   });
+<% else %>
+  <%# Live log loading not implemented yet. %>
+<% end %>
 
 $(".toggle-filter").on("change", function() {
   logViewer.filter(makeFilter());
@@ -107,16 +70,19 @@ $("#sort-by-task").on("change", function() {
     </div>
 <br>
   <div class="checkbox-inline">
-    <label><input id="show-task-output" type="checkbox" checked="true" class="toggle-filter"> Show task output</label>
+    <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch output</label>
+  </div>
+  <div class="checkbox-inline">
+    <label><input id="show-job-status" type="checkbox" checked="true" class="toggle-filter"> Show job status</label>
   </div>
   <div class="checkbox-inline">
     <label><input id="show-task-dispatch" type="checkbox" checked="true" class="toggle-filter"> Show task dispatch</label>
   </div>
   <div class="checkbox-inline">
-    <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch output</label>
+    <label><input id="show-task-output" type="checkbox" checked="true" class="toggle-filter"> Show task output</label>
   </div>
   <div class="checkbox-inline">
-    <label><input id="show-job-progress" type="checkbox" checked="true" class="toggle-filter"> Show job progress</label>
+    <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
   </div>
 
 <div class="pull-right">
@@ -128,22 +94,22 @@ $("#sort-by-task").on("change", function() {
     </button>
 </div>
 
-  <table style='width: 100%; font-family:"Lucida Console", Monaco, monospace; font-size: 11px'>
+  <table class="log-viewer-table">
     <thead>
       <tr>
-        <th class="sort" data-sort="id" style="display:none;"></th>
-        <th class="sort" data-sort="timestamp" style="width: 12em">Timestamp</th>
-        <th class="sort" data-sort="type" style="width: 8em">Log type</th>
-        <th class="sort" data-sort="taskid" style="width: 4em">Task</th>
-        <th class="sort" data-sort="message" >Message</th>
+        <th class="id" data-sort="id"></th>
+        <th class="timestamp" data-sort="timestamp">Timestamp</th>
+        <th class="type" data-sort="type">Log type</th>
+        <th class="taskid"  data-sort="taskid">Task</th>
+        <th class="message" data-sort="message">Message</th>
       </tr>
     </thead>
     <tbody class="list">
       <tr>
-        <td class="id" style="display:none;">0</td>
+        <td class="id"></td>
         <td class="timestamp"></td>
         <td class="type"></td>
-        <td class="taskid" style="text-align: center"></td>
+        <td class="taskid"></td>
         <td class="message"></td>
       </tr>
     </tbody>
@@ -151,4 +117,8 @@ $("#sort-by-task").on("change", function() {
 
 </div>
 
+<% if !@object.log %>
+  This job is still running.  The job log will be available when the job is complete.
+<% end %>
+
 <%= image_tag 'ajax-loader.gif', id: "logloadspinner" %>