Skip to content

Commit

Permalink
fix: Searching by bib citation fixed. Model repository updated. Model…
Browse files Browse the repository at this point in the history
…sPage refactoring.
  • Loading branch information
Matěj Zábojník committed Nov 7, 2023
1 parent 69875bd commit 2cbd045
Show file tree
Hide file tree
Showing 31 changed files with 540 additions and 310 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"start": "ts-node src/index.ts",
"read": "ts-node src/tmpReadModels.ts"
"seed": "ts-node src/tmpReadModels.ts"
},
"keywords": [],
"author": "",
Expand Down
23 changes: 4 additions & 19 deletions backend/src/tmpReadModels.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
import client from "./repositories/client";
import {seed} from "./seed";

const getAll = async () => {
try {
return await client.model.findMany()
} catch (e) {
console.error('Error fetching validationModels!');
throw e;
} finally {
await client.$disconnect();
}
}

getAll()
.then((models) => {
console.log("All validationModels:", models)
})
.catch((_) => {
console.error("Error!")
});
seed()
.then((_) => console.log('success'))
.catch((_) => console.error('error'))
72 changes: 72 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
"@mui/material": "^5.14.13",
"@tanstack/react-query": "^4.35.7",
"axios": "^1.5.1",
"bibtex-parse": "^2.1.0",
"cytoscape": "^3.26.0",
"latex-to-unicode": "^0.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.16.0",
Expand All @@ -33,6 +35,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"typescript": "^5.0.2",
"unicodeit": "^0.7.5",
"vite": "^4.4.5"
}
}
200 changes: 200 additions & 0 deletions frontend/src/components/FilterBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
import React from "react";
import {FilterBarProps} from "../types/data";
import {Button, IconButton, MenuItem, Select, TextField} from "@mui/material";
import SearchOutlinedIcon from "@mui/icons-material/SearchOutlined";
import SouthOutlinedIcon from "@mui/icons-material/SouthOutlined";
import ClearIcon from "@mui/icons-material/Clear";
import ExpandMoreOutlinedIcon from "@mui/icons-material/ExpandMoreOutlined";

const FilterBar: React.FC<FilterBarProps> = ({
searchNameQuery,
setSearchNameQuery,
searchBibJournalQuery,
setSearchBibJournalQuery,
searchBibYearQuery,
setSearchBibYearQuery,
sortBy,
setSortBy,
filterChanged,
setFilterChanged,
sortOrder,
uniqueKeywords,
countModelsForKeyword,
selectedKeywords,
handleKeywordChange,
toggleSortOrder,
showAdvancedFilters,
toggleAdvancedFilters,
handleResetFilters}) => {
return (
<div className="filter_bar_container">
<div className="filter_bar">
<div className="basic_filter">
<div className="basicFilter_items">
<TextField
label="Search"
variant="outlined"
value={searchNameQuery}
onChange={(e) => {
setSearchNameQuery(e.target.value);
setFilterChanged(true)
}}
InputProps={{
endAdornment: (
<IconButton>
<SearchOutlinedIcon />
</IconButton>
),
}}
sx={{
'@media only screen and (max-width: 767px)': {
marginBottom: '1rem',
}
}}
/>
<div className="sortBy_container">
<span className="sortBy_label"><b>Sort by</b></span>
<div className="sortBy_items">
<Select
className="sortBy_select"
style={{ marginLeft: '.8rem'}}
value={sortBy}
onChange={(e) => {
setSortBy(e.target.value);
setFilterChanged(true)
}}
>
<MenuItem value="name">Name</MenuItem>
<MenuItem value="inputs">Inputs count</MenuItem>
<MenuItem value="variables">Variables count</MenuItem>
<MenuItem value="regulations">Regulations count</MenuItem>
</Select>
<IconButton
onClick={toggleSortOrder}
style={{
transition: 'transform 0.3s ease', // Add a transition for smooth rotation
transform: `rotate(${sortOrder === 'desc' ? '0deg' : '180deg'})`, // Rotate the icon
marginLeft: '.7rem',
outline: 'none'
}}>
<SouthOutlinedIcon />
</IconButton>
</div>
</div>
</div>
<div className="buttons">
<Button
style={{
outline: 'none',
padding: '.2rem 1rem',
margin: '.2rem',
backgroundColor: '#3a568c'
}}
variant="contained"
endIcon={<ClearIcon />}
onClick={handleResetFilters}
disabled={!filterChanged}>
Reset Filters
</Button>
<Button
style={{
outline: 'none',
padding: '.2rem 1rem',
margin: '.2rem',
backgroundColor: '#3a568c'
}}
variant="contained"
endIcon={<ExpandMoreOutlinedIcon
style={{
transition: 'transform 0.3s ease',
transform: `rotate(${!showAdvancedFilters ? '0deg' : '180deg'})` }}
/>}
onClick={toggleAdvancedFilters}>
Advanced Filter
</Button>
</div>
</div>
{showAdvancedFilters && (
<div className="advanced_filter">
<div className="advancedFilter_keywords" style={{width: '-webkit-fill-available'}}>
<p className="keywords_label"><b>Keywords:</b></p>
<div className="keywords"><br/>
{uniqueKeywords.map((keyword) => (
<label key={keyword}>
{countModelsForKeyword(keyword) === 0 ? (
<input
type="checkbox"
value={keyword}
checked={false}
disabled
className="disabled_checkbox"
/>
) : (
<input
type="checkbox"
value={keyword}
checked={selectedKeywords.includes(keyword)}
onChange={() => handleKeywordChange(keyword)}
/>
)}
{keyword} [{countModelsForKeyword(keyword)}]
</label>
))}
</div>
</div>
<div className="advancedFilter_searchBars">
<TextField
sx={{
marginTop: '2rem',
marginLeft: '2rem',
'@media only screen and (max-width: 767px)': {
margin: '1rem 0 0 0'
}
}}
label="Search Publication"
variant="outlined"
value={searchBibJournalQuery}
onChange={(e) => {
setSearchBibJournalQuery(e.target.value);
setFilterChanged(true);
}}
InputProps={{
endAdornment: (
<IconButton>
<SearchOutlinedIcon />
</IconButton>
),
}}
/>
<TextField
sx={{
marginTop: '2rem',
marginLeft: '2rem',
'@media only screen and (max-width: 767px)': {
margin: '1rem 0 0 0'
}
}}
label="Search Year"
variant="outlined"
value={searchBibYearQuery}
onChange={(e) => {
setSearchBibYearQuery(e.target.value);
setFilterChanged(true);
}}
InputProps={{
endAdornment: (
<IconButton>
<SearchOutlinedIcon />
</IconButton>
),
}}
/>
</div>
</div>
)}
</div>
</div>
);
};

export default FilterBar;
Loading

0 comments on commit 2cbd045

Please sign in to comment.