-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add network details query. Use netip.Addr more
- Loading branch information
1 parent
1c27667
commit 21742c8
Showing
24 changed files
with
467 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { useState } from 'react'; | ||
import SearchIcon from '@mui/icons-material/Search'; | ||
import Typography from '@mui/material/Typography'; | ||
import Grid from '@mui/material/Unstable_Grid2'; | ||
import { Formik } from 'formik'; | ||
import { useNetworkQuery } from '../hooks/useNetworkQuery.ts'; | ||
import { LoadingPlaceholder } from './LoadingPlaceholder.tsx'; | ||
import { IPField, IPFieldProps } from './formik/IPField.tsx'; | ||
import { SubmitButton } from './modal/Buttons.tsx'; | ||
|
||
export const NetworkInfo = () => { | ||
const [ip, setIP] = useState(''); | ||
|
||
const { data, loading } = useNetworkQuery({ ip: ip }); | ||
|
||
const onSubmit = (values: IPFieldProps) => { | ||
setIP(values.ip); | ||
}; | ||
|
||
return ( | ||
<Grid container spacing={2}> | ||
<Grid xs={12}> | ||
<Formik onSubmit={onSubmit} initialValues={{ ip: '' }}> | ||
<Grid | ||
container | ||
direction="row" | ||
alignItems="top" | ||
justifyContent="center" | ||
spacing={2} | ||
> | ||
<Grid xs> | ||
<IPField /> | ||
</Grid> | ||
<Grid xs={2}> | ||
<SubmitButton | ||
label={'Submit'} | ||
fullWidth | ||
disabled={loading} | ||
startIcon={<SearchIcon />} | ||
/> | ||
</Grid> | ||
</Grid> | ||
</Formik> | ||
</Grid> | ||
<Grid xs={12}> | ||
{loading ? ( | ||
<LoadingPlaceholder /> | ||
) : ( | ||
<Typography variant={'body1'}> | ||
{JSON.stringify(data)} | ||
</Typography> | ||
)} | ||
</Grid> | ||
</Grid> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { apiGetNetworkDetails, IPQuery, NetworkDetails } from '../api'; | ||
import { logErr } from '../util/errors'; | ||
|
||
export const useNetworkQuery = (opts: IPQuery) => { | ||
const [loading, setLoading] = useState(false); | ||
const [data, setData] = useState<NetworkDetails>(); | ||
|
||
useEffect(() => { | ||
if (opts.ip == '') { | ||
return; | ||
} | ||
const abortController = new AbortController(); | ||
|
||
setLoading(true); | ||
apiGetNetworkDetails(opts, abortController) | ||
.then((resp) => { | ||
setData(resp); | ||
}) | ||
.catch(logErr) | ||
.finally(() => { | ||
setLoading(false); | ||
}); | ||
|
||
return () => abortController.abort(); | ||
}, [opts.ip]); | ||
|
||
return { data, loading }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.