ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsai...@apache.org
Subject ambari git commit: AMBARI-20883.Visual explain issues(Venkata Sairam)
Date Sun, 30 Apr 2017 06:15:44 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 52d0e2943 -> 66232aeed


AMBARI-20883.Visual explain issues(Venkata Sairam)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/66232aee
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/66232aee
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/66232aee

Branch: refs/heads/branch-2.5
Commit: 66232aeedac86a308cfc22621f80c25d5642616b
Parents: 52d0e29
Author: Venkata Sairam <venkatasairam.lanka@gmail.com>
Authored: Sun Apr 30 11:44:08 2017 +0530
Committer: Venkata Sairam <venkatasairam.lanka@gmail.com>
Committed: Sun Apr 30 11:45:31 2017 +0530

----------------------------------------------------------------------
 .../ui/app/utils/hive-explainer/renderer.js     | 146 ++++++++++++++++++-
 1 file changed, 140 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/66232aee/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js
----------------------------------------------------------------------
diff --git a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js
b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js
index 82627c8..3a23226 100644
--- a/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js
+++ b/contrib/views/hive20/src/main/resources/ui/app/utils/hive-explainer/renderer.js
@@ -119,7 +119,16 @@ export default function doRender(data, selector, onRequestDetail, draggable)
{
     .enter()
       .insert('path', ':first-child')
     .attr('class', 'edge')
-    .attr('d', d => (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) ? getConnectionPathFF(d,
svg, container) : getConnectionPath(d, svg, container));
+    .attr('d', d => (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) ? getConnectionPathFF(d,
svg, container, data) : getConnectionPath(d, svg, container, data));
+  if(navigator.userAgent.toLowerCase().indexOf('firefox') === -1) {
+    root.selectAll('path.arrow')
+      .data(data.connections)
+      .enter()
+      .insert('path')
+      .attr('class', 'arrow')
+      .style("stroke-width", function(d) { return Math.sqrt(d.value); })
+      .attr('d', d => getConnectionPathArrow(d, svg, container, data));
+  }
 
   reset(zoom, svg, container);
 
@@ -349,7 +358,7 @@ function reset(zoom, svg, container) {
     .call( zoom.event );
 }
 
-function getConnectionPathFF(connector, svg, container) {
+function getConnectionPathFF(connector, svg, container, data) {
   const source = container.select(`#${connector._source._uuid}`).node();
   const target = container.select(`#${connector._target._uuid}`).node();
   const rSource = d3.select(source).data()[0];
@@ -358,14 +367,19 @@ function getConnectionPathFF(connector, svg, container) {
   const rTargetVertex = d3.select(Ember.$(target).closest('.vertex').get(0)).data()[0];
 
   const offsetBox = Ember.$(container.node()).children('.vertex').get(0).getBoundingClientRect();
+  let connectionComplexity, connection = data.nodes.find((item)=>item["filterExpr:"]);
 
-
+  if(connection){
+    connectionComplexity = 0;
+  } else {
+    connectionComplexity = data.connections.length;
+  }
   const pSource = {
-    x: offsetBox.left - 200 + (rSourceVertex._X + (rSourceVertex._widthOfSelf - (rSource._indexX
+ 1))) * 200 + 140 / 2,
+    x: offsetBox.left - 200 - 200*connectionComplexity + (rSourceVertex._X + (rSourceVertex._widthOfSelf
- (rSource._indexX + 1))) * 200 + 140 / 2,
     y: offsetBox.top + (rSourceVertex._Y + rSource._indexY) * 100 + 55 / 2,
   };
   const pTarget = {
-    x: offsetBox.left - 200 + (rTargetVertex._X + (rTargetVertex._widthOfSelf - (rTarget._indexX
+ 1))) * 200 + 140 / 2,
+    x: offsetBox.left - 200 - 200*connectionComplexity + (rTargetVertex._X + (rTargetVertex._widthOfSelf
- (rTarget._indexX + 1))) * 200 + 140 / 2,
     y: offsetBox.top + (rTargetVertex._Y + rTarget._indexY) * 100 + 55 / 2,
   };
   const path = [
@@ -392,8 +406,72 @@ function getConnectionPathFF(connector, svg, container) {
   }, '');
 }
 
+function getConnectionPathFFArrow(connector, svg, container, data) {
+  const source = container.select(`#${connector._source._uuid}`).node();
+  const target = container.select(`#${connector._target._uuid}`).node();
+  const rSource = d3.select(source).data()[0];
+  const rTarget = d3.select(target).data()[0];
+  const rSourceVertex = d3.select(Ember.$(source).closest('.vertex').get(0)).data()[0];
+  const rTargetVertex = d3.select(Ember.$(target).closest('.vertex').get(0)).data()[0];
+
+  const offsetBox = Ember.$(container.node()).children('.vertex').get(0).getBoundingClientRect();
+
+  let connectionComplexity, connection = data.nodes.find((item)=>item["filterExpr:"]);
+  if(connection){
+    connectionComplexity = 0;
+  } else {
+    connectionComplexity = data.connections.length;
+  }
+  const pSource = {
+    x: offsetBox.left - 200 - 200*connectionComplexity + (rSourceVertex._X + (rSourceVertex._widthOfSelf
- (rSource._indexX + 1))) * 200 + 140 / 2,
+    y: offsetBox.top + (rSourceVertex._Y + rSource._indexY) * 100 + 55 / 2,
+  };
+  const pTarget = {
+    x: offsetBox.left - 200 - 200*connectionComplexity + (rTargetVertex._X + (rTargetVertex._widthOfSelf
- (rTarget._indexX + 1))) * 200 + 140 / 2,
+    y: offsetBox.top + (rTargetVertex._Y + rTarget._indexY) * 100 + 55 / 2,
+  };
+  const path = [
+    pTarget
+  ];
+  const junctionXMultiplier = (pTarget.x - pSource.x < 0) ? +1 : -1;
+  if(pSource.y !== pTarget.y) {
+    path.push({
+      x: pTarget.x + junctionXMultiplier * 90,
+      y: pTarget.y
+    }, {
+      x: pTarget.x + junctionXMultiplier * 90,
+      y: pSource.y
+    });
+  }
+  path.push(pSource);
+  const offsetY = svg.node().getBoundingClientRect().top;
+  return path.reduce((accumulator, cPoint, index) => {
+    if(path.length === 2){
+      if(index === 0) {
+        if(cPoint.x > 0){
+          return accumulator + `M ${cPoint.x + 60}, ${cPoint.y - offsetY+10} V 10, ${(cPoint.x+200)%(cPoint.x)
=== 0 ? 40:100}  L ${cPoint.x + 50}, ${cPoint.y - offsetY} Z\n`;
+        } else {
+          return accumulator + `M ${cPoint.x + 60}, ${cPoint.y - offsetY-10} V 10, ${Math.ceil((cPoint.x))%Math.ceil((cPoint.x+200))
=== -0 ? 40:100}  L ${cPoint.x + 50}, ${cPoint.y - offsetY} Z\n`;
+        }
+      } else {
+        return accumulator;
+      }
+    } else {
+      if(index === 0) {
+        if(cPoint.x > 0) {
+          return accumulator + `M ${cPoint.x + 60}, ${cPoint.y - offsetY-10} V 10, ${40}
L ${cPoint.x + 50}, ${cPoint.y - offsetY} Z\n`;
+        } else {
+          return accumulator + `M ${cPoint.x + 60}, ${cPoint.y - offsetY+10} V 10, ${40}
L ${cPoint.x + 50}, ${cPoint.y - offsetY} Z\n`;
+        }
+      } else {
+        return accumulator;
+      }
+    }
 
-function getConnectionPath(connector, svg, container){
+  }, '');
+}
+
+function getConnectionPath(connector, svg, container, data){
   const operators = container.selectAll('.operator');
   const source = container.select(`#${connector._source._uuid}`);
   const target = container.select(`#${connector._target._uuid}`);
@@ -431,6 +509,62 @@ function getConnectionPath(connector, svg, container){
   }, '');
 }
 
+function getConnectionPathArrow(connector, svg, container){
+
+  const operators = container.selectAll('.operator');
+  const source = container.select(`#${connector._source._uuid}`);
+  const target = container.select(`#${connector._target._uuid}`);
+  const rSource = source.node().getBoundingClientRect();
+  const rTarget = target.node().getBoundingClientRect();
+  const pSource = {
+    x: (rSource.left + rSource.right) / 2,
+    y: (rSource.top + rSource.bottom) / 2,
+  };
+  const pTarget = {
+    x: (rTarget.left + rTarget.right) / 2,
+    y: (rTarget.top + rTarget.bottom) / 2,
+  };
+  const path = [
+    pTarget
+  ];
+  const junctionXMultiplier = (pTarget.x - pSource.x < 0) ? +1 : -1;
+  if(pSource.y !== pTarget.y) {
+    path.push({
+      x: pTarget.x + junctionXMultiplier * 90,
+      y: pTarget.y
+    }, {
+      x: pTarget.x + junctionXMultiplier * 90,
+      y: pSource.y
+    });
+  }
+  path.push(pSource);
+  const offsetY = svg.node().getBoundingClientRect().top;
+  return path.reduce((accumulator, cPoint, index) => {
+    if(path.length === 2){
+      if(index === 0) {
+        if(cPoint.x > 0){
+          return accumulator + `M ${cPoint.x + 60}, ${cPoint.y - offsetY-15} V 0, ${(((cPoint.y
- offsetY-15)/100)*100)+35}  L ${cPoint.x + 50}, ${cPoint.y - offsetY} Z\n`;
+        } else {
+          return accumulator + `M ${cPoint.x + 60}, ${cPoint.y - offsetY-15} V 0, ${(((cPoint.y
- offsetY-15)/100)*100)+35}  L ${cPoint.x + 50}, ${cPoint.y - offsetY} Z\n`;
+        }
+      } else {
+        return accumulator;
+      }
+    } else {
+      if(index === 0) {
+        if(cPoint.x > 0) {
+          return accumulator + `M ${cPoint.x + 60}, ${cPoint.y - offsetY-15} V 0, ${(((cPoint.y
- offsetY-15)/100)*100)+35} L ${cPoint.x + 50}, ${cPoint.y - offsetY} Z\n`;
+        } else {
+          return accumulator + `M ${cPoint.x + 60}, ${cPoint.y - offsetY+15} V 0, ${10*6}
L ${cPoint.x + 50}, ${cPoint.y - offsetY} Z\n`;
+        }
+      } else {
+        return accumulator;
+      }
+    }
+  }, '');
+
+}
+
 function doClean(node) {
   if(Array.isArray(node._groups)) {
     return node._groups.map(cGroup => doClean(cGroup));


Mime
View raw message