-
Notifications
You must be signed in to change notification settings - Fork 33
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
1 parent
fadf288
commit 1cbad01
Showing
12 changed files
with
739 additions
and
2 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
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
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,105 @@ | ||
#explorer-content { | ||
font-family: Vollkorn, Ubuntu, Optima, Segoe, Segoe UI, Candara, Calibri, Arial, sans-serif; | ||
margin: 40px; | ||
text-align: left; | ||
} | ||
|
||
#explorer-content>.group { | ||
border-top: 1px dotted lightgrey; | ||
border-left: 6px solid lightgrey; | ||
margin: 4px; | ||
margin-left: 46px; | ||
padding: 5px; | ||
vertical-align: top; | ||
background-color: rgba(200, 200, 200, 0.2); | ||
} | ||
|
||
#explorer-content>.doc-id { | ||
display: inline-block; | ||
border-radius: 6px; | ||
margin: 3px; | ||
padding: 3px; | ||
background-color: #f8f8f8; | ||
vertical-align: top; | ||
font-size: 90%; | ||
} | ||
|
||
#explorer-content>.tag { | ||
display: inline-block; | ||
border: 1px solid lightgrey; | ||
border-radius: 6px; | ||
margin: 3px; | ||
padding: 3px; | ||
background-color: #f8f8f8; | ||
vertical-align: top; | ||
font-size: 90%; | ||
max-width: 80px; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
} | ||
|
||
#explorer-content>a { | ||
text-decoration: none; | ||
} | ||
|
||
#explorer-content>.icon { | ||
width: 140px; | ||
height: 140px; | ||
object-fit: cover; | ||
border-radius: 4px; | ||
margin-top: 26px; | ||
margin-bottom: 20px; | ||
filter: grayscale(100%); | ||
} | ||
|
||
#explorer-content>::placeholder { | ||
color: lightgrey; | ||
opacity: 1; | ||
} | ||
|
||
#explorer-content>:-ms-input-placeholder { | ||
color: lightgrey; | ||
} | ||
|
||
#explorer-content>::-ms-input-placeholder { | ||
color: lightgrey; | ||
} | ||
|
||
|
||
#explorer-content>div { | ||
vertical-align: top; | ||
} | ||
|
||
#explorer-content>content { | ||
margin-left: -20px; | ||
} | ||
|
||
#explorer-content>h1 { | ||
font-size: 50px; | ||
margin-bottom: 5px; | ||
margin-left: 16px; | ||
} | ||
|
||
#explorer-content>img { | ||
vertical-align: middle; | ||
height: 80px; | ||
} | ||
|
||
b { | ||
padding-top: 20px; | ||
padding-left: 12px; | ||
} | ||
p{ | ||
color: grey; margin-left: 26px; | ||
} | ||
#explorer-wrapper{ | ||
margin-left: 24px; margin-top: 20px; margin-bottom: 20px; color: grey; | ||
} | ||
|
||
#filter{ | ||
font-size: 16px; height: 32px; width: 320px; margin-bottom: 10px; | ||
} | ||
#search-summary{ | ||
display: inline-block; vertical-align: middle; | ||
} | ||
#graphs{font-size: 80%; color: grey;} |
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,148 @@ | ||
import './explorer.scss'; | ||
|
||
import React, { useContext, useEffect, useMemo, useState } from 'react'; | ||
import { useQuery } from 'react-query'; | ||
import { useParams } from 'react-router-dom'; | ||
|
||
import { DocumentNode } from '../../components/DocumentNode'; | ||
import { ClearFilterButton, FilterButton } from '../../components/FilterButton/FilterButton'; | ||
import { LoadingAndErrorIndicator } from '../../components/LoadingAndErrorIndicator'; | ||
import { useEnvironment } from '../../hooks'; | ||
import { applyFilters, filterContext } from '../../hooks/applyFilters'; | ||
import { Document } from '../../types'; | ||
import { groupLinksByType } from '../../utils'; | ||
import { SearchResults } from '../Search/components/SearchResults'; | ||
|
||
export const Explorer = () => { | ||
const { apiUrl } = useEnvironment(); | ||
const [loading, setLoading] = useState<boolean>(false); | ||
const [filter, setFilter] = useState(""); | ||
const [searchSummary, setSearchSummary] = useState(0); | ||
const [data, setData] = useState<Document[]>() | ||
const [rootCREs, setRootCREs] = useState<Document[]>() | ||
const [filteredData, setFilteredData] = useState<Document[]>() | ||
|
||
useQuery<{ data: Document }, string>( | ||
'root_cres', | ||
() => | ||
fetch(`${apiUrl}/root_cres`) | ||
.then((res) => res.json()) | ||
.then((resjson) => { | ||
setRootCREs(resjson.data); | ||
return resjson; | ||
}), | ||
{ | ||
retry: false, | ||
enabled: false, | ||
onSettled: () => { | ||
setLoading(false); | ||
}, | ||
} | ||
); | ||
const docs = localStorage.getItem("documents") | ||
useEffect(()=>{ | ||
if (docs != null) { | ||
setData(JSON.parse(docs).sort((a, b) => (a.id + '').localeCompare(b.id + ''))); | ||
setFilteredData(data) | ||
} | ||
},[docs]) | ||
|
||
const query = useQuery( | ||
'everything', | ||
() => { | ||
if (docs == null) { | ||
fetch(`${apiUrl}/everything`) | ||
.then((res) => { return res.json() }) | ||
.then((resjson) => { | ||
return resjson.data | ||
}).then((data) => { | ||
if (data) { | ||
localStorage.setItem("documents", JSON.stringify(data)); | ||
setData(data) | ||
} | ||
}), | ||
{ | ||
retry: false, | ||
enabled: false, | ||
onSettled: () => { | ||
setLoading(false); | ||
}, | ||
} | ||
} | ||
|
||
} | ||
); | ||
|
||
|
||
useEffect(() => { | ||
window.scrollTo(0, 0); | ||
setLoading(true); | ||
query.refetch(); | ||
}, []); | ||
|
||
|
||
if (!data?.length) { | ||
const docs = localStorage.getItem("documents") | ||
if (docs) { | ||
setData(JSON.parse(docs).sort((a, b) => (a.id + '').localeCompare(b.id + ''))); | ||
setFilteredData(data) | ||
} | ||
} | ||
|
||
function processNode(item) { | ||
if (!item) { | ||
return (<></>) | ||
} | ||
return ( | ||
<div className="group" > | ||
<div className="group-1"> | ||
<div className='group-2'> | ||
<a target="_blank" href={"https://opencre.org/cre/" + item?.id}> | ||
{item?.name} | ||
</a> | ||
</div> | ||
<div /*style="font-size: 90%"*/> | ||
{item?.links?.forEach(child => processNode(child))} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
function update(event) { | ||
setFilter(event.target.value) | ||
setFilteredData(data?.filter(item => item.name.toLowerCase().includes(filter))) | ||
} | ||
|
||
return (<> | ||
{/* <LoadingAndErrorIndicator loading={loading} error={query.error} /> */} | ||
<div id="explorer-content"> | ||
<h1> | ||
<img src="assets/logo.png" /> | ||
<b>Open CRE Explorer</b> | ||
</h1> | ||
<p>A visual explorer of Open Common Requirement Enumerations (CREs). | ||
Data source: <a target="_blank" href="https://opencre.org/">opencre.org</a>.</p> | ||
|
||
<div id="explorer-wrapper"> | ||
<div> | ||
<input id="filter" type="text" placeholder="search..." | ||
onKeyUp={update} /> | ||
<div id="search-summary"></div> | ||
</div> | ||
<div id="graphs">graphs (3D): | ||
<a target="_blank" href="visuals/force-graph-3d-all.html">CRE dependencies</a> - | ||
<a target="_blank" href="visuals/force-graph-3d-contains.html">hierarchy only</a> - | ||
<a target="_blank" href="visuals/force-graph-3d-related.html">related only</a> | | ||
<a target="_blank" href="visuals/force-graph-3d-linked.html">links to external standards</a> | | ||
<a target="_blank" href="visuals/circles.html">zoomable circles</a> | ||
</div> | ||
</div> | ||
<div id="content"></div> | ||
{filteredData?.map(item => { | ||
return processNode(item) | ||
})} | ||
</div> | ||
|
||
</> | ||
); | ||
}; |
188 changes: 188 additions & 0 deletions
188
application/frontend/src/pages/Explorer/visuals/circles.html
Large diffs are not rendered by default.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
application/frontend/src/pages/Explorer/visuals/force-graph-3d-all.html
Large diffs are not rendered by default.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
application/frontend/src/pages/Explorer/visuals/force-graph-3d-contains.html
Large diffs are not rendered by default.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
application/frontend/src/pages/Explorer/visuals/force-graph-3d-linked.html
Large diffs are not rendered by default.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
application/frontend/src/pages/Explorer/visuals/force-graph-3d-related.html
Large diffs are not rendered by default.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
application/frontend/src/pages/Explorer/visuals/force-graph-3d.html
Large diffs are not rendered by default.
Oops, something went wrong.
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
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