Skip to content

Commit 871f61a

Browse files
authored
Merge pull request #228 from MetaCell/feature/SDSV-30
#SDSV-30 - Update Read me and fix graph viewer bugs
2 parents 424d8d0 + 30e4914 commit 871f61a

4 files changed

Lines changed: 35 additions & 29 deletions

File tree

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ Deployed version : https://metacell.github.io/sds-viewer/
66

77
The SDS Viewer can now be launched directly from datasets and models on the SPARC Portal (https://sparc.science/). From the landing page for your dataset or model of interest, simply click the SDS Viewer button, it will launch the viewer with it already loaded. In addition, users can load SPARC datasets using two other methods:
88

9-
1) Loading a SPARC Dataset from list:
9+
1) Loading a SPARC Dataset from app:
1010
- Click on 'SPARC Datasets' button, it's located on the lower left corner.
11-
- On the window that opens up, select the dataset you want to load.
11+
- On the window that opens up, select the dataset you want to load. You can search
12+
by dataset title and id.
1213
![image](https://user-images.githubusercontent.com/4562825/166984322-83b4a8c2-aa29-4e6d-96e9-bcf4d125a3a9.png)
1314
- After selection, click 'Done'
1415
- Dataset will be loaded.
@@ -21,27 +22,28 @@ The SDS Viewer can now be launched directly from datasets and models on the SPAR
2122
This will open up the SDS Viewer with the dataset already loaded.
2223

2324
##### Loaded dataset example #####
24-
![Screenshot 2023-09-21 at 3 50 49 PM](https://github.com/MetaCell/sds-viewer/assets/4562825/e7247cf1-df5e-498d-a418-4cbc7f4c4de2)
25+
![image](https://github.com/MetaCell/sds-viewer/assets/4562825/9ea43afd-28cc-4b37-8c72-96be2f821f1a)
26+
2527
##### SPARC Dataset used #####
2628
![Screenshot 2023-09-21 at 3 53 33 PM](https://github.com/MetaCell/sds-viewer/assets/4562825/f3e287ed-f93a-436b-b3b0-b85cb1c0857c)
2729

2830
2931
### Navigating the SDS Viewer
30-
- Users can search for subjects, folders and files on the sidebar. Selecting an item on the sidebar will display the Metadata for it and zoom the Graph to its corresponding node.
31-
![Screenshot 2023-09-21 at 4 04 23 PM](https://github.com/MetaCell/sds-viewer/assets/4562825/b64ea659-607f-42f7-b58f-edb01e31ab40)
32+
- Users can search for subjects, folders and files on the sidebar. Selecting an item on the sidebar will display the Metadata for it and zoom the Graph to its corresponding folder or file.
33+
![image](https://github.com/MetaCell/sds-viewer/assets/4562825/7b013f5a-eead-4996-b7d2-20b3bf35a294)
3234

3335

3436
- Selecting an item on the Graph will display its Metadata.
3537

3638
![image](https://user-images.githubusercontent.com/4562825/186723085-c6573146-82dc-4fb7-ae95-588f7b1e4842.png)
3739

38-
- Navigating the Graph Viewer can be done with the mouse. There's also controlers on the bottom right that allows the user to change the Layout view, zoom in/out, reset the view to its original state and expand all data in the viewer.
40+
- Navigating the Graph Viewer can be done with the mouse. There are also controllers on the bottom right that allow user to change the Graph Layout view, zoom in/out of the graph, reset the Layout to its original state and expand/collapse all data in the viewer.
3941

4042
![controllers](https://github.com/MetaCell/sds-viewer/assets/99416933/30aa8bb3-ec61-46d8-9f83-55ade15b95c0)
4143

42-
- Multiple Datasets can be loaded at the same time, which will open a new Graph Viewer Component for each dataset.
44+
- Multiple Datasets can be loaded at the same time, a new Graph Viewer Component will be opened for each dataset.
4345

44-
![multiple](https://github.com/MetaCell/sds-viewer/assets/99416933/a74fa033-ccd4-4609-b50f-852ce44d347a)
46+
![Multiple](https://github.com/MetaCell/sds-viewer/assets/4562825/9abe621a-a406-4e6b-8d6a-165622014425)
4547

4648

4749
### Datasets Used

src/components/GraphViewer/GraphViewer.js

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,10 @@ const GraphViewer = (props) => {
7070

7171
const handleNodeLeftClick = (node, event) => {
7272
if ( node.type === rdfTypes.Subject.key || node.type === rdfTypes.Sample.key || node.type === rdfTypes.Collection.key ) {
73-
node.collapsed = !node.collapsed;
7473
collapseSubLevels(node, node.collapsed, { links : 0 });
74+
node.collapsed = !node.collapsed;
7575
let updatedData = getPrunedTree(props.graph_id, selectedLayout.layout);
7676
setData(updatedData);
77-
78-
collapseSubLevels(node, true, { links : 0 });
79-
updatedData = getPrunedTree(props.graph_id, selectedLayout.layout);
80-
setData(updatedData);
8177
}
8278
handleNodeHover(node);
8379

@@ -121,7 +117,7 @@ const GraphViewer = (props) => {
121117
setCollapsed(!collapsed)
122118
setTimeout( () => {
123119
resetCamera();
124-
},200)
120+
},10)
125121
}
126122

127123
/**
@@ -174,10 +170,7 @@ const GraphViewer = (props) => {
174170

175171
const onEngineStop = () => {
176172
setForce();
177-
if ( triggerCenter ) {
178-
graphRef?.current?.ggv?.current.centerAt(selectedNode.x, selectedNode.y, ONE_SECOND);
179-
triggerCenter = false;
180-
}
173+
selectedNode && handleNodeRightClick(nodeSelected)
181174
}
182175

183176
useEffect(() => {
@@ -234,8 +227,10 @@ const GraphViewer = (props) => {
234227
}, [selectedNode]);
235228

236229
useEffect(() => {
237-
if ( nodeSelected && ( nodeSelected?.tree_reference?.dataset_id?.includes(props.graph_id) ||
238-
nodeSelected?.dataset_id?.includes(props.graph_id) )) {
230+
let sameDataset = nodeSelected?.tree_reference?.dataset_id?.includes(props.graph_id) ||
231+
nodeSelected?.dataset_id?.includes(props.graph_id)
232+
|| nodeSelected?.attributes?.dataset_id?.includes(props.graph_id);
233+
if ( nodeSelected && sameDataset) {
239234
if ( nodeSelected?.id !== selectedNode?.id ){
240235
let node = nodeSelected;
241236
let collapsed = node.collapsed
@@ -264,10 +259,10 @@ const GraphViewer = (props) => {
264259
let updatedData = getPrunedTree(props.graph_id, selectedLayout.layout);
265260
setData(updatedData);
266261
}
262+
setSelectedNode(nodeSelected);
263+
handleNodeHover(nodeSelected);
264+
graphRef?.current?.ggv?.current.centerAt(nodeSelected.x, nodeSelected.y, ONE_SECOND);
267265
}
268-
setSelectedNode(nodeSelected);
269-
handleNodeHover(nodeSelected);
270-
graphRef?.current?.ggv?.current.centerAt(nodeSelected.x, nodeSelected.y, ONE_SECOND);
271266
} else {
272267
handleNodeHover(nodeSelected);
273268
graphRef?.current?.ggv?.current.centerAt(nodeSelected.x, nodeSelected.y, ONE_SECOND);
@@ -362,11 +357,6 @@ const GraphViewer = (props) => {
362357
controls={
363358
<div>
364359
<div className='graph-view_controls'>
365-
<IconButton area-label="GraphLayout" aria-controls="layout-menu" aria-haspopup="true" onClick={handleLayoutClick}>
366-
<Tooltip id="button-report" title="Change Graph Layout">
367-
<ViewTypeIcon />
368-
</Tooltip>
369-
</IconButton>
370360
<Menu
371361
id="layout-menu"
372362
anchorEl={layoutAnchorEl}
@@ -378,6 +368,11 @@ const GraphViewer = (props) => {
378368
<MenuItem selected={TOP_DOWN.layout === selectedLayout.layout} onClick={() => handleLayoutChange(TOP_DOWN)}>{TOP_DOWN.label}</MenuItem>
379369
<MenuItem selected={LEFT_RIGHT.layout === selectedLayout.layout} onClick={() => handleLayoutChange(LEFT_RIGHT)}>{LEFT_RIGHT.label}</MenuItem>
380370
</Menu>
371+
<IconButton area-label="GraphLayout" aria-controls="layout-menu" aria-haspopup="true" onClick={handleLayoutClick}>
372+
<Tooltip id="button-report" title="Change Graph Layout">
373+
<ViewTypeIcon />
374+
</Tooltip>
375+
</IconButton>
381376
<IconButton area-label="ZoomIn" onClick={(e) => zoomIn()}>
382377
<Tooltip id="button-report" title="Zoom In">
383378
<AddRoundedIcon />

src/utils/Splinter.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ class Splinter {
799799
}
800800

801801
if (node.attributes?.relativePath !== undefined) {
802+
node.attributes.dataset_id = this.dataset_id;
802803
node.attributes.publishedURI =
803804
Array.from(this.nodes)[0][1].attributes.hasUriPublished[0] +
804805
"?datasetDetailsTab=files&path=files/" +
@@ -1097,6 +1098,14 @@ class Splinter {
10971098
if ( node.graph_reference === undefined ) {
10981099
node.graph_reference = this.findReference(node.uri_api);
10991100
}
1101+
if ( node.graph_reference === undefined ) {
1102+
const fn = (hashMap, str) => [...hashMap.keys()].find(k => k.includes(str))
1103+
const graph_reference = fn(this.nodes, node.id)
1104+
1105+
if ( graph_reference ) {
1106+
node.graph_reference = this.findReference(graph_reference);
1107+
}
1108+
}
11001109
this.tree_map.set(node.id, node);
11011110
const newNode = {
11021111
id: node.uri_api,

src/utils/graphModel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ export const rdfTypes = {
137137
"key": "title",
138138
"property": "title",
139139
"label": "Label",
140-
"visible" : false
140+
"visible" : true
141141
},
142142
{
143143
"type": "dc",

0 commit comments

Comments
 (0)