Skip to content

Commit

Permalink
content update for ref in filesview
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricdcc committed May 5, 2022
1 parent 324f173 commit f7c657d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 17 deletions.
31 changes: 18 additions & 13 deletions backend/app/routers/APIV1/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,24 @@ def get_shacl_report(*,space_id: str = Path(None,description="space_id name")):

@router.get('/terms', status_code=200)
def get_terms_shacl(*, space_id: str = Path(None,description="space_id name")):
#TODO from json select which shacl file should be taken
with open(Locations().join_abs_path('spaces.json'), "r+") as file:
data = json.load(file)
try:
space_folder = data[space_id]['storage_path']
except Exception as e:
raise HTTPException(status_code=404, detail="Space not found")
#read in shacl file
path_shacl = os.path.join(Locations().get_workspace_location_by_uuid(space_uuid=space_id),"all_constraints.ttl")
print(path_shacl, file=sys.stderr)
test = shclh.ShapesInfoGraph(path_shacl)
shacldata = test.full_shacl_graph_dict()
return shacldata
try:

#TODO from json select which shacl file should be taken
with open(Locations().join_abs_path('spaces.json'), "r+") as file:
data = json.load(file)
try:
space_folder = data[space_id]['storage_path']
except Exception as e:
raise HTTPException(status_code=404, detail="Space not found")
#read in shacl file
path_shacl = os.path.join(Locations().get_workspace_location_by_uuid(space_uuid=space_id),"all_constraints.ttl")
print(path_shacl, file=sys.stderr)
test = shclh.ShapesInfoGraph(path_shacl)
shacldata = test.full_shacl_graph_dict()
return shacldata
except Exception as e:
log.error(e)
log.exception(e)

@router.post('/', status_code=200)
def make_annotations_for_all_resources(*,space_id: str = Path(None,description="space_id name"), item: AnnotationsModel):
Expand Down
19 changes: 18 additions & 1 deletion backend/app/routers/APIV1/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,24 @@ def get_space_content_info(*,space_id: str = Path(None,description="space_id nam
for (dirpath, dirnames, filenames) in os.walk(space_folder):
for filen in filenames:
if '.git' not in dirpath:
toreturn.append({"file":filen,"folder":dirpath})
toreturn.append({"file":filen,"folder":dirpath,"type":"file"})

#open up the rocrate metadata.json file and loop over all the entries in the @graph and add the ids that are not yet in the toreturn["file"] list
space_object = Space.load(uuid=space_id)
metadata = space_object._read_metadata_datacrate()
log.info(metadata)
for entry in metadata['@graph']:
found = 0
for item in toreturn:
if item["file"] == entry["@id"]:
found = 1
if found == 0:
if "@type" in entry:
if entry["@type"] == "File":
toreturn.append({"file":entry["@id"],"folder":"/", "type":"reference"})



return toreturn

@router.get('/file/{file_id}')
Expand Down
3 changes: 3 additions & 0 deletions frontend/frontend_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/sh
export NODE_OPTIONS=--openssl-legacy-provider
npm run build
20 changes: 17 additions & 3 deletions frontend/src/components/files_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ function FilesView(props) {
}
}

//child component to see if a component should have a open in external window button or not
const OpenInExternal = (props) => {
var file = props.file;
console.log(file);
if(file.type == 'file'){
return(
<OverlayTrigger trigger={['hover', 'focus']} placement="right" overlay={popoveropenexternal}>
<button onClick={() => openFileExternal(file.file)}><MdOpenInBrowser></MdOpenInBrowser></button>
</OverlayTrigger>
)
}else{
return(<></>)
}
}


useEffect(() => {
fetchSpaceName();
},[]);
Expand Down Expand Up @@ -152,9 +168,7 @@ function FilesView(props) {
<tr>
<td><Checkbox value={file.file} onChange={(e) => setfileinarray(file.file,e.target.checked)}/></td>
<td variant="info">
<OverlayTrigger trigger={['hover', 'focus']} placement="right" overlay={popoveropenexternal}>
<button onClick={() => openFileExternal(file.file)}><MdOpenInBrowser></MdOpenInBrowser></button>
</OverlayTrigger>
<OpenInExternal file={file}></OpenInExternal>
</td>
<td className="filetd">
<a href={ '/spaces/'+SpaceId+'/all_files/'+ file.file}>{file.file} </a>
Expand Down

0 comments on commit f7c657d

Please sign in to comment.