2883: Fixes secondary key sort bug. Adds filtering on successful/failed tasks.
authorPeter Amstutz <peter.amstutz@curoverse.com>
Mon, 16 Jun 2014 15:43:20 +0000 (15:43 +0000)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Mon, 16 Jun 2014 15:43:20 +0000 (15:43 +0000)
apps/workbench/app/assets/javascripts/log_viewer.js
apps/workbench/app/assets/stylesheets/log_viewer.scss
apps/workbench/app/views/jobs/_show_log.html.erb

index d6c611bf78ab9beaab874b81ba4fcd47f6ade978..fc1d93414cf08abac046e1bf323fd664b8980686 100644 (file)
@@ -8,12 +8,14 @@ function addToLogViewer(logViewer, lines, taskState) {
 
             v11 = v[11];
             if (typeof v[11] === 'undefined') {
-                v11 = '&nbsp;';
+                v11 = "";
+            } else {
+                v11 = Number(v11);
             }
 
             var message = v[12];
             var type = "";
-            if (v11 != '&nbsp;') {
+            if (v11 !== "") {
                 if (/^stderr /.test(message)) {
                     message = message.substr(7);
                     if (/^crunchstat: /.test(message)) {
@@ -25,10 +27,10 @@ function addToLogViewer(logViewer, lines, taskState) {
                         type = "task-output";
                     }
                 } else {
-                    if (/^success in (\d+)/) {
+                    if (/^success in (\d+)/.test(message)) {
                         taskState[v11] = "success";
                     }
-                    if (/^failure \([^)]+\) (\d+)/) {
+                    if (/^failure \([^)]+\) (\d+)/.test(message)) {
                         taskState[v11] = "failure";
                     }
                     type = "task-dispatch";
@@ -56,3 +58,32 @@ function addToLogViewer(logViewer, lines, taskState) {
     }
     logViewer.update();
 }
+
+function sortByTaskThenId(a, b, opt) {
+    a = a.values();
+    b = b.values();
+
+    if (a["taskid"] === "" && b["taskid"] !== "") {
+        return -1;
+    }
+    if (a["taskid"] !== "" && b["taskid"] === "") {
+        return 1;
+    }
+
+    if (a["taskid"] !== "" && b["taskid"] !== "") {
+        if (a["taskid"] > b["taskid"]) {
+            return 1;
+        }
+        if (a["taskid"] < b["taskid"]) {
+            return -1;
+        }
+    }
+
+    if (a["id"] > b["id"]) {
+        return 1;
+    }
+    if (a["id"] < b["id"]) {
+        return -1;
+    }
+    return 0;
+}
index f88ae3d4321524abe79f3709f452a0ee8a536a1e..600c0121063066cadec5b3fb62ad9683eb484e12 100644 (file)
@@ -2,6 +2,7 @@
  width: 100%;
  font-family: "Lucida Console", Monaco, monospace;
  font-size: 11px;
+ table-layout: fixed;
  thead tr {
    th {
      padding-right: 1em;
      display: none;
    }
    th.timestamp {
-     width: 15em;
+     width: 14em;
    }
    th.type {
-     width: 10em;
+     width: 8em;
    }
    th.taskid {
      width: 3em;
    }
+   th.message {
+     width: auto;
+   }
  }
  tbody tr {
    vertical-align: top;
@@ -30,5 +34,8 @@
    td.taskid {
      text-align: right;
    }
+   td.message {
+     word-wrap: break-word;
+   }
  }
 }
\ No newline at end of file
index cead801180a68879c258bb04d72a95dab820d43d..41cd08f50b9d401e8a8e2f47b8fea5cda7450116 100644 (file)
@@ -5,6 +5,8 @@ var logViewer = new List('log-viewer', {
   page: 10000,
 });
 
+var taskState = {};
+
 var makeFilter = function() {
   var pass = [];
   $(".toggle-filter").each(function(i, e) {
@@ -12,9 +14,19 @@ var makeFilter = function() {
       pass.push(e.id.substr(5));
     }
   });
+
   return (function(item) {
+    var v = false;
+    if (item.values().taskid !== "") {
+      for (a in pass) {
+        if (pass[a] == "successful-tasks" && taskState[item.values().taskid] == "success") { v = true; }
+        if (pass[a] == "failed-tasks" && taskState[item.values().taskid] == "failure") { v = true; }
+      }
+    } else {
+      v = true;
+    }
     for (a in pass) {
-      if (pass[a] == item.values().type) { return true; }
+      if (pass[a] == item.values().type) { return v; }
     }
     return false;
   });
@@ -26,7 +38,7 @@ var makeFilter = function() {
 $.ajax('<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>').
   done(function(data, status, jqxhr) {
     logViewer.filter();
-    addToLogViewer(logViewer, data.split("\n"));
+    addToLogViewer(logViewer, data.split("\n"), taskState);
     logViewer.filter(makeFilter());
     $("#logloadspinner").detach();
   });
@@ -53,7 +65,7 @@ $("#sort-by-time").on("change", function() {
 });
 
 $("#sort-by-task").on("change", function() {
-  logViewer.sort("taskid");
+  logViewer.sort("taskid", {sortFunction: sortByTaskThenId});
 });
 
 })();
@@ -69,17 +81,6 @@ $("#sort-by-task").on("change", function() {
       <label><input id="sort-by-task" type="radio" name="sort-radio" > Sort by task</label>
     </div>
 
-<br>
-    <div class="radio-inline">
-      <label><input id="filter-tasks-all" type="radio" name="tasks-radio" checked> Show all tasks</label>
-    </div>
-    <div class="radio-inline">
-      <label><input id="filter-tasks-successes" type="radio" name="tasks-radio" > Show successes only</label>
-    </div>
-    <div class="radio-inline">
-      <label><input id="filter-tasks-failures" type="radio" name="tasks-radio" > Show failures only</label>
-    </div>
-<br>
   <div class="checkbox-inline">
     <label><input id="show-crunch" type="checkbox" checked="true" class="toggle-filter"> Show crunch output</label>
   </div>
@@ -95,6 +96,12 @@ $("#sort-by-task").on("change", function() {
   <div class="checkbox-inline">
     <label><input id="show-crunchstat" type="checkbox" checked="true" class="toggle-filter"> Show compute usage</label>
   </div>
+  <div class="checkbox-inline">
+    <label><input id="show-successful-tasks" type="checkbox" checked="true" class="toggle-filter"> Show successful tasks</label>
+  </div>
+  <div class="checkbox-inline">
+    <label><input id="show-failed-tasks" type="checkbox" checked="true" class="toggle-filter"> Show failed tasks</label>
+  </div>
 
 <div class="pull-right">
     <button id="filter-all" class="btn">