SciCatProject / frontend

SciCat open data catalogue web client
https://scicatproject.github.io
BSD 3-Clause "New" or "Revised" License
24 stars 29 forks source link

nested json not rendering as tree for scientific metadata #1263

Open mkywall opened 1 year ago

mkywall commented 1 year ago

Issue Name

nested json not rendering as tree for scientific metadata

Summary

When uploading datasets with nested json in the scientific metadata field, the front end seems to render the data so that the left most column only contains the highest level nodes and the value column shows all of the other information as a single nested dictionary. It could be nice if it is possible to have the data rendered so that it is possible to expand each sublevel of nodes for the nested data.

Steps to Reproduce

Try to create a dataset with nested json as the scientific metadata.

Current Behaviour

A row is created for each node in the highest level of the json tree. The values of those nodes appear in the left most column, all objects nested under that node appear as a single string of text in the second column, an empty column for units is on the right.

Expected Behaviour

A row would be created for each object in the json tree. Rows for higher level nodes could be expanded to show the rows containing the subtrees nested below. The left hand column would contain the key/name for each object and the middle column would contain the value.

Extra Details

image

bpedersen2 commented 1 year ago

I like the idea, but it probably needs some BE support as well, as we already have object-type values for storing value/unit pairs (including SI conversions). So value is {"value":" <thevalue>, "unit":<theunit>,"SIvalue":<value as SI>,"SIunit": <si unit>}. String values are coming as {"value": <thevalue>, "unit":''} (I think currently we still allow also pure strings, but that may change, see

One solution would be to allow a unit of json (or object, nested...) to allow the FE to render these more structured data. Of course we should care about how to handle very deep trees then.

See #983 and SciCatProject/scicat-backend-next#138

fpotier commented 10 months ago

@mkywall You can toggle the tree view for metadata in the backend with metadataStructure: "tree" in frontend.config.json image

@bpedersen2 it also supports the value/unit, for instance

{
  "energy": {
    "unit": "keV",
    "value": 12.6999,
   "valueSI": 2.03474821578435e-15,
   "unitSI": "(kg m^2) / s^2"
  }
}

is rendered as : image