fix(striker-ui): add title to striker config page

main
Tsu-ba-me 2 years ago
parent cd869363d2
commit 5f1d6a8f09
  1. 77
      striker-ui/pages/config/index.tsx

@ -1,4 +1,5 @@
import { Box, Grid } from '@mui/material'; import { Grid } from '@mui/material';
import Head from 'next/head';
import { FC, useState } from 'react'; import { FC, useState } from 'react';
import API_BASE_URL from '../../lib/consts/API_BASE_URL'; import API_BASE_URL from '../../lib/consts/API_BASE_URL';
@ -42,45 +43,51 @@ const Config: FC<{ refreshInterval?: number }> = ({
const [simpleOpsPanelHeader, setSimpleOpsPanelHeader] = const [simpleOpsPanelHeader, setSimpleOpsPanelHeader] =
useProtectedState<string>('', protect); useProtectedState<string>('', protect);
periodicFetch<APIHostDetail>(`${API_BASE_URL}/host/local`, { const { data: hostDetail, isLoading: loadingHostDetail } =
onError: () => { periodicFetch<APIHostDetail>(`${API_BASE_URL}/host/local`, {
setSimpleOpsPanelHeader('Unknown'); onError: () => {
}, setSimpleOpsPanelHeader('Unknown');
onSuccess: ({ installTarget, shortHostName }) => { },
setSimpleOpsInstallTarget(installTarget); onSuccess: ({ installTarget, shortHostName }) => {
setSimpleOpsPanelHeader(shortHostName); setSimpleOpsInstallTarget(installTarget);
}, setSimpleOpsPanelHeader(shortHostName);
refreshInterval, },
}); refreshInterval,
});
return ( return (
<> <>
<Box sx={{ display: 'flex', flexDirection: 'column' }}> <Head>
<Header /> <title>
<Grid container columns={{ xs: 1, md: 3, lg: 4 }}> {loadingHostDetail
<Grid item xs={1}> ? 'Loading...'
<SimpleOperationsPanel : `${hostDetail?.shortHostName} Config`}
installTarget={simpleOpsInstallTarget} </title>
onSubmit={({ onProceedAppend, ...restConfirmDialogProps }) => { </Head>
setConfirmDialogProps((previous) => ({ <Header />
...previous, <Grid container columns={{ xs: 1, md: 3, lg: 4 }}>
...restConfirmDialogProps, <Grid item xs={1}>
onProceedAppend: (...args) => { <SimpleOperationsPanel
onProceedAppend?.call(null, ...args); installTarget={simpleOpsInstallTarget}
setIsOpenConfirmDialog(false); onSubmit={({ onProceedAppend, ...restConfirmDialogProps }) => {
}, setConfirmDialogProps((previous) => ({
})); ...previous,
...restConfirmDialogProps,
onProceedAppend: (...args) => {
onProceedAppend?.call(null, ...args);
setIsOpenConfirmDialog(false);
},
}));
setIsOpenConfirmDialog(true); setIsOpenConfirmDialog(true);
}} }}
title={simpleOpsPanelHeader} title={simpleOpsPanelHeader}
/> />
</Grid> </Grid>
<Grid item md={2} xs={1}> <Grid item md={2} xs={1}>
<ComplexOperationsPanel /> <ComplexOperationsPanel />
</Grid>
</Grid> </Grid>
</Box> </Grid>
<ConfirmDialog <ConfirmDialog
{...confirmDialogProps} {...confirmDialogProps}
dialogProps={{ open: isOpenConfirmDialog }} dialogProps={{ open: isOpenConfirmDialog }}

Loading…
Cancel
Save