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

Feature: Add loading indicators for all main routes #2092

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 17 additions & 1 deletion packages/ui/src/views/apikey/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Button,
Box,
Chip,
CircularProgress,
Stack,
Table,
TableBody,
Expand Down Expand Up @@ -193,6 +194,7 @@ const APIKey = () => {
const enqueueSnackbar = (...args) => dispatch(enqueueSnackbarAction(...args))
const closeSnackbar = (...args) => dispatch(closeSnackbarAction(...args))

const [isLoading, setLoading] = useState(true)
const [showDialog, setShowDialog] = useState(false)
const [dialogProps, setDialogProps] = useState({})
const [apiKeys, setAPIKeys] = useState([])
Expand Down Expand Up @@ -321,6 +323,10 @@ const APIKey = () => {
}
}, [getAllAPIKeysApi.data])

useEffect(() => {
setLoading(getAllAPIKeysApi.loading)
}, [getAllAPIKeysApi.loading])

return (
<>
<MainCard sx={{ background: customization.isDarkMode ? theme.palette.common.black : '' }}>
Expand Down Expand Up @@ -374,14 +380,24 @@ const APIKey = () => {
</Toolbar>
</Box>
</Stack>
{apiKeys.length <= 0 && (

{isLoading && (
<Stack sx={{ alignItems: 'center', justifyContent: 'center' }} flexDirection='column'>
<Box sx={{ p: 2, height: 'auto' }}>
<CircularProgress color='inherit' />
</Box>
</Stack>
)}

{!isLoading && apiKeys.length <= 0 && (
<Stack sx={{ alignItems: 'center', justifyContent: 'center' }} flexDirection='column'>
<Box sx={{ p: 2, height: 'auto' }}>
<img style={{ objectFit: 'cover', height: '30vh', width: 'auto' }} src={APIEmptySVG} alt='APIEmptySVG' />
</Box>
<div>No API Keys Yet</div>
</Stack>
)}

{apiKeys.length > 0 && (
<TableContainer component={Paper}>
<Table sx={{ minWidth: 650 }} aria-label='simple table'>
Expand Down
29 changes: 22 additions & 7 deletions packages/ui/src/views/assistants/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'
import { useSelector } from 'react-redux'

// material-ui
import { Grid, Box, Stack, Button } from '@mui/material'
import { CircularProgress, Grid, Box, Stack, Button } from '@mui/material'
import { useTheme } from '@mui/material/styles'

// project imports
Expand Down Expand Up @@ -31,6 +31,7 @@ const Assistants = () => {

const getAllAssistantsApi = useApi(assistantsApi.getAllAssistants)

const [isLoading, setLoading] = useState(true)
const [showDialog, setShowDialog] = useState(false)
const [dialogProps, setDialogProps] = useState({})
const [showLoadDialog, setShowLoadDialog] = useState(false)
Expand Down Expand Up @@ -85,6 +86,10 @@ const Assistants = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

useEffect(() => {
setLoading(getAllAssistantsApi.loading)
}, [getAllAssistantsApi.loading])

return (
<>
<MainCard sx={{ background: customization.isDarkMode ? theme.palette.common.black : '' }}>
Expand All @@ -102,10 +107,18 @@ const Assistants = () => {
</Grid>
</Grid>
</Stack>
<Grid container spacing={gridSpacing}>
{!getAllAssistantsApi.loading &&
getAllAssistantsApi.data &&
getAllAssistantsApi.data.map((data, index) => (

{isLoading && (
<Stack sx={{ alignItems: 'center', justifyContent: 'center' }} flexDirection='column'>
<Box sx={{ p: 2, height: 'auto' }}>
<CircularProgress color='inherit' />
</Box>
</Stack>
)}

{!isLoading && getAllAssistantsApi.data && (
<Grid container spacing={gridSpacing}>
{getAllAssistantsApi.data.map((data, index) => (
<Grid key={index} item lg={3} md={4} sm={6} xs={12}>
<ItemCard
data={{
Expand All @@ -117,8 +130,10 @@ const Assistants = () => {
/>
</Grid>
))}
</Grid>
{!getAllAssistantsApi.loading && (!getAllAssistantsApi.data || getAllAssistantsApi.data.length === 0) && (
</Grid>
)}

{!isLoading && (!getAllAssistantsApi.data || getAllAssistantsApi.data.length === 0) && (
<Stack sx={{ alignItems: 'center', justifyContent: 'center' }} flexDirection='column'>
<Box sx={{ p: 2, height: 'auto' }}>
<img style={{ objectFit: 'cover', height: '30vh', width: 'auto' }} src={ToolEmptySVG} alt='ToolEmptySVG' />
Expand Down
9 changes: 8 additions & 1 deletion packages/ui/src/views/chatflows/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom'
import { useSelector } from 'react-redux'

// material-ui
import { Grid, Box, Stack, Toolbar, ToggleButton, ButtonGroup, InputAdornment, TextField } from '@mui/material'
import { CircularProgress, Grid, Box, Stack, Toolbar, ToggleButton, ButtonGroup, InputAdornment, TextField } from '@mui/material'
import { useTheme } from '@mui/material/styles'

// project imports
Expand Down Expand Up @@ -184,6 +184,13 @@ const Chatflows = () => {
</ButtonGroup>
</Toolbar>
</Box>
{isLoading && (
<Stack sx={{ alignItems: 'center', justifyContent: 'center' }} flexDirection='column'>
<Box sx={{ p: 2, height: 'auto' }}>
<CircularProgress color='inherit' />
</Box>
</Stack>
)}
{!isLoading && (!view || view === 'card') && getAllChatflowsApi.data && (
<Grid container spacing={gridSpacing}>
{getAllChatflowsApi.data.filter(filterFlows).map((data, index) => (
Expand Down
20 changes: 18 additions & 2 deletions packages/ui/src/views/credentials/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import moment from 'moment'
import {
Button,
Box,
CircularProgress,
Stack,
Table,
TableBody,
Expand Down Expand Up @@ -60,6 +61,7 @@ const Credentials = () => {
const enqueueSnackbar = (...args) => dispatch(enqueueSnackbarAction(...args))
const closeSnackbar = (...args) => dispatch(closeSnackbarAction(...args))

const [isLoading, setLoading] = useState(true)
const [showCredentialListDialog, setShowCredentialListDialog] = useState(false)
const [credentialListDialogProps, setCredentialListDialogProps] = useState({})
const [showSpecificCredentialDialog, setShowSpecificCredentialDialog] = useState(false)
Expand Down Expand Up @@ -174,6 +176,10 @@ const Credentials = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

useEffect(() => {
setLoading(getAllCredentialsApi.loading)
}, [getAllCredentialsApi.loading])

useEffect(() => {
if (getAllCredentialsApi.data) {
setCredentials(getAllCredentialsApi.data)
Expand Down Expand Up @@ -239,7 +245,16 @@ const Credentials = () => {
</Toolbar>
</Box>
</Stack>
{credentials.length <= 0 && (

{isLoading && (
<Stack sx={{ alignItems: 'center', justifyContent: 'center' }} flexDirection='column'>
<Box sx={{ p: 2, height: 'auto' }}>
<CircularProgress color='inherit' />
</Box>
</Stack>
)}

{!isLoading && credentials.length <= 0 && (
<Stack sx={{ alignItems: 'center', justifyContent: 'center' }} flexDirection='column'>
<Box sx={{ p: 2, height: 'auto' }}>
<img
Expand All @@ -251,7 +266,8 @@ const Credentials = () => {
<div>No Credentials Yet</div>
</Stack>
)}
{credentials.length > 0 && (

{!isLoading && credentials.length > 0 && (
<TableContainer component={Paper}>
<Table sx={{ minWidth: 650 }} aria-label='simple table'>
<TableHead>
Expand Down
9 changes: 9 additions & 0 deletions packages/ui/src/views/marketplaces/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PropTypes from 'prop-types'

// material-ui
import {
CircularProgress,
Grid,
Box,
Stack,
Expand Down Expand Up @@ -381,6 +382,14 @@ const Marketplace = () => {
</Box>
)}

{isLoading && (
<Stack sx={{ alignItems: 'center', justifyContent: 'center' }} flexDirection='column'>
<Box sx={{ p: 2, height: 'auto' }}>
<CircularProgress color='inherit' />
</Box>
</Stack>
)}

{!isLoading && (!view || view === 'card') && getAllTemplatesMarketplacesApi.data && (
<>
<Grid container spacing={gridSpacing}>
Expand Down
29 changes: 22 additions & 7 deletions packages/ui/src/views/tools/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState, useRef } from 'react'
import { useSelector } from 'react-redux'

// material-ui
import { Grid, Box, Stack, Button } from '@mui/material'
import { CircularProgress, Grid, Box, Stack, Button } from '@mui/material'
import { useTheme } from '@mui/material/styles'

// project imports
Expand Down Expand Up @@ -30,6 +30,7 @@ const Tools = () => {

const getAllToolsApi = useApi(toolsApi.getAllTools)

const [isLoading, setLoading] = useState(true)
const [showDialog, setShowDialog] = useState(false)
const [dialogProps, setDialogProps] = useState({})

Expand Down Expand Up @@ -101,6 +102,10 @@ const Tools = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

useEffect(() => {
setLoading(getAllToolsApi.loading)
}, [getAllToolsApi.loading])

return (
<>
<MainCard sx={{ background: customization.isDarkMode ? theme.palette.common.black : '' }}>
Expand All @@ -124,16 +129,26 @@ const Tools = () => {
</Grid>
</Grid>
</Stack>
<Grid container spacing={gridSpacing}>
{!getAllToolsApi.loading &&
getAllToolsApi.data &&
getAllToolsApi.data.map((data, index) => (

{isLoading && (
<Stack sx={{ alignItems: 'center', justifyContent: 'center' }} flexDirection='column'>
<Box sx={{ p: 2, height: 'auto' }}>
<CircularProgress color='inherit' />
</Box>
</Stack>
)}

{!isLoading && getAllToolsApi.data && (
<Grid container spacing={gridSpacing}>
{getAllToolsApi.data.map((data, index) => (
<Grid key={index} item lg={3} md={4} sm={6} xs={12}>
<ItemCard data={data} onClick={() => edit(data)} />
</Grid>
))}
</Grid>
{!getAllToolsApi.loading && (!getAllToolsApi.data || getAllToolsApi.data.length === 0) && (
</Grid>
)}

{!isLoading && (!getAllToolsApi.data || getAllToolsApi.data.length === 0) && (
<Stack sx={{ alignItems: 'center', justifyContent: 'center' }} flexDirection='column'>
<Box sx={{ p: 2, height: 'auto' }}>
<img style={{ objectFit: 'cover', height: '30vh', width: 'auto' }} src={ToolEmptySVG} alt='ToolEmptySVG' />
Expand Down
20 changes: 18 additions & 2 deletions packages/ui/src/views/variables/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import moment from 'moment'
import {
Button,
Box,
CircularProgress,
Stack,
Table,
TableBody,
Expand Down Expand Up @@ -59,6 +60,7 @@ const Variables = () => {
const enqueueSnackbar = (...args) => dispatch(enqueueSnackbarAction(...args))
const closeSnackbar = (...args) => dispatch(closeSnackbarAction(...args))

const [isLoading, setLoading] = useState(true)
const [showVariableDialog, setShowVariableDialog] = useState(false)
const [variableDialogProps, setVariableDialogProps] = useState({})
const [variables, setVariables] = useState([])
Expand Down Expand Up @@ -160,6 +162,10 @@ const Variables = () => {
}
}, [getAllVariables.data])

useEffect(() => {
setLoading(getAllVariables.loading)
}, [getAllVariables.loading])

return (
<>
<MainCard sx={{ background: customization.isDarkMode ? theme.palette.common.black : '' }}>
Expand Down Expand Up @@ -216,7 +222,16 @@ const Variables = () => {
</Toolbar>
</Box>
</Stack>
{variables.length === 0 && (

{isLoading && (
<Stack sx={{ alignItems: 'center', justifyContent: 'center' }} flexDirection='column'>
<Box sx={{ p: 2, height: 'auto' }}>
<CircularProgress color='inherit' />
</Box>
</Stack>
)}

{!isLoading && variables.length === 0 && (
<Stack sx={{ alignItems: 'center', justifyContent: 'center' }} flexDirection='column'>
<Box sx={{ p: 2, height: 'auto' }}>
<img
Expand All @@ -228,7 +243,8 @@ const Variables = () => {
<div>No Variables Yet</div>
</Stack>
)}
{variables.length > 0 && (

{!isLoading && variables.length > 0 && (
<TableContainer component={Paper}>
<Table sx={{ minWidth: 650 }} aria-label='simple table'>
<TableHead>
Expand Down
Loading