React UI: Add Starting Screen (#8662)
* Added walreplay API endpoint Signed-off-by: Levi Harrison <git@leviharrison.dev> * Added starting page to react-ui Signed-off-by: Levi Harrison <git@leviharrison.dev> * Documented the new endpoint Signed-off-by: Levi Harrison <git@leviharrison.dev> * Fixed typos Signed-off-by: Levi Harrison <git@leviharrison.dev> Co-authored-by: Julius Volz <julius.volz@gmail.com> * Removed logo Signed-off-by: Levi Harrison <git@leviharrison.dev> * Changed isResponding to isUnexpected Signed-off-by: Levi Harrison <git@leviharrison.dev> * Changed width of progress bar Signed-off-by: Levi Harrison <git@leviharrison.dev> * Changed width of progress bar Signed-off-by: Levi Harrison <git@leviharrison.dev> * Added DB stats object Signed-off-by: Levi Harrison <git@leviharrison.dev> * Updated starting page to work with new fields Signed-off-by: Levi Harrison <git@leviharrison.dev> * Passing nil Signed-off-by: Levi Harrison <git@leviharrison.dev> * Passing nil (pt. 2) Signed-off-by: Levi Harrison <git@leviharrison.dev> * Passing nil (pt. 3) Signed-off-by: Levi Harrison <git@leviharrison.dev> * Passing nil (and also implementing a method this time) (pt. 4) Signed-off-by: Levi Harrison <git@leviharrison.dev> * Passing nil (and also implementing a method this time) (pt. 5) Signed-off-by: Levi Harrison <git@leviharrison.dev> * Changed const to let Signed-off-by: Levi Harrison <git@leviharrison.dev> * Passing nil (pt. 6) Signed-off-by: Levi Harrison <git@leviharrison.dev> * Remove SetStats method Signed-off-by: Levi Harrison <git@leviharrison.dev> * Added comma Signed-off-by: Levi Harrison <git@leviharrison.dev> * Changed api Signed-off-by: Levi Harrison <git@leviharrison.dev> * Changed to triple equals Signed-off-by: Levi Harrison <git@leviharrison.dev> * Fixed data response types Signed-off-by: Levi Harrison <git@leviharrison.dev> * Don't return pointer Signed-off-by: Levi Harrison <git@leviharrison.dev> * Changed version Signed-off-by: Levi Harrison <git@leviharrison.dev> * Fixed interface issue Signed-off-by: Levi Harrison <git@leviharrison.dev> * Fixed pointer Signed-off-by: Levi Harrison <git@leviharrison.dev> * Fixed copying lock value error Signed-off-by: Levi Harrison <git@leviharrison.dev> Co-authored-by: Julius Volz <julius.volz@gmail.com>pull/8900/head
parent
b781b5cac5
commit
7bc11dcb06
@ -0,0 +1,60 @@ |
||||
import React, { FC, useEffect } from 'react'; |
||||
import { RouteComponentProps, navigate } from '@reach/router'; |
||||
import { Progress, Alert } from 'reactstrap'; |
||||
|
||||
import { useFetchReadyInterval } from '../../hooks/useFetch'; |
||||
import { WALReplayData } from '../../types/types'; |
||||
import { usePathPrefix } from '../../contexts/PathPrefixContext'; |
||||
|
||||
interface StartingContentProps { |
||||
isUnexpected: boolean; |
||||
status?: WALReplayData; |
||||
} |
||||
|
||||
export const StartingContent: FC<StartingContentProps> = ({ status, isUnexpected }) => { |
||||
if (isUnexpected) { |
||||
return ( |
||||
<Alert color="danger"> |
||||
<strong>Error:</strong> Server is not responding |
||||
</Alert> |
||||
); |
||||
} |
||||
|
||||
return ( |
||||
<div className="text-center m-3"> |
||||
<div className="m-4"> |
||||
<h2>Starting up...</h2> |
||||
{status?.current! > status?.min! ? ( |
||||
<div> |
||||
<p> |
||||
Replaying WAL ({status?.current}/{status?.max}) |
||||
</p> |
||||
<Progress |
||||
animated |
||||
value={status?.current} |
||||
min={status?.min} |
||||
max={status?.max} |
||||
color={status?.max === status?.current ? 'success' : undefined} |
||||
style={{ width: '10%', margin: 'auto' }} |
||||
/> |
||||
</div> |
||||
) : null} |
||||
</div> |
||||
</div> |
||||
); |
||||
}; |
||||
|
||||
const Starting: FC<RouteComponentProps> = () => { |
||||
const pathPrefix = usePathPrefix(); |
||||
const { ready, walReplayStatus, isUnexpected } = useFetchReadyInterval(pathPrefix); |
||||
|
||||
useEffect(() => { |
||||
if (ready) { |
||||
navigate('/'); |
||||
} |
||||
}, [ready]); |
||||
|
||||
return <StartingContent isUnexpected={isUnexpected} status={walReplayStatus.data} />; |
||||
}; |
||||
|
||||
export default Starting; |
||||
Loading…
Reference in new issue