diff --git a/src/App.js b/src/App.js index 25548d7..f5ed2a3 100644 --- a/src/App.js +++ b/src/App.js @@ -146,7 +146,7 @@ const App = () => { if ( version !== undefined && localStorage.getItem(config.datasetsStorage)?.version !== version[0] ) { let parsedDatasets = [] datasets.forEach( node => { - parsedDatasets.push({name : node.name , doi : node.attributes?.hasDoi?.[0]}); + parsedDatasets.push({ name : node.name , doi : node.attributes?.hasDoi?.[0], label : node.attributes ? node.attributes?.label?.[0]?.toLowerCase() : null}); }); datasetStorage = { version : version[0], diff --git a/src/components/DatasetsListViewer/DatasetsListDialog.js b/src/components/DatasetsListViewer/DatasetsListDialog.js index b63ef04..d27bd07 100644 --- a/src/components/DatasetsListViewer/DatasetsListDialog.js +++ b/src/components/DatasetsListViewer/DatasetsListDialog.js @@ -106,8 +106,24 @@ const DatasetsListDialog = (props) => { let datasets = graph.nodes.filter((node) => node?.attributes?.hasUriApi); datasets.forEach( node => node.attributes ? node.attributes.lowerCaseLabel = node.attributes?.label?.[0]?.toLowerCase() : null ); datasets = datasets.filter( node => node?.attributes?.statusOnPlatform?.[0]?.includes(PUBLISHED) ); - dispatch(setDatasetsList(datasets)); - setFilteredDatasets(datasets); + + + let version = graph.nodes.find( node => node?.attributes?.versionInfo)?.attributes?.versionInfo + let datasetStorage = {}; + if ( version !== undefined && localStorage.getItem(config.datasetsStorage)?.version !== version[0] ) { + let parsedDatasets = [] + datasets.forEach( node => { + parsedDatasets.push({ name : node.name , doi : node.attributes?.hasDoi?.[0], label : node.attributes ? node.attributes.lowerCaseLabel : null}); + }); + datasetStorage = { + version : version[0], + datasets : parsedDatasets + } + + localStorage.setItem(config.datasetsStorage, JSON.stringify(datasetStorage)); + dispatch(setDatasetsList(datasetStorage.datasets)); + setFilteredDatasets(datasetStorage.datasets); + } }; const summaryURL = config.repository_url + config.available_datasets; fileHandler.get_remote_file(summaryURL, callback); @@ -139,7 +155,15 @@ const DatasetsListDialog = (props) => { } useEffect(() => { - open && datasets.length === 0 && loadDatasets(); + if ( open && datasets.length === 0 ) { + if ( localStorage.getItem(config.datasetsStorage) ) { + let storedDatasetsInfo = JSON.parse(localStorage.getItem(config.datasetsStorage)); + dispatch(setDatasetsList(storedDatasetsInfo.datasets)); + setFilteredDatasets(storedDatasetsInfo.datasets); + } else { + loadDatasets(); + } + } }); return ( @@ -202,7 +226,7 @@ const DatasetsListDialog = (props) => { className="dataset_list_text" dangerouslySetInnerHTML={{ __html: - getFormattedListTex(dataset.attributes?.label[0]) + getFormattedListTex(dataset.label) }} /> } diff --git a/src/utils/GraphViewerHelper.js b/src/utils/GraphViewerHelper.js index f7109d6..4b1913b 100644 --- a/src/utils/GraphViewerHelper.js +++ b/src/utils/GraphViewerHelper.js @@ -437,7 +437,7 @@ export const getPrunedTree = (graph_id, layout) => { */ const updateConflictedNodes = (nodes, conflictNode, positionsMap, level, index, layout) => { let matchIndex = index; - for ( let i = 0; i < index ; i++ ) { + for ( let i = 0; i <= index ; i++ ) { let conflict = nodes.find ( n => !n.collapsed && n?.parent?.id === nodes[i]?.parent?.id) if ( conflict === undefined ){ conflict = nodes.find ( n => !n.collapsed ) diff --git a/src/utils/graphModel.js b/src/utils/graphModel.js index b25d42e..ad81d7b 100644 --- a/src/utils/graphModel.js +++ b/src/utils/graphModel.js @@ -22,6 +22,12 @@ export const rdfTypes = { "key": "hasUriHuman", "property": "hasUriHuman", "label": "To be filled" + }, + { + "type" : "owl", + "key" : "versionInfo", + "property" : "versionInfo", + "label" : "Version" } ] }, @@ -122,7 +128,8 @@ export const rdfTypes = { "label": "Title", "visible" : true, "link" : { - "property" : "hasUriPublished" + "property" : "hasUriPublished", + "asText" : true } }, { @@ -202,7 +209,8 @@ export const rdfTypes = { "label": "DOI", "visible" : true, "link" : { - "property" : "hasUriPublished" + "property" : "hasUriPublished", + "asText" : true } }, {