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

feat(taxonomy-editor-frontend): loading animation #283

Merged
merged 7 commits into from
Nov 23, 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Alert, Box, Snackbar, Typography, Button } from "@mui/material";
import SaveIcon from "@mui/icons-material/Save";
import CircularProgress from "@mui/material/CircularProgress";
import { useEffect, useState } from "react";
import useFetch from "../../components/useFetch";
import ListEntryParents from "./ListEntryParents";
Expand Down Expand Up @@ -76,11 +77,18 @@ const AccumulateAllComponents = ({ id, taxonomyName, branchName }) => {
}

// Loading...
if (isPending) {
if (isPending && !node) {
return (
<Typography sx={{ ml: 4 }} variant="h5">
Loading..
</Typography>
<Box
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "100vh",
}}
>
<CircularProgress sx={{ textAlign: "center" }} />
</Box>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import DialogContentText from "@mui/material/DialogContentText";
import DialogTitle from "@mui/material/DialogTitle";
import AddBoxIcon from "@mui/icons-material/AddBox";
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
import CircularProgress from "@mui/material/CircularProgress";
import ISO6391 from "iso-639-1";
import { ENTER_KEYCODE } from "../../constants";
import { greyHexCode } from "../../constants";
Expand Down Expand Up @@ -85,11 +86,11 @@ const ListEntryChildren = ({ url, urlPrefix, setUpdateNodeChildren }) => {
</Typography>
);
}
if (isPending) {
if (isPending && !incomingData) {
return (
<Typography sx={{ ml: 4 }} variant="h5">
Loading..
</Typography>
<Box sx={{ textAlign: "left", m: 5 }}>
<CircularProgress />
</Box>
);
}
return (
Expand All @@ -98,6 +99,11 @@ const ListEntryChildren = ({ url, urlPrefix, setUpdateNodeChildren }) => {
<Typography sx={{ ml: 4 }} variant="h5">
Children
</Typography>
{!incomingData && (
<Box sx={{ textAlign: "left", m: 3 }}>
<CircularProgress size={20} />
</Box>
)}
<IconButton
sx={{ ml: 1, color: greyHexCode }}
onClick={handleOpenDialog}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Link } from "react-router-dom";

import { Box, Typography } from "@mui/material";
import CircularProgress from "@mui/material/CircularProgress";

import useFetch from "../../components/useFetch";
import type { ParentsAPIResponse } from "../../backend-types/types";
Expand All @@ -24,21 +25,29 @@ const ListEntryParents = ({ fetchUrl, linkHrefPrefix }: Props) => {
);
}

if (isPending) {
if (isPending && !data) {
return (
<Typography sx={{ ml: 4 }} variant="h5">
Loading...
</Typography>
<Box
sx={{
textAlign: "center",
my: 5,
}}
>
<CircularProgress />
</Box>
);
}

return (
<Box>
{
<Typography sx={{ ml: 4, mb: 1 }} variant="h5">
Parents
</Typography>
}
<Typography sx={{ ml: 4, mb: 1 }} variant="h5">
Parents
</Typography>
{!data && (
<Box sx={{ textAlign: "left", m: 3 }}>
<CircularProgress size={20} />
</Box>
)}

{relations.length === 0 ? (
<Typography sx={{ ml: 8, mb: 1 }} variant="h6">
Expand Down
12 changes: 10 additions & 2 deletions taxonomy-editor-frontend/src/pages/errors/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
TableContainer,
} from "@mui/material";
import MaterialTable from "@material-table/core";
import CircularProgress from "@mui/material/CircularProgress";
import { useState, useEffect } from "react";

const Errors = ({ addNavLinks }) => {
Expand Down Expand Up @@ -51,8 +52,15 @@ const Errors = ({ addNavLinks }) => {
}
if (isPending) {
return (
<Box>
<Typography variant="h5">Loading...</Typography>
<Box
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "100vh",
}}
>
<CircularProgress sx={{ textAlign: "center" }} />
</Box>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useNavigate } from "react-router-dom";
import { Typography, Box, Grid, Link as MuiLink } from "@mui/material";
import MaterialTable from "@material-table/core";
import EditIcon from "@mui/icons-material/Edit";
import CircularProgress from "@mui/material/CircularProgress";

import useFetch from "../../components/useFetch";
import { API_URL } from "../../constants";
Expand Down Expand Up @@ -70,7 +71,11 @@ const GoToProject = ({ clearNavBarLinks }: Props) => {
}

if (isPending) {
return <Typography variant="h5">Loading..</Typography>;
return (
<Box sx={{ textAlign: "center", my: 10 }}>
<CircularProgress />
</Box>
);
}

return (
Expand Down
10 changes: 8 additions & 2 deletions taxonomy-editor-frontend/src/pages/root-nodes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import TableRow from "@mui/material/TableRow";
import EditIcon from "@mui/icons-material/Edit";
import AddBoxIcon from "@mui/icons-material/AddBox";
import Dialog from "@mui/material/Dialog";
import CircularProgress from "@mui/material/CircularProgress";

import CreateNodeDialogContent from "../../components/CreateNodeDialogContent";
import useFetch from "../../components/useFetch";
Expand Down Expand Up @@ -80,8 +81,13 @@ const RootNodes = ({

if (isPending || !nodes) {
return (
<Box>
<Typography variant="h5">Loading...</Typography>
<Box
sx={{
textAlign: "center",
my: 10,
}}
>
<CircularProgress />
</Box>
);
}
Expand Down
16 changes: 13 additions & 3 deletions taxonomy-editor-frontend/src/pages/search/SearchResults.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import CircularProgress from "@mui/material/CircularProgress";
import { useState } from "react";
import { Link } from "react-router-dom";

Expand Down Expand Up @@ -80,10 +81,19 @@ const SearchResults = ({ query, taxonomyName, branchName }: Props) => {
direction="column"
alignItems="center"
justifyContent="center"
height="100%"
>
<Typography sx={{ mt: 2 }} variant="h5">
Loading..
</Typography>
<Box
sx={{
flex: 1,
display: "flex",
justifyContent: "center",
alignItems: "center",
marginTop: "1em",
}}
>
<CircularProgress sx={{ textAlign: "center" }} />
</Box>
</Grid>
);
}
Expand Down
13 changes: 6 additions & 7 deletions taxonomy-editor-frontend/src/pages/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,15 @@ const SearchNode = ({
<Box>
<Grid
container
direction="column"
display="flex"
flexDirection="column"
alignItems="center"
justifyContent="center"
justifyContent="flex-start"
gap="20px"
>
<Typography sx={{ mt: 4 }} variant="h3">
Search
</Typography>
<Typography variant="h3">Search</Typography>
<Box
component="img"
sx={{ mt: 2 }}
width={100}
height={100}
src={require("../../assets/classification.png")}
Expand All @@ -67,7 +66,7 @@ const SearchNode = ({
}}
>
<TextField
sx={{ mt: 3, width: 350 }}
sx={{ width: 350 }}
InputProps={{
endAdornment: (
<InputAdornment position="end">
Expand Down