Skip to content

Commit

Permalink
#SDSV-18 - Work in progress showing metadata for folders and files no…
Browse files Browse the repository at this point in the history
…t on graph viewer
  • Loading branch information
jrmartin committed Mar 12, 2024
1 parent 8c8ac32 commit 7aac4c1
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 39 deletions.
4 changes: 2 additions & 2 deletions src/components/NodeDetailView/Details/CollectionDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ const CollectionDetails = (props) => {

const collectionPropertiesModel = useSelector(state => state.sdsState.metadata_model.collection);
return (
<Box id={node?.graph_node?.attributes.localId + detailsLabel}>
<Box id={node?.graph_node?.attributes?.localId + detailsLabel}>
<Divider />
<Box className="tab-content">
<SimpleLabelValue label={""} value={""} heading={"Folder Details"} />

{collectionPropertiesModel?.map( property => {
if ( property.visible ){
const propValue = node.graph_node.attributes[property.property];
const propValue = node?.tree_node?.[property.property] || node?.graph_node?.attributes?.[property.property];
if ( isValidUrl(propValue) ){
return (<Box className="tab-content-row">
<Typography component="label">{property.label}</Typography>
Expand Down
2 changes: 1 addition & 1 deletion src/components/NodeDetailView/Details/FileDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const FileDetails = (props) => {

{filePropertiesModel?.map( property => {
if ( property.visible ){
const propValue = node.graph_node.attributes[property.property];
const propValue = node?.tree_node?.[property.property] || node?.graph_node?.attributes?.[property.property];
if ( isValidUrl(propValue) ){
return (<Box className="tab-content-row">
<Typography component="label">{property.label}</Typography>
Expand Down
1 change: 1 addition & 0 deletions src/components/NodeDetailView/Details/PersonDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Typography,
} from "@material-ui/core";
import Links from './Views/Links';
import { detailsLabel } from '../../../constants';

const PersonDetails = (props) => {
const { node } = props;
Expand Down
8 changes: 7 additions & 1 deletion src/components/NodeDetailView/Details/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,11 @@ export const simpleValue = (label, value) => {
}

export const isValidUrl = (urlString) => {
return /(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)?[a-zA-Z]{2,}(\.[a-zA-Z]{2,})(\.[a-zA-Z]{2,})?\/[a-zA-Z0-9]{2,}|((https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)?[a-zA-Z]{2,}(\.[a-zA-Z]{2,})(\.[a-zA-Z]{2,})?)|(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)?[a-zA-Z0-9]{2,}\.[a-zA-Z0-9]{2,}\.[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})?/g.test(urlString);
var urlPattern = new RegExp('^(https?:\\/\\/)?'+ // validate protocol
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // validate domain name
'((\\d{1,3}\\.){3}\\d{1,3}))'+ // validate OR ip (v4) address
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // validate port and path
'(\\?[;&a-z\\d%_.~+=-]*)?'+ // validate query string
'(\\#[-a-z\\d_]*)?$','i'); // validate fragment locator
return ( typeof urlString === "string" && urlString?.startsWith("http"));
}
22 changes: 12 additions & 10 deletions src/components/NodeDetailView/NodeDetailView.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ const NodeDetailView = (props) => {
};
var path = []
var latestNodeVisited = nodeSelected;
while ( latestNodeVisited.graph_node.parent !== undefined ) {
path.push(latestNodeVisited.graph_node.parent.id);
while ( latestNodeVisited?.graph_node?.parent !== undefined ) {
path.push(latestNodeVisited?.graph_node?.parent?.id);
latestNodeVisited = {
tree_node: undefined,
graph_node: latestNodeVisited.graph_node.parent
graph_node: latestNodeVisited?.graph_node?.parent
};
};

Expand All @@ -40,9 +40,9 @@ const NodeDetailView = (props) => {
graph_node: graph_node,
tree_node: graph_node.tree_reference
}
if (new_node.graph_node.id !== subject_key
&& new_node.graph_node.id !== contributors_key
&& new_node.graph_node.id !== protocols_key) {
if (new_node?.graph_node?.id !== subject_key
&& new_node?.graph_node?.id !== contributors_key
&& new_node?.graph_node?.id !== protocols_key) {
links.pages.push({
id: singleNode,
title: graph_node.name,
Expand All @@ -52,10 +52,12 @@ const NodeDetailView = (props) => {
}
return <> </>;
});
links.current = {
id: nodeSelected.graph_node.id,
text: nodeSelected.graph_node.name
};
if ( nodeSelected?.graph_node ){
links.current = {
id: nodeSelected?.graph_node?.id,
text: nodeSelected?.graph_node?.name
};
}
const toggleContent = () => {
dispatch(toggleSettingsPanelVisibility(!showSettingsContent));
};
Expand Down
8 changes: 8 additions & 0 deletions src/utils/Splinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -989,13 +989,21 @@ class Splinter {
let tree_node = this.tree_map.get(id);
if (tree_node) {
value.tree_reference = tree_node;
tree_node.publishedURI =
Array.from(this.nodes)[0][1].attributes.hasUriPublished[0]?.replace("datasets", "file") +
"/1?path=files/" +
tree_node?.dataset_relative_path;
this.nodes.set(key, value);
tree_node.graph_reference = value;
this.tree_map.set(value.id, tree_node);
} else {
value.proxies.every(proxy => {
tree_node = this.tree_map.get(proxy);
if (tree_node) {
tree_node.publishedURI =
Array.from(this.nodes)[0][1].attributes.hasUriPublished[0]?.replace("datasets", "file") +
"/1?path=files/" +
tree_node?.dataset_relative_path;
value.tree_reference = tree_node;
this.nodes.set(key, value);
tree_node.graph_reference = value;
Expand Down
71 changes: 46 additions & 25 deletions src/utils/graphModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,17 @@ export const rdfTypes = {
"properties": [
{
"type": "rdfs",
"key": "label",
"property": "label",
"label": "Label",
"visible" : false
},
{
"type": "rdfs",
"key": "identifier",
"property": "identifier",
"label": "Label",
"key": "basename",
"property": "basename",
"label": "Basename",
"visible" : true
},
{
"type": "rdfs",
"key": "mimetype",
"property": "mimetype",
"label": "Mimetype",
"visible" : false
"visible" : true
},
{
"type": "rdfs",
Expand All @@ -77,18 +70,25 @@ export const rdfTypes = {
},
{
"type": "rdfs",
"key": "updated",
"property": "updated",
"key": "timestamp_updated",
"property": "timestamp_updated",
"label": "Updated On",
"visible" : true
},
{
"type": "TEMP",
"key": "hasUriHuman",
"property": "hasUriHuman",
"key": "uri_human",
"property": "uri_human",
"label": "URI Link",
"visible" : false
},
{
"type": "TEMP",
"key": "uri_api",
"property": "uri_api",
"label": "URI API",
"visible" : true
},
{
"type": "TEMP",
"key": "publishedURI",
Expand Down Expand Up @@ -396,9 +396,16 @@ export const rdfTypes = {
"properties": [
{
"type": "rdfs",
"key": "identifier",
"property": "identifier",
"label": "Label",
"key": "basename",
"property": "basename",
"label": "Basename",
"visible" : true
},
{
"type": "rdfs",
"key": "timestamp_updated",
"property": "timestamp_updated",
"label": "Updated On",
"visible" : true
},
{
Expand All @@ -417,18 +424,32 @@ export const rdfTypes = {
},
{
"type": "TEMP",
"key": "updated",
"property": "updated",
"label": "Updated On",
"key": "publishedURI",
"property": "publishedURI",
"label": "Published URI",
"visible" : true
},
{
"type": "TEMP",
"key": "publishedURI",
"property": "publishedURI",
"label": "Published URI",
"key": "uri_human",
"property": "uri_human",
"label": "URI Link",
"visible" : false
},
{
"type": "TEMP",
"key": "uri_api",
"property": "uri_api",
"label": "URI API",
"visible" : true
}
},
{
"type": "TEMP",
"key": "status",
"property": "status",
"label": "Status",
"visible" : true
},
]
},
"Subject": {
Expand Down
6 changes: 6 additions & 0 deletions src/utils/nodesFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ const Protocol = function (node, ttlTypes) {
const Sample = function (node, ttlTypes) {
node.img = createImage(node);
extractProperties(node, ttlTypes);
if (node.attributes?.identifier !== undefined) {
node.name = node.attributes?.identifier[0];
} else {
let namesArray = node.name.split("/");
node.name = namesArray[namesArray.length - 1];
}
return node;
};

Expand Down

0 comments on commit 7aac4c1

Please sign in to comment.