|
| 1 | +import React from 'react'; |
| 2 | +import globalize from 'lib/globalize'; |
| 3 | +import Widget from './Widget'; |
| 4 | +import Paper from '@mui/material/Paper'; |
| 5 | +import Typography from '@mui/material/Typography'; |
| 6 | +import Stack from '@mui/material/Stack'; |
| 7 | +import Button from '@mui/material/Button'; |
| 8 | +import Skeleton from '@mui/material/Skeleton'; |
| 9 | +import { useSystemInfo } from 'hooks/useSystemInfo'; |
| 10 | + |
| 11 | +type ServerInfoWidgetProps = { |
| 12 | + onScanLibrariesClick?: () => void; |
| 13 | + onRestartClick?: () => void; |
| 14 | + onShutdownClick?: () => void; |
| 15 | +}; |
| 16 | + |
| 17 | +const ServerInfoWidget = ({ onScanLibrariesClick, onRestartClick, onShutdownClick }: ServerInfoWidgetProps) => { |
| 18 | + const { data: systemInfo, isPending } = useSystemInfo(); |
| 19 | + |
| 20 | + return ( |
| 21 | + <Widget |
| 22 | + title={globalize.translate('TabServer')} |
| 23 | + href='/dashboard/settings' |
| 24 | + > |
| 25 | + <Stack spacing={2}> |
| 26 | + <Paper sx={{ |
| 27 | + padding: 2 |
| 28 | + }}> |
| 29 | + <Stack direction='row'> |
| 30 | + <Stack flexGrow={1} gap={1}> |
| 31 | + <Typography fontWeight='bold'>{globalize.translate('LabelServerName')}</Typography> |
| 32 | + <Typography fontWeight='bold'>{globalize.translate('LabelServerVersion')}</Typography> |
| 33 | + <Typography fontWeight='bold'>{globalize.translate('LabelWebVersion')}</Typography> |
| 34 | + <Typography fontWeight='bold'>{globalize.translate('LabelBuildVersion')}</Typography> |
| 35 | + </Stack> |
| 36 | + <Stack flexGrow={5} gap={1}> |
| 37 | + {isPending ? ( |
| 38 | + <> |
| 39 | + <Skeleton /> |
| 40 | + <Skeleton /> |
| 41 | + <Skeleton /> |
| 42 | + <Skeleton /> |
| 43 | + </> |
| 44 | + ) : ( |
| 45 | + <> |
| 46 | + <Typography>{systemInfo?.ServerName}</Typography> |
| 47 | + <Typography>{systemInfo?.Version}</Typography> |
| 48 | + <Typography>{__PACKAGE_JSON_VERSION__}</Typography> |
| 49 | + <Typography>{__JF_BUILD_VERSION__}</Typography> |
| 50 | + </> |
| 51 | + )} |
| 52 | + </Stack> |
| 53 | + </Stack> |
| 54 | + </Paper> |
| 55 | + |
| 56 | + <Stack direction='row' gap={1.5} flexWrap={'wrap'}> |
| 57 | + <Button |
| 58 | + onClick={onScanLibrariesClick} |
| 59 | + sx={{ |
| 60 | + fontWeight: 'bold' |
| 61 | + }} |
| 62 | + > |
| 63 | + {globalize.translate('ButtonScanAllLibraries')} |
| 64 | + </Button> |
| 65 | + |
| 66 | + <Button |
| 67 | + onClick={onRestartClick} |
| 68 | + color='error' |
| 69 | + sx={{ |
| 70 | + fontWeight: 'bold' |
| 71 | + }} |
| 72 | + > |
| 73 | + {globalize.translate('Restart')} |
| 74 | + </Button> |
| 75 | + |
| 76 | + <Button |
| 77 | + onClick={onShutdownClick} |
| 78 | + color='error' |
| 79 | + sx={{ |
| 80 | + fontWeight: 'bold' |
| 81 | + }} |
| 82 | + > |
| 83 | + {globalize.translate('ButtonShutdown')} |
| 84 | + </Button> |
| 85 | + </Stack> |
| 86 | + </Stack> |
| 87 | + </Widget> |
| 88 | + ); |
| 89 | +}; |
| 90 | + |
| 91 | +export default ServerInfoWidget; |
0 commit comments