mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-03 22:20:56 +00:00
feat(nui): RightBar data fetching
This commit is contained in:
1 parent
ae121fd01c
commit
1ecb93801a
3 files changed
+17
-10
No files matched your search
@@ -3,12 +3,7 @@ import { useState } from 'react';
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { useNuiEvent } from '../../hooks/useNuiEvent';
|
import { useNuiEvent } from '../../hooks/useNuiEvent';
|
||||||
import { debugData } from '../../utils/debugData';
|
import { debugData } from '../../utils/debugData';
|
||||||
|
import type { InitData } from '../../types';
|
||||||
interface InitData {
|
|
||||||
resources: string[];
|
|
||||||
totalQueries: number;
|
|
||||||
totalTime: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const LeftBar: React.FC = () => {
|
const LeftBar: React.FC = () => {
|
||||||
debugData([
|
debugData([
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
import React from 'react';
|
import { useState } from 'react';
|
||||||
import { Box, VStack, Center } from '@chakra-ui/react';
|
import { Box, VStack, Center } from '@chakra-ui/react';
|
||||||
|
import { useNuiEvent } from '../../hooks/useNuiEvent';
|
||||||
|
import type { InitData } from '../../types';
|
||||||
|
|
||||||
const RightBar: React.FC = () => {
|
const RightBar: React.FC = () => {
|
||||||
|
const [initData, setInitData] = useState<InitData>({ totalQueries: 0, totalTime: 0, resources: [''] });
|
||||||
|
|
||||||
|
// Debug data defined in LeftBar.tsx
|
||||||
|
|
||||||
|
useNuiEvent<InitData>('init', (data) => setInitData(data));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box float="right" w="20%" h="max" p="1.2vh">
|
<Box float="right" w="20%" h="max" p="1.2vh">
|
||||||
<Center>
|
<Center>
|
||||||
<VStack align="left">
|
<VStack align="left">
|
||||||
<Box>Number of slow queries: 3</Box>
|
<Box>Total number of queries: {initData.totalQueries}</Box>
|
||||||
<Box>Most active resource: essentialmode</Box>
|
<Box>Total amount of time querying: {initData.totalTime}</Box>
|
||||||
<Box>Total number of queries: 732</Box>
|
|
||||||
</VStack>
|
</VStack>
|
||||||
</Center>
|
</Center>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export type InitData = {
|
||||||
|
resources: string[];
|
||||||
|
totalQueries: number;
|
||||||
|
totalTime: number;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user