azkaban-aplcache

Improvement of user usability (#2070) * Improvement of user

12/21/2018 5:58:27 PM

Details

diff --git a/azkaban-web-server/src/web/js/azkaban/view/flow-execution-list.js b/azkaban-web-server/src/web/js/azkaban/view/flow-execution-list.js
index 8719821..d2d9204 100644
--- a/azkaban-web-server/src/web/js/azkaban/view/flow-execution-list.js
+++ b/azkaban-web-server/src/web/js/azkaban/view/flow-execution-list.js
@@ -35,7 +35,6 @@ azkaban.ExecutionListView = Backbone.View.extend({
 
   renderJobs: function (evt) {
     var data = this.model.get("data");
-    var lastTime = data.endTime == -1 ? (new Date()).getTime() : data.endTime;
     var executingBody = $("#executableBody");
     this.updateJobRow(data.nodes, executingBody);
 
@@ -43,6 +42,8 @@ azkaban.ExecutionListView = Backbone.View.extend({
         : data.endTime;
     var flowStartTime = data.startTime;
     this.updateProgressBar(data, flowStartTime, flowLastTime);
+
+    this.expandFailedOrKilledJobs(data.nodes);
   },
 
 //
@@ -67,13 +68,11 @@ azkaban.ExecutionListView = Backbone.View.extend({
 
   updateJobs: function (evt) {
     var update = this.model.get("update");
-    var lastTime = update.endTime == -1
-        ? (new Date()).getTime()
-        : update.endTime;
     var executingBody = $("#executableBody");
 
     if (update.nodes) {
       this.updateJobRow(update.nodes, executingBody);
+      this.expandFailedOrKilledJobs(update.nodes);
     }
 
     var data = this.model.get("data");
@@ -266,26 +265,54 @@ azkaban.ExecutionListView = Backbone.View.extend({
     }
   },
 
-  toggleExpandFlow: function (flow) {
-    console.log("Toggle Expand");
+  /**
+   * Expands or collapses a flow node according to the value of the expand
+   * parameter.
+   *
+   * @param flow - node to expand/collapse
+   * @param expand - if value true -> expand, false: collapse,
+   *                 undefined -> toggles node status
+   */
+  setFlowExpansion: function (flow, expand) {
     var tr = flow.joblistrow;
     var subFlowRow = tr.subflowrow;
     var expandIcon = $(tr).find("> td > .listExpand");
-    if (tr.expanded) {
-      tr.expanded = false;
-      $(expandIcon).removeClass("glyphicon-chevron-up");
-      $(expandIcon).addClass("glyphicon-chevron-down");
 
-      $(tr).removeClass("expanded");
-      $(subFlowRow).hide();
-    }
-    else {
+    var needsExpansion = !tr.expanded && (expand === undefined || expand);
+    var needsCollapsing = tr.expanded && (expand === undefined || !expand);
+
+    if (needsExpansion) {
       tr.expanded = true;
       $(expandIcon).addClass("glyphicon-chevron-up");
       $(expandIcon).removeClass("glyphicon-chevron-down");
       $(tr).addClass("expanded");
       $(subFlowRow).show();
+
+    } else if (needsCollapsing) {
+      tr.expanded = false;
+      $(expandIcon).removeClass("glyphicon-chevron-up");
+      $(expandIcon).addClass("glyphicon-chevron-down");
+      $(tr).removeClass("expanded");
+      $(subFlowRow).hide();
+    } // else do nothing
+  },
+
+  expandFailedOrKilledJobs: function (nodes) {
+    var hasFailedOrKilled = false;
+    for (var i = 0; i < nodes.length; ++i) {
+      var node = nodes[i].changedNode ? nodes[i].changedNode : nodes[i];
+
+      if (node.type === "flow") {
+        if (this.expandFailedOrKilledJobs(node.nodes || [])) {
+          hasFailedOrKilled = true;
+          this.setFlowExpansion(node, true);
+        }
+
+      } else if (node.status === "FAILED" || node.status === "KILLED") {
+        hasFailedOrKilled = true;
+      }
     }
+    return hasFailedOrKilled;
   },
 
   addNodeRow: function (node, body) {
@@ -352,7 +379,7 @@ azkaban.ExecutionListView = Backbone.View.extend({
       $(expandIcon).addClass("expandarrow glyphicon glyphicon-chevron-down");
       $(expandIcon).click(function (evt) {
         var parent = $(evt.currentTarget).parents("tr")[0];
-        self.toggleExpandFlow(parent.node);
+        self.setFlowExpansion(parent.node);
       });
     }
 
@@ -410,13 +437,13 @@ var attemptRightClick = function (event) {
   var menu = [
     {
       title: "Open Attempt Log...", callback: function () {
-      window.location.href = requestURL;
-    }
+        window.location.href = requestURL;
+      }
     },
     {
       title: "Open Attempt Log in New Window...", callback: function () {
-      window.open(requestURL);
-    }
+        window.open(requestURL);
+      }
     }
   ];