This repository has been archived by the owner on Jun 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Git 150 initial draft Tex render #175
Open
habiblawal1
wants to merge
8
commits into
odpi:main
Choose a base branch
from
habiblawal1:git150
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a87effe
Git 150 initial draft Tex render
habiblawal1 385b776
Git 150 removed unnecessary comments
habiblawal1 9ca8a76
Git 150 added and centred customisable title
habiblawal1 6cc2d97
Git 150 Seperated out tex data from mock data
habiblawal1 8f04975
Git 150 Split the graph type selection into a seperate method
habiblawal1 617173c
Git 150 removed duplicate code
habiblawal1 fd67d8e
Git 150 Added option to change graph type on frontend
habiblawal1 cbe17df
Git 150 removed the heading at the top of the page
habiblawal1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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> | ||
</>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; | ||
}), | ||
], | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.