Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DUOS-2688] Add loading indicator and details when no items #2345

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/components/data_search/DatasetSearchTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,23 @@ export const DatasetSearchTable = (props) => {
<DatasetFilterList datasets={datasets} filters={filters} filterHandler={filterHandler} />
</Box>
<Box sx={{ width: '85%', padding: '0 1em' }}>
<CollapsibleTable data={tableData} selected={selected} selectHandler={selectHandler} summary='faceted study search table' />
{
isEmpty(datasets) ?
<Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', height: '100%' }}>
<h1>No datasets registered for this library.</h1>
</Box>
:
<CollapsibleTable data={tableData} selected={selected} selectHandler={selectHandler} summary='faceted study search table' />
}
</Box>
</Box>
<Box sx={{ display: 'flex', flexDirection: 'row', justifyContent: 'flex-end', padding: '2em 4em' }}>
<Button variant="contained" onClick={applyForAccess} sx={{ transform: 'scale(1.5)' }} >
{
!isEmpty(datasets) &&
<Button variant="contained" onClick={applyForAccess} sx={{ transform: 'scale(1.5)' }} >
Apply for Access
</Button>
</Button>
}
</Box>
</Box>
);
Expand Down
11 changes: 10 additions & 1 deletion src/pages/DatasetSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import duosIcon from '../images/duos-network-logo.svg';
import mgbIcon from '../images/mass-general-brigham-logo.svg';
import elwaziIcon from '../images/elwazi-logo-color.svg';
import { Storage } from '../libs/storage';
import { isEmpty, isNil } from 'lodash';
import { Box, CircularProgress } from '@mui/material';

const signingOfficialQuery = (user) => {
return {
Expand Down Expand Up @@ -51,6 +53,7 @@ const myInstitutionQuery = (user) => {
export const DatasetSearch = (props) => {
const { location } = props;
const [datasets, setDatasets] = useState([]);
const [loading, setLoading] = useState(true);
const user = Storage.getCurrentUser();

// branded study table versions
Expand Down Expand Up @@ -143,6 +146,7 @@ export const DatasetSearch = (props) => {
try {
await DataSet.searchDatasetIndex(query).then((datasets) => {
setDatasets(datasets);
setLoading(false);
});
} catch (error) {
Notifications.showError({ text: 'Failed to load Elasticsearch index' });
Expand All @@ -152,7 +156,12 @@ export const DatasetSearch = (props) => {
}, []);

return (
<DatasetSearchTable {...props} datasets={datasets} icon={version.icon} title={version.title} />
loading ?
<Box sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '50vh' }}>
<CircularProgress />
</Box>
:
<DatasetSearchTable {...props} datasets={datasets} icon={version.icon} title={version.title} />
);
};

Expand Down