Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Git 150 initial draft Tex render #175

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/App/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ html, body {

.container {
display:flex;
flex-direction: column;
align-items: center;
padding-top: 20px;
height:100%;
width:100%;
}
}
72 changes: 57 additions & 15 deletions src/components/App/index.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,74 @@
import React from 'react';
import React, { useState, useEffect } from 'react';

import {
HappiGraph,
HappiGraphActions
} from '../HappiGraph';

import { GraphType } from "../HappiGraph/happi-graph.helpers";

import './index.scss';
import '../HappiGraph/happi-graph.scss';

import { mockData } from '../../mockData';
import { mockData as lineageMockData } from '../../mockData';
import {texMockData} from '../HappiGraph/Tex/dataRender';
import { Modal } from '@mantine/core';

const rawData = {
...mockData
};


export function App() {
const [selectedNodeData, setSelectedNodeData] = useState(undefined);
const [opened, setOpened] = useState(false);
//To switch the graph types displayed between Lineage/Inheritance/Neighbourhood graphs, change the initial graphType state to your preference
const [graphType, setGraphType] = useState(GraphType.LINEAGE);

const selectGraphData = () => {
let objectGraphData;
switch(graphType) {
case GraphType.LINEAGE: {
objectGraphData = lineageMockData;
break;
}
case GraphType.TEX_INHERITANCE: {
objectGraphData = texMockData;
break;
}
case GraphType.TEX_NEIGHBOURHOOD: {
objectGraphData = texMockData;
break;
}
default:
objectGraphData = texMockData;
console.log('GRAPH_TYPE_NOT_SELECTED');
}
return objectGraphData;
}

return <>
<div className="container">
<HappiGraph rawData={{...rawData}}
algorithm={""}
debug={false}
printMode={false}
graphDirection={"VERTICAL"}
selectedNodeId={"term@68e36496-7167-4af7-abdd-a0cd36e24084:6662c0f2.e1b1ec6c.66k78i6du.uchsna1.rn2epa.rfn2fjqf7h4qvmt5lflm8"}
actions={<HappiGraphActions rawData={{...rawData}}/>}
onNodeClick={(d: any) => console.log(d)}
onGraphRender={() => { console.log('Graph rendered');}} />

<Modal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extract tex functionality in separate demo component so that we can differentiate and encapsulate the functionality

ideally the modal should be implemented in the egeria-ui-components where there will be a new happi-graph instance

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the frontend to have a dropdown menu to choose the graph type, the only issue I'm struggling with a bit is to have the Happi Graph update with the new Graph Type state after you change it with the dropdown. If you run the code it should make sense. For example, whatever graph type you start with is ok, but then if you change the graph via the down from Inheritance to Lineage, the graph does not refresh to show the Lineage graph.

opened={opened}
onClose={() => setOpened(false)}
withCloseButton={false}
centered
size="50%"
>
{ selectedNodeData && JSON.stringify(selectedNodeData) }
</Modal>

<div style={{width: 1200, height: 800, margin: '0 auto'}}>
<HappiGraph rawData={{...selectGraphData()}}
algorithm={"VISJS"}
graphType={graphType}
debug={false}
printMode={false}
graphDirection={"HORIZONTAL"}
selectedNodeId={""}
actions={<HappiGraphActions rawData={{...selectGraphData()}}/>}
onNodeClick={(d: any) => { setSelectedNodeData(d); setOpened(true); }}
onGraphRender={() => { console.log('Graph rendered'); }} />
</div>
</div>
</>;
}
}
47 changes: 47 additions & 0 deletions src/components/HappiGraph/Tex/dataRender.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { rawTexData } from "./mockTexData";

export const texMockData = {
nodes: [
...Object.keys(rawTexData.typeExplorer.entities).map((e) => {
return {
id: rawTexData.typeExplorer.entities[e].entityDef.guid,
label: e,
group: "Port",
guid: rawTexData.typeExplorer.entities[e].entityDef.guid,
tex: {
entityType: "OpenMetadataRoot",
desciption: {
"Description": "Common root for all open metadata entity types.",
"Type Status": "ACTIVE_TYPEDEF",
"Attributes": "list is empty",
"Relationships": "none",
"Classifications ": "",
},
extras: {
"Anchors": "",
"Memento": "",
},
},
};
}),
],
edges: [
...Object.keys(rawTexData.typeExplorer.entities)
.filter((e) => {
if (rawTexData.typeExplorer.entities[e].entityDef.superType) {
return true;
} else {
return false;
}
})
.map((e) => {
return {
id: `${rawTexData.typeExplorer.entities[e].entityDef.guid}-${rawTexData.typeExplorer.entities[e].entityDef.superType.guid}`,
to: rawTexData.typeExplorer.entities[e].entityDef.guid,
from: rawTexData.typeExplorer.entities[e].entityDef.superType.guid,
label: "Label",
type: null,
};
}),
],
};
Loading