Skip to content

Commit

Permalink
feat(ui): Loading animation cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypfer committed May 28, 2024
1 parent 31519e1 commit d8714dd
Show file tree
Hide file tree
Showing 21 changed files with 1,752 additions and 1,660 deletions.
23 changes: 4 additions & 19 deletions frontend/src/CapabilitiesProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import {Backdrop, Button, styled, Typography,} from "@mui/material";
import {Button} from "@mui/material";
import {SnackbarKey, useSnackbar} from "notistack";
import React from "react";
import {Capability, useCapabilitiesQuery} from "./api";
import ValetudoSplash from "./components/ValetudoSplash";

const StyledBackdrop = styled(Backdrop)(({theme}) => {
return {
zIndex: theme.zIndex.drawer + 1,
color: "#fff",
display: "flex",
flexFlow: "column",
};
});

const Context = React.createContext<Capability[]>([]);

const CapabilitiesProvider = (props: {
Expand Down Expand Up @@ -71,16 +62,10 @@ const CapabilitiesProvider = (props: {

return (
<Context.Provider value={capabilities ?? []}>
<StyledBackdrop
open={capabilitiesPending}
style={{
transitionDelay: capabilitiesPending ? "800ms" : "0ms",
}}
unmountOnExit
>
{
capabilitiesPending &&
<ValetudoSplash/>
<Typography variant="caption">Loading capabilities...</Typography>
</StyledBackdrop>
}
{
capabilities &&
children
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/ProvisioningPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
ListItemIcon,
ListItemText,
Paper,
Skeleton,
TextField,
Typography
} from "@mui/material";
Expand All @@ -40,7 +41,6 @@ import {
useWifiConfigurationMutation,
useWifiScanQuery,
} from "./api";
import LoadingFade from "./components/LoadingFade";
import {LoadingButton} from "@mui/lab";
import {useCapabilitiesSupported} from "./CapabilitiesProvider";

Expand Down Expand Up @@ -219,7 +219,7 @@ const ProvisioningPage = (): React.ReactElement => {
const robotInformationElement = React.useMemo(() => {
if (robotInformationPending || versionPending) {
return (
<LoadingFade/>
<Skeleton height={"6rem"}/>
);
}

Expand Down
14 changes: 11 additions & 3 deletions frontend/src/components/list_menu/SelectListMenuItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import React from "react";
import {Avatar, ListItem, ListItemAvatar, ListItemText, MenuItem, Select, Typography} from "@mui/material";
import LoadingFade from "../LoadingFade";
import {
Avatar,
CircularProgress,
ListItem,
ListItemAvatar,
ListItemText,
MenuItem,
Select,
Typography
} from "@mui/material";

export type SelectListMenuItemOption = {
value: string,
Expand Down Expand Up @@ -31,7 +39,7 @@ export const SelectListMenuItem: React.FunctionComponent<{
let select;

if (loadingOptions) {
select = <LoadingFade/>;
select = <CircularProgress/>;
} else if (loadError) {
select = <Typography variant="body2" color="error">Error</Typography>;
} else {
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/controls/PresetSelection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import {Box, CircularProgress, Grid, Icon, Paper, Slider, sliderClasses, styled, Typography,} from "@mui/material";
import {
Box,
Grid,
Icon,
Paper,
Skeleton,
Slider,
sliderClasses,
styled,
Typography,
} from "@mui/material";
import {Mark} from "@mui/base";
import React from "react";
import {
Expand Down Expand Up @@ -102,7 +112,7 @@ const PresetSelectionControl = (props: PresetSelectionProps): React.ReactElement
if (presetsPending) {
return (
<Grid item>
<CircularProgress size={20} />
<Skeleton height={"3rem"} />
</Grid>
);
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/useCommittingSlider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const useCommittingSlider = (initialValue: number, onChange: (value: numb

setResetTimeout(setTimeout(() => {
setSliderValue(initialValue);
}, 1000));
}, 2000));
}
}, [sliderValue, initialValue, adoptedValue, getResetTimeout]);

Expand Down
20 changes: 10 additions & 10 deletions frontend/src/options/OptionsRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import MapManagement from "./MapManagement";
import EditMapPage from "../map/EditMapPage";
import {useCapabilitiesSupported} from "../CapabilitiesProvider";
import {Capability} from "../api";
import MQTTConnectivity from "./connectivity/MQTTConnectivity";
import ConnectivityOptions from "./connectivity/ConnectivityOptions";
import NTPConnectivity from "./connectivity/NTPConnectivity";
import AuthSettings from "./connectivity/AuthSettings";
import WifiConnectivity from "./connectivity/WifiConnectivity";
import NetworkAdvertisementSettings from "./connectivity/NetworkAdvertisementSettings";
import NTPConnectivityPage from "./connectivity/NTPConnectivityPage";
import AuthSettingsPage from "./connectivity/AuthSettingsPage";
import WifiConnectivityPage from "./connectivity/WifiConnectivityPage";
import NetworkAdvertisementSettingsPage from "./connectivity/NetworkAdvertisementSettingsPage";
import RobotCoverageMapPage from "../map/RobotCoverageMapPage";
import ValetudoOptions from "./ValetudoOptions";
import React from "react";
import RobotOptions from "../robot/RobotOptions";
import MiscRobotOptions from "../robot/capabilities/MiscRobotOptions";
import Quirks from "../robot/capabilities/Quirks";
import MQTTConnectivityPage from "./connectivity/MQTTConnectivityPage";

const OptionsRouter = (): React.ReactElement => {
const {path} = useRouteMatch();
Expand Down Expand Up @@ -70,21 +70,21 @@ const OptionsRouter = (): React.ReactElement => {
<ConnectivityOptions/>
</Route>
<Route exact path={path + "/connectivity/auth"}>
<AuthSettings/>
<AuthSettingsPage/>
</Route>
<Route exact path={path + "/connectivity/mqtt"}>
<MQTTConnectivity/>
<MQTTConnectivityPage/>
</Route>
<Route exact path={path + "/connectivity/networkadvertisement"}>
<NetworkAdvertisementSettings/>
<NetworkAdvertisementSettingsPage/>
</Route>
<Route exact path={path + "/connectivity/ntp"}>
<NTPConnectivity/>
<NTPConnectivityPage/>
</Route>
{
wifiConfigurationCapabilitySupported &&
<Route exact path={path + "/connectivity/wifi"}>
<WifiConnectivity/>
<WifiConnectivityPage/>
</Route>
}

Expand Down
180 changes: 0 additions & 180 deletions frontend/src/options/connectivity/AuthSettings.tsx

This file was deleted.

Loading

0 comments on commit d8714dd

Please sign in to comment.