-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
88 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
capella_model_explorer/frontend/src/components/InstanceView.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, {useEffect, useState} from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
|
||
|
||
export const InstanceView = ({endpoint}) => { | ||
let { templateName, objectID } = useParams(); | ||
const [details, setDetails] = useState([]); | ||
|
||
useEffect(() => { | ||
const fetchDetails = async () => { | ||
try { | ||
const url = endpoint + `${templateName}/${objectID}`; | ||
console.log(url); | ||
const response = await fetch(url, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'text/html' | ||
}, | ||
}); | ||
const data = await response.text(); | ||
setDetails(data); | ||
} | ||
catch (error) {} | ||
finally {} | ||
}; | ||
fetchDetails(); | ||
}, [endpoint]); | ||
|
||
return ( | ||
<div dangerouslySetInnerHTML={{__html: details}}> | ||
|
||
</div> | ||
);} |
53 changes: 46 additions & 7 deletions
53
capella_model_explorer/frontend/src/components/TemplateDetails.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,52 @@ | ||
import React from 'react'; | ||
import React, {useEffect, useState} from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export const TemplateDetails = ({template, onClickCallback}) => ( | ||
<div onClick={() => onClickCallback(template.idx)} | ||
className='max-w-sm bg-white rounded-lg border border-gray-200 shadow-md m-4 cursor-pointer hover:bg-gray-100'> | ||
export const TemplateDetails = ({endpoint}) => { | ||
const location = useLocation(); | ||
const template_id = location.state.idx; | ||
const [details, setDetails] = useState([]); | ||
const navigate = useNavigate(); | ||
|
||
useEffect(() => { | ||
const fetchDetails = async () => { | ||
try { | ||
const response = await fetch(endpoint + template_id, { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
}); | ||
const data = await response.json(); | ||
setDetails(data); | ||
} | ||
catch (error) {} | ||
finally {} | ||
}; | ||
fetchDetails(); | ||
}, [endpoint]); | ||
|
||
return ( | ||
<div> | ||
<div className='p-5'> | ||
<h5 className='mb-2 text-2xl font-bold text-gray-900'> | ||
{template.name} | ||
{details.name} | ||
</h5> | ||
<p className='mb-3 font-normal text-gray-700'>{template.description}</p> | ||
<p className='mb-3 font-normal text-gray-700'>{details.description}</p> | ||
</div> | ||
<div className='flex flex-wrap justify-center items-center'> | ||
{details.objects && details.objects.length === 0 && <p>No objects found</p>} | ||
{details.objects && details.objects.length > 0 && details.objects.map(object => ( | ||
<div key={object.idx} | ||
onClick={() => navigate(`/templates/${template_id}/${object.idx}`, {state: {template_id: template_id, object_idx: object.idx}})} | ||
className='max-w-sm bg-white rounded-lg border border-gray-200 shadow-md m-4 cursor-pointer hover:bg-gray-100'> | ||
<div className='p-4'> | ||
<h5 className='text-lg font-bold text-gray-900'> | ||
{object.name} | ||
</h5> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
);} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters