-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from yiisoft/opcache
Add opcache page
- Loading branch information
Showing
5 changed files
with
200 additions
and
1 deletion.
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
69 changes: 69 additions & 0 deletions
69
packages/yii-dev-panel/src/Module/Inspector/Pages/OpcachePage.tsx
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,69 @@ | ||
import {Tab, Tabs} from '@mui/material'; | ||
import Box from '@mui/material/Box'; | ||
import {JsonRenderer} from '@yiisoft/yii-dev-panel-sdk/Component/JsonRenderer'; | ||
import {useGetOpcacheQuery} from '@yiisoft/yii-dev-panel/Module/Inspector/API/Inspector'; | ||
import * as React from 'react'; | ||
import {SyntheticEvent, useEffect, useState} from 'react'; | ||
|
||
type TabPanelProps = { | ||
children?: React.ReactNode; | ||
index: number; | ||
value: number; | ||
}; | ||
|
||
function TabPanel(props: TabPanelProps) { | ||
const {children, value, index, ...other} = props; | ||
|
||
return ( | ||
<div role="tabpanel" hidden={value !== index} {...other}> | ||
{value === index && <Box sx={{p: 3}}>{children}</Box>} | ||
</div> | ||
); | ||
} | ||
|
||
export const OpcachePage = () => { | ||
const getOpcacheQuery = useGetOpcacheQuery(); | ||
const [value, setValue] = useState(0); | ||
const [opcache, setOpcache] = useState<any>({}); | ||
const [jit, setJit] = useState<any>({}); | ||
const [scripts, setScripts] = useState<any>({}); | ||
const [configuration, setConfiguration] = useState<any>({}); | ||
|
||
useEffect(() => { | ||
if (getOpcacheQuery.data) { | ||
const data = getOpcacheQuery.data; | ||
const {jit, scripts, ...opcache} = data.status; | ||
setOpcache(opcache); | ||
setJit(jit); | ||
setScripts(scripts); | ||
setConfiguration(data.configuration); | ||
} | ||
}, [getOpcacheQuery.isSuccess]); | ||
console.log(getOpcacheQuery.data); | ||
const handleChange = (event: SyntheticEvent, newValue: number) => setValue(newValue); | ||
|
||
return ( | ||
<Box sx={{width: '100%'}}> | ||
<Box sx={{borderBottom: 1, borderColor: 'divider'}}> | ||
<Tabs value={value} onChange={handleChange}> | ||
<Tab label="Opcache" /> | ||
<Tab label="Jit" /> | ||
<Tab label="Scripts" /> | ||
<Tab label="Configuration" /> | ||
</Tabs> | ||
</Box> | ||
<TabPanel value={value} index={0}> | ||
{opcache && <JsonRenderer value={opcache} />} | ||
</TabPanel> | ||
<TabPanel value={value} index={1}> | ||
{jit && jit && <JsonRenderer value={jit} />} | ||
</TabPanel> | ||
<TabPanel value={value} index={2}> | ||
{scripts && scripts && <JsonRenderer value={scripts} />} | ||
</TabPanel> | ||
<TabPanel value={value} index={3}> | ||
{configuration && configuration && <JsonRenderer value={configuration} />} | ||
</TabPanel> | ||
</Box> | ||
); | ||
}; |
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