You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@age.apache.org by em...@apache.org on 2021/12/13 01:43:13 UTC

[incubator-age-viewer] branch main updated: feat: Extends node for AGE flavor (#17)

This is an automated email from the ASF dual-hosted git repository.

emotionbug pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-age-viewer.git


The following commit(s) were added to refs/heads/main by this push:
     new a521e8d  feat: Extends node for AGE flavor (#17)
a521e8d is described below

commit a521e8d0de32891d5972742739063a0a716a1d26
Author: Hanbyeol Shin / 신한별 <76...@users.noreply.github.com>
AuthorDate: Mon Dec 13 10:43:07 2021 +0900

    feat: Extends node for AGE flavor (#17)
---
 .../containers/CypherResultCytoscapeContainer.js   |  2 +
 .../presentations/CypherResultCytoscape.jsx        |  4 ++
 .../cytoscape/CypherResultCytoscapeChart.jsx       | 46 +++++++++++++++-------
 3 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/frontend/src/components/cypherresult/containers/CypherResultCytoscapeContainer.js b/frontend/src/components/cypherresult/containers/CypherResultCytoscapeContainer.js
index db25621..82ae641 100644
--- a/frontend/src/components/cypherresult/containers/CypherResultCytoscapeContainer.js
+++ b/frontend/src/components/cypherresult/containers/CypherResultCytoscapeContainer.js
@@ -50,6 +50,8 @@ const mapStateToProps = (state, ownProps) => {
     maxDataOfGraph: state.setting.maxDataOfGraph,
     maxDataOfTable: state.setting.maxDataOfTable,
     setChartLegend: ownProps.setChartLegend,
+    lavor: state.database.flavor,
+    graph: state.database.graph,
   };
 };
 
diff --git a/frontend/src/components/cypherresult/presentations/CypherResultCytoscape.jsx b/frontend/src/components/cypherresult/presentations/CypherResultCytoscape.jsx
index e358455..ad63e52 100644
--- a/frontend/src/components/cypherresult/presentations/CypherResultCytoscape.jsx
+++ b/frontend/src/components/cypherresult/presentations/CypherResultCytoscape.jsx
@@ -379,6 +379,8 @@ const CypherResultCytoscape = forwardRef((props, ref) => {
         cytoscapeLayout={cytoscapeLayout}
         addLegendData={addLegendData}
         maxDataOfGraph={maxDataOfGraph}
+        flavor={props.flavor}
+        graph={props.graph}
       />
       <CypherResultCytoscapeFooter
         captions={captions}
@@ -419,6 +421,8 @@ CypherResultCytoscape.propTypes = {
   setLabels: PropTypes.func.isRequired,
   refKey: PropTypes.string.isRequired,
   setChartLegend: PropTypes.func.isRequired,
+  flavor: PropTypes.string.isRequired,
+  graph: PropTypes.string.isRequired,
 };
 
 export default CypherResultCytoscape;
diff --git a/frontend/src/components/cytoscape/CypherResultCytoscapeChart.jsx b/frontend/src/components/cytoscape/CypherResultCytoscapeChart.jsx
index 7c0d760..e4995d4 100644
--- a/frontend/src/components/cytoscape/CypherResultCytoscapeChart.jsx
+++ b/frontend/src/components/cytoscape/CypherResultCytoscapeChart.jsx
@@ -52,7 +52,7 @@ cytoscape.use(cxtmenu);
 
 const CypherResultCytoscapeCharts = ({
   elements, cytoscapeObject, setCytoscapeObject, cytoscapeLayout, maxDataOfGraph,
-  onElementsMouseover, addLegendData,
+  onElementsMouseover, addLegendData, flavor, graph,
 }) => {
   const [cytoscapeMenu, setCytoscapeMenu] = useState(null);
   const [initialized, setInitialized] = useState(false);
@@ -164,19 +164,35 @@ const CypherResultCytoscapeCharts = ({
               (<FontAwesomeIcon icon={faProjectDiagram} size="lg" />),
             ),
             select(ele) {
-              fetch('/api/v1/cypher',
-                {
-                  method: 'POST',
-                  headers: {
-                    Accept: 'application/json',
-                    'Content-Type': 'application/json',
-                  },
-                  body: JSON.stringify({ cmd: `MATCH (S)-[R]-(T) WHERE id(S) = '${ele.id()}' RETURN S, R, T` }),
-                })
-                .then((res) => res.json())
-                .then((data) => {
-                  addElements(ele.id(), data);
-                });
+              if (flavor === 'AGENS') {
+                fetch('/api/v1/cypher',
+                  {
+                    method: 'POST',
+                    headers: {
+                      Accept: 'application/json',
+                      'Content-Type': 'application/json',
+                    },
+                    body: JSON.stringify({ cmd: `MATCH (S)-[R]-(T) WHERE id(S) = '${ele.id()}' RETURN S, R, T` }),
+                  })
+                  .then((res) => res.json())
+                  .then((data) => {
+                    addElements(ele.id(), data);
+                  });
+              } else {
+                fetch('/api/v1/cypher',
+                  {
+                    method: 'POST',
+                    headers: {
+                      Accept: 'application/json',
+                      'Content-Type': 'application/json',
+                    },
+                    body: JSON.stringify({ cmd: `SELECT * FROM cypher('${graph}', $$ MATCH (S)-[R]-(T) WHERE id(S) = ${ele.id()} RETURN S, R, T $$) as (S agtype, R agtype, T agtype);` }),
+                  })
+                  .then((res) => res.json())
+                  .then((data) => {
+                    addElements(ele.id(), data);
+                  });
+              }
             },
           },
 
@@ -271,6 +287,8 @@ CypherResultCytoscapeCharts.propTypes = {
   maxDataOfGraph: PropTypes.number.isRequired,
   onElementsMouseover: PropTypes.func.isRequired,
   addLegendData: PropTypes.func.isRequired,
+  flavor: PropTypes.string.isRequired,
+  graph: PropTypes.string.isRequired,
 };
 
 export default CypherResultCytoscapeCharts;