mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-01 14:38:50 +00:00
refactor(web): initial svelte rewrite files
This commit is contained in:
1 parent
be8580396c
commit
e04a43a86c
53 files changed
+3462
-12172
No files matched your search
@@ -110,6 +110,9 @@ dist
|
||||
# Stores VSCode versions used for testing VSCode extensions
|
||||
.vscode-test
|
||||
|
||||
# JetBrains
|
||||
.idea
|
||||
|
||||
# yarn v2
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
|
||||
+2
-1
@@ -26,7 +26,8 @@
|
||||
"mysql2": "^3.2.0",
|
||||
"named-placeholders": "^1.1.3",
|
||||
"node-fetch": "^3.3.0",
|
||||
"prettier": "^2.8.3"
|
||||
"prettier": "^2.8.3",
|
||||
"svelte-spa-router": "^3.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.14.54",
|
||||
|
||||
Generated
+13
@@ -12,6 +12,7 @@ specifiers:
|
||||
postinstall-postinstall: ^2.1.0
|
||||
prettier: ^2.8.3
|
||||
pretty-quick: ^3.1.3
|
||||
svelte-spa-router: ^3.3.0
|
||||
typescript: ^4.9.4
|
||||
|
||||
dependencies:
|
||||
@@ -22,6 +23,7 @@ dependencies:
|
||||
named-placeholders: 1.1.3
|
||||
node-fetch: 3.3.0
|
||||
prettier: 2.8.3
|
||||
svelte-spa-router: 3.3.0
|
||||
|
||||
devDependencies:
|
||||
esbuild: 0.14.54
|
||||
@@ -4182,6 +4184,11 @@ packages:
|
||||
functions-have-names: 1.2.3
|
||||
dev: true
|
||||
|
||||
/regexparam/2.0.1:
|
||||
resolution: {integrity: sha512-zRgSaYemnNYxUv+/5SeoHI0eJIgTL/A2pUtXUPLHQxUldagouJ9p+K6IbIZ/JiQuCEv2E2B1O11SjVQy3aMCkw==}
|
||||
engines: {node: '>=8'}
|
||||
dev: false
|
||||
|
||||
/request/2.88.2:
|
||||
resolution: {integrity: sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==}
|
||||
engines: {node: '>= 6'}
|
||||
@@ -4616,6 +4623,12 @@ packages:
|
||||
engines: {node: '>= 0.4'}
|
||||
dev: true
|
||||
|
||||
/svelte-spa-router/3.3.0:
|
||||
resolution: {integrity: sha512-cwRNe7cxD43sCvSfEeaKiNZg3FCizGxeMcf7CPiWRP3jKXjEma3vxyyuDtPOam6nWbVxl9TNM3hlE/i87ZlqcQ==}
|
||||
dependencies:
|
||||
regexparam: 2.0.1
|
||||
dev: false
|
||||
|
||||
/tar/4.4.19:
|
||||
resolution: {integrity: sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==}
|
||||
engines: {node: '>=4.5'}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
@@ -1,24 +0,0 @@
|
||||
const path = require('path');
|
||||
module.exports = {
|
||||
webpack: {
|
||||
configure: (webpackConfig) => {
|
||||
// Because CEF has issues with loading source maps properly atm,
|
||||
// lets use the best we can get in line with `eval-source-map`
|
||||
if (webpackConfig.mode === 'development' && process.env.IN_GAME_DEV) {
|
||||
webpackConfig.devtool = 'eval-source-map';
|
||||
webpackConfig.output.path = path.join(__dirname, 'build');
|
||||
}
|
||||
|
||||
return webpackConfig;
|
||||
},
|
||||
},
|
||||
|
||||
devServer: (devServerConfig) => {
|
||||
if (process.env.IN_GAME_DEV) {
|
||||
// Used for in-game dev mode
|
||||
devServerConfig.devMiddleware.writeToDisk = true;
|
||||
}
|
||||
|
||||
return devServerConfig;
|
||||
},
|
||||
};
|
||||
@@ -1,69 +0,0 @@
|
||||
{
|
||||
"name": "ui",
|
||||
"version": "1.0.0",
|
||||
"homepage": "ui/build",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@chakra-ui/icons": "^1.1.1",
|
||||
"@chakra-ui/react": "^1.7.3",
|
||||
"@emotion/react": "^11",
|
||||
"@emotion/styled": "^11",
|
||||
"@types/jest": "^26.0.24",
|
||||
"@types/node": "^16.11.18",
|
||||
"@types/react": "^17.0.38",
|
||||
"@types/react-dom": "^17.0.11",
|
||||
"@types/react-table": "^7.7.9",
|
||||
"framer-motion": "4.1.17",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-router-dom": "6",
|
||||
"react-scripts": "5.0.0",
|
||||
"react-table": "^7.7.0",
|
||||
"typescript": "^4.5.4",
|
||||
"victory": "^36.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cross-env PUBLIC_URL=/ craco start",
|
||||
"start:game": "cross-env IN_GAME_DEV=1 craco start",
|
||||
"build": "rimraf build && craco build",
|
||||
"test": "craco test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": ">=7.0.0 <8.0.0",
|
||||
"@babel/plugin-syntax-flow": "^7.14.5",
|
||||
"@babel/plugin-transform-react-jsx": "^7.14.9",
|
||||
"@chakra-ui/system": "^1.11.2",
|
||||
"@craco/craco": "^6.4.3",
|
||||
"autoprefixer": "^10.0.2",
|
||||
"cross-env": "^7.0.3",
|
||||
"postcss": "^8.1.0",
|
||||
"rimraf": "^3.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": ">=7.0.0 <8.0.0",
|
||||
"@babel/plugin-syntax-flow": "^7.14.5",
|
||||
"@babel/plugin-transform-react-jsx": "^7.14.9",
|
||||
"@chakra-ui/system": "^1.11.2",
|
||||
"autoprefixer": "^10.0.2",
|
||||
"postcss": "^8.1.0"
|
||||
}
|
||||
}
|
||||
Generated
-11261
File diff suppressed because it is too large.
Load diff
@@ -1,23 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<title>NUI React Boilerplate</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,58 +0,0 @@
|
||||
import { Flex, Box } from '@chakra-ui/react';
|
||||
import { debugData } from '../utils/debugData';
|
||||
import TopBar from './NavBars/TopBar';
|
||||
import LeftBar from './NavBars/LeftBar';
|
||||
import { Routes, Route, useNavigate } from 'react-router-dom';
|
||||
import Resource from './Resource';
|
||||
import RightBar from './NavBars/RightBar';
|
||||
import MainContent from './MainContent';
|
||||
import { useNuiEvent } from '../hooks/useNuiEvent';
|
||||
|
||||
debugData([
|
||||
{
|
||||
action: 'openUI',
|
||||
data: {
|
||||
resources: ['ox_inventory', 'luke_garages', 'es_extended'],
|
||||
totalQueries: 732,
|
||||
totalTime: 258,
|
||||
slowQueries: 6,
|
||||
chartData: [
|
||||
{ x: 13, y: 350, z: 'ox_inventory' },
|
||||
{ x: 27, y: 752, z: 'es_extended' },
|
||||
{ x: 41, y: 52, z: 'luke_garages' },
|
||||
],
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const App: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
useNuiEvent('openUI', () => navigate('/'));
|
||||
|
||||
return (
|
||||
<Flex w="100%" h="100%" alignItems="center" justifyContent="center">
|
||||
<Box
|
||||
width="6xl"
|
||||
height="lg"
|
||||
backgroundColor="#191E26"
|
||||
borderRadius="lg"
|
||||
color="white"
|
||||
fontFamily="Poppins"
|
||||
userSelect="none"
|
||||
>
|
||||
<TopBar />
|
||||
<LeftBar />
|
||||
<RightBar />
|
||||
<MainContent>
|
||||
<Routes>
|
||||
<Route path="/:resource" element={<Resource />} />
|
||||
<Route path="/" element={<></>} />
|
||||
</Routes>
|
||||
</MainContent>
|
||||
</Box>
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
@@ -1,14 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Box, Center } from '@chakra-ui/react';
|
||||
|
||||
const MainContent: React.FC = ({ children }) => {
|
||||
return (
|
||||
<Center>
|
||||
<Box h="30.3rem" w="50%" backgroundColor="#1B2129" flex="1">
|
||||
{children}
|
||||
</Box>
|
||||
</Center>
|
||||
);
|
||||
};
|
||||
|
||||
export default MainContent;
|
||||
@@ -1,42 +0,0 @@
|
||||
import { Box, VStack } from '@chakra-ui/react';
|
||||
import { useState } from 'react';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import { useNuiEvent } from '../../hooks/useNuiEvent';
|
||||
import type { InitData } from '../../types';
|
||||
|
||||
const LeftBar: React.FC = () => {
|
||||
const [initData, setInitData] = useState<InitData>({
|
||||
resources: [''],
|
||||
totalQueries: 0,
|
||||
totalTime: 0,
|
||||
slowQueries: 0,
|
||||
chartData: [{ x: 0, y: 0, z: '' }],
|
||||
});
|
||||
|
||||
useNuiEvent<InitData>('openUI', (data) => {
|
||||
setInitData(data);
|
||||
});
|
||||
|
||||
return (
|
||||
<Box pl={3} pr={3} pb={3} pt={2} fontSize="md" float="left" w={150} height="90%" overflowY="scroll">
|
||||
<VStack align="left">
|
||||
{initData.resources.map((resource, index) => (
|
||||
<Box isTruncated key={`${resource}-${index}`}>
|
||||
<NavLink
|
||||
to={resource}
|
||||
style={(state) => ({
|
||||
color: state.isActive ? 'white' : 'grey',
|
||||
})}
|
||||
>
|
||||
<Box _hover={{ color: 'white' }} isTruncated>
|
||||
{resource}
|
||||
</Box>
|
||||
</NavLink>
|
||||
</Box>
|
||||
))}
|
||||
</VStack>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default LeftBar;
|
||||
@@ -1,56 +0,0 @@
|
||||
import { useState } from 'react';
|
||||
import { Box, VStack, Center, Spacer, Flex, Text } from '@chakra-ui/react';
|
||||
import { useNuiEvent } from '../../hooks/useNuiEvent';
|
||||
import { VictoryPie, VictoryTooltip } from 'victory';
|
||||
import type { InitData } from '../../types';
|
||||
|
||||
const RightBar: React.FC = () => {
|
||||
const [initData, setInitData] = useState<InitData>({
|
||||
totalQueries: 0,
|
||||
totalTime: 0,
|
||||
slowQueries: 0,
|
||||
resources: [''],
|
||||
chartData: [{ x: 0, y: 0, z: '' }],
|
||||
});
|
||||
|
||||
// Debug data defined in LeftBar.tsx
|
||||
|
||||
useNuiEvent<InitData>('openUI', (data) => {
|
||||
setInitData(data);
|
||||
});
|
||||
|
||||
return (
|
||||
<Box float="right" w="3xs" h="100%" p={3}>
|
||||
<Center h="100%">
|
||||
<Flex direction="column" h="100%">
|
||||
<Box>
|
||||
<VStack align="left">
|
||||
<Text>Number of queries: {initData.totalQueries.toLocaleString('en-US')}</Text>
|
||||
<Text>Time querying: {Math.trunc(initData.totalTime).toLocaleString('en-US')} ms</Text>
|
||||
<Text color="#f3eca1">Slow queries: {initData.slowQueries.toLocaleString('en-US')}</Text>
|
||||
</VStack>
|
||||
</Box>
|
||||
<Spacer />
|
||||
<Box>
|
||||
<VictoryPie
|
||||
colorScale="qualitative"
|
||||
data={initData.chartData}
|
||||
labelComponent={<VictoryTooltip flyoutPadding={18} style={{ fontSize: 24 }} cornerRadius={15} />}
|
||||
style={{
|
||||
labels: {
|
||||
fill: 'black',
|
||||
fontFamily: 'Poppins',
|
||||
fontSize: 28,
|
||||
},
|
||||
}}
|
||||
labels={({ datum }) => `${datum.z}: ${datum.x} (${Math.trunc(datum.y)}ms)`}
|
||||
labelPlacement="parallel"
|
||||
/>
|
||||
</Box>
|
||||
</Flex>
|
||||
</Center>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default RightBar;
|
||||
@@ -1,13 +0,0 @@
|
||||
import { Box, Text } from '@chakra-ui/react';
|
||||
|
||||
const TopBar: React.FC = () => {
|
||||
return (
|
||||
<Box w="full" h="4xs">
|
||||
<Text paddingLeft={3} fontSize="lg">
|
||||
Resources
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default TopBar;
|
||||
@@ -1,257 +0,0 @@
|
||||
import { useParams } from 'react-router-dom';
|
||||
import React, { useEffect, useState, useMemo } from 'react';
|
||||
import { fetchNui } from '../utils/fetchNui';
|
||||
import { useNuiEvent } from '../hooks/useNuiEvent';
|
||||
import {
|
||||
Table,
|
||||
Thead,
|
||||
Tbody,
|
||||
Tr,
|
||||
Th,
|
||||
Td,
|
||||
chakra,
|
||||
Flex,
|
||||
IconButton,
|
||||
Text,
|
||||
Spinner,
|
||||
Tooltip,
|
||||
useToast,
|
||||
} from '@chakra-ui/react';
|
||||
import {
|
||||
TriangleDownIcon,
|
||||
TriangleUpIcon,
|
||||
ArrowLeftIcon,
|
||||
ChevronLeftIcon,
|
||||
ArrowRightIcon,
|
||||
ChevronRightIcon,
|
||||
} from '@chakra-ui/icons';
|
||||
import { useTable, useSortBy, Column, usePagination, useFlexLayout } from 'react-table';
|
||||
import { debugData } from '../utils/debugData';
|
||||
import { setClipboard } from '../utils/setClipboard';
|
||||
|
||||
interface QueryData {
|
||||
date: number;
|
||||
query: string;
|
||||
executionTime: number;
|
||||
slow?: boolean;
|
||||
}
|
||||
|
||||
interface TableData {
|
||||
query: string;
|
||||
executionTime: number;
|
||||
slow?: boolean;
|
||||
}
|
||||
|
||||
interface NuiData {
|
||||
queries: QueryData[];
|
||||
pageCount: number;
|
||||
}
|
||||
|
||||
const Resource: React.FC = () => {
|
||||
const { resource } = useParams();
|
||||
const toast = useToast();
|
||||
|
||||
const [isLoaded, setIsLoaded] = useState(false);
|
||||
const [resourceData, setResourceData] = useState<QueryData[]>([
|
||||
{
|
||||
date: 0,
|
||||
query: '',
|
||||
executionTime: 0,
|
||||
},
|
||||
]);
|
||||
const [totalPages, setTotalPages] = useState(1);
|
||||
|
||||
const data = useMemo<TableData[]>(() => resourceData, [resourceData]);
|
||||
|
||||
const columns = useMemo<Column<TableData>[]>(
|
||||
() => [
|
||||
{
|
||||
Header: 'Query',
|
||||
accessor: 'query',
|
||||
},
|
||||
{
|
||||
Header: 'Execution time (ms)',
|
||||
accessor: 'executionTime',
|
||||
},
|
||||
{
|
||||
Header: 'Slow',
|
||||
accessor: 'slow',
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
|
||||
const {
|
||||
getTableProps,
|
||||
getTableBodyProps,
|
||||
headerGroups,
|
||||
page,
|
||||
canPreviousPage,
|
||||
canNextPage,
|
||||
pageOptions,
|
||||
pageCount,
|
||||
gotoPage,
|
||||
nextPage,
|
||||
previousPage,
|
||||
state: { pageIndex, sortBy },
|
||||
prepareRow,
|
||||
} = useTable(
|
||||
{
|
||||
columns,
|
||||
data,
|
||||
initialState: { pageSize: 12, hiddenColumns: ['slow'] },
|
||||
manualPagination: true,
|
||||
manualSortBy: true,
|
||||
pageCount: totalPages,
|
||||
autoResetPage: false,
|
||||
},
|
||||
useSortBy,
|
||||
usePagination,
|
||||
useFlexLayout
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
fetchNui('fetchResource', { resource, pageIndex, sortBy });
|
||||
setIsLoaded(false);
|
||||
debugData<NuiData>([
|
||||
{
|
||||
action: 'loadResource',
|
||||
data: {
|
||||
queries: [
|
||||
{ query: 'SELECT * FROM `owned_vehicles`', date: 0, executionTime: 3.5 },
|
||||
{ query: 'SELECT * FROM `users`', date: 0, executionTime: 7.3 },
|
||||
{ query: 'SELECT * FROM `properties`', date: 0, executionTime: 25.7 },
|
||||
],
|
||||
pageCount: 1,
|
||||
},
|
||||
},
|
||||
]);
|
||||
}, [resource, pageIndex, sortBy]);
|
||||
|
||||
useNuiEvent<NuiData>('loadResource', (data) => {
|
||||
setResourceData(data.queries);
|
||||
setTotalPages(data.pageCount);
|
||||
setIsLoaded(true);
|
||||
});
|
||||
|
||||
const handleClick = (value: string) => {
|
||||
setClipboard(value);
|
||||
toast({
|
||||
title: 'Query copied to clipboard',
|
||||
duration: 2500,
|
||||
status: 'success',
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Flex direction="column" justifyContent="space-between" alignItems="center" h="full">
|
||||
<Table {...getTableProps()} size="sm">
|
||||
<Thead>
|
||||
{headerGroups.map((header): any => (
|
||||
<Tr {...header.getHeaderGroupProps()}>
|
||||
{header.headers.map((column) => (
|
||||
<Th
|
||||
{...column.getHeaderProps(column.getSortByToggleProps())}
|
||||
color="white"
|
||||
fontFamily="Poppins"
|
||||
borderBottomColor="#313C4A"
|
||||
textAlign="center"
|
||||
>
|
||||
{column.render('Header')}
|
||||
<chakra.span pl="4">
|
||||
{column.isSorted ? (
|
||||
column.isSortedDesc ? (
|
||||
<TriangleDownIcon aria-label="sorted descending" />
|
||||
) : (
|
||||
<TriangleUpIcon aria-label="sorted ascending" />
|
||||
)
|
||||
) : null}
|
||||
</chakra.span>
|
||||
</Th>
|
||||
))}
|
||||
</Tr>
|
||||
))}
|
||||
</Thead>
|
||||
<Tbody {...getTableBodyProps()}>
|
||||
{isLoaded && (
|
||||
<>
|
||||
{page.map((row, index) => {
|
||||
prepareRow(row);
|
||||
return (
|
||||
<Tr {...row.getRowProps()} key={`row-${index}`}>
|
||||
{row.cells.map((cell, index) => (
|
||||
<React.Fragment key={`row-${index}`}>
|
||||
<Tooltip
|
||||
isDisabled={cell.column.id === 'executionTime'}
|
||||
label={cell.value}
|
||||
openDelay={500}
|
||||
key={`cell-${index}`}
|
||||
>
|
||||
<Td
|
||||
{...cell.getCellProps()}
|
||||
fontFamily="Poppins"
|
||||
borderBottomColor="#313C4A"
|
||||
color={row.values.slow && '#f3eca1'}
|
||||
isTruncated={cell.column.id === 'query'}
|
||||
textAlign={cell.column.id === 'executionTime' ? 'center' : 'left'}
|
||||
onClick={(e) => cell.column.id === 'query' && handleClick(cell.value)}
|
||||
>
|
||||
{cell.render('Cell')}
|
||||
</Td>
|
||||
</Tooltip>
|
||||
</React.Fragment>
|
||||
))}
|
||||
</Tr>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
)}
|
||||
</Tbody>
|
||||
</Table>
|
||||
|
||||
{!isLoaded && <Spinner />}
|
||||
|
||||
<Flex justifyContent="center" alignItems="center" p={3}>
|
||||
<Flex>
|
||||
<IconButton
|
||||
icon={<ArrowLeftIcon h={3} w={3} color="black" />}
|
||||
aria-label="Last page"
|
||||
onClick={() => gotoPage(0)}
|
||||
size="sm"
|
||||
isDisabled={!canPreviousPage}
|
||||
/>
|
||||
<IconButton
|
||||
aria-label="Previous page"
|
||||
onClick={previousPage}
|
||||
isDisabled={!canPreviousPage}
|
||||
icon={<ChevronLeftIcon h={6} w={6} color="black" />}
|
||||
size="sm"
|
||||
ml={4}
|
||||
/>
|
||||
</Flex>
|
||||
<Text align="center" pl={4} pr={4}>
|
||||
Page {pageIndex + 1} of {pageOptions.length}
|
||||
</Text>
|
||||
<Flex>
|
||||
<IconButton
|
||||
aria-label="Next page"
|
||||
onClick={nextPage}
|
||||
size="sm"
|
||||
isDisabled={!canNextPage}
|
||||
icon={<ChevronRightIcon h={6} w={6} color="black" />}
|
||||
/>
|
||||
<IconButton
|
||||
aria-label="Last page"
|
||||
onClick={() => gotoPage(pageCount - 1)}
|
||||
isDisabled={!canNextPage}
|
||||
icon={<ArrowRightIcon h={3} w={3} color="black" />}
|
||||
size="sm"
|
||||
ml={4}
|
||||
/>
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
export default Resource;
|
||||
@@ -1,46 +0,0 @@
|
||||
import { MutableRefObject, useEffect, useRef } from 'react';
|
||||
import { noop } from '../utils/misc';
|
||||
|
||||
interface NuiMessageData<T = unknown> {
|
||||
action: string;
|
||||
data: T;
|
||||
}
|
||||
|
||||
type NuiHandlerSignature<T> = (data: T) => void;
|
||||
|
||||
/**
|
||||
* A hook that manage events listeners for receiving data from the client scripts
|
||||
* @param action The specific `action` that should be listened for.
|
||||
* @param handler The callback function that will handle data relayed by this hook
|
||||
*
|
||||
* @example
|
||||
* useNuiEvent<{visibility: true, wasVisible: 'something'}>('setVisible', (data) => {
|
||||
* // whatever logic you want
|
||||
* })
|
||||
*
|
||||
**/
|
||||
|
||||
export const useNuiEvent = <T = any>(action: string, handler: (data: T) => void) => {
|
||||
const savedHandler: MutableRefObject<NuiHandlerSignature<T>> = useRef(noop);
|
||||
|
||||
// Make sure we handle for a reactive handler
|
||||
useEffect(() => {
|
||||
savedHandler.current = handler;
|
||||
}, [handler]);
|
||||
|
||||
useEffect(() => {
|
||||
const eventListener = (event: MessageEvent<NuiMessageData<T>>) => {
|
||||
const { action: eventAction, data } = event.data;
|
||||
|
||||
if (savedHandler.current) {
|
||||
if (eventAction === action) {
|
||||
savedHandler.current(data);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('message', eventListener);
|
||||
// Remove Event Listener on component cleanup
|
||||
return () => window.removeEventListener('message', eventListener);
|
||||
}, [action]);
|
||||
};
|
||||
@@ -1,32 +0,0 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
|
||||
'Droid Sans', 'Helvetica Neue', sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
height: 100vh;
|
||||
background: none !important;
|
||||
}
|
||||
|
||||
#root {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 2px;
|
||||
border-radius: 1vh;
|
||||
background-color: transparent;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: grey;
|
||||
border-radius: 1vh;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import './index.css';
|
||||
import App from './components/App';
|
||||
import { VisibilityProvider } from './providers/VisibilityProvider';
|
||||
import { ChakraProvider } from '@chakra-ui/react';
|
||||
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<VisibilityProvider>
|
||||
<ChakraProvider>
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
</ChakraProvider>
|
||||
</VisibilityProvider>
|
||||
</React.StrictMode>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
@@ -1,49 +0,0 @@
|
||||
import React, { Context, createContext, useContext, useEffect, useState } from 'react';
|
||||
import { useNuiEvent } from '../hooks/useNuiEvent';
|
||||
import { fetchNui } from '../utils/fetchNui';
|
||||
|
||||
const VisibilityCtx = createContext<VisibilityProviderValue | null>(null);
|
||||
|
||||
interface VisibilityProviderValue {
|
||||
setVisible: (visible: boolean) => void;
|
||||
visible: boolean;
|
||||
}
|
||||
|
||||
// This should be mounted at the top level of your application, it is currently set to
|
||||
// apply a CSS visibility value. If this is non-performant, this should be customized.
|
||||
export const VisibilityProvider: React.FC = ({ children }) => {
|
||||
const [visible, setVisible] = useState(false);
|
||||
|
||||
useNuiEvent<boolean>('openUI', setVisible);
|
||||
|
||||
// Handle pressing escape/backspace
|
||||
useEffect(() => {
|
||||
// Only attach listener when we are visible
|
||||
if (!visible) return;
|
||||
|
||||
const keyHandler = (e: KeyboardEvent) => {
|
||||
if (['Escape'].includes(e.code)) {
|
||||
fetchNui('exit');
|
||||
setVisible(false);
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('keydown', keyHandler);
|
||||
|
||||
return () => window.removeEventListener('keydown', keyHandler);
|
||||
}, [visible]);
|
||||
|
||||
return (
|
||||
<VisibilityCtx.Provider
|
||||
value={{
|
||||
visible,
|
||||
setVisible,
|
||||
}}
|
||||
>
|
||||
<div style={{ visibility: visible ? 'visible' : 'hidden', height: '100%' }}>{children}</div>
|
||||
</VisibilityCtx.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useVisibility = () =>
|
||||
useContext<VisibilityProviderValue>(VisibilityCtx as Context<VisibilityProviderValue>);
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
/// <reference types="react-scripts" />
|
||||
@@ -1,13 +0,0 @@
|
||||
interface ChartData {
|
||||
x: number;
|
||||
y: number;
|
||||
z: string;
|
||||
}
|
||||
|
||||
export type InitData = {
|
||||
resources: string[];
|
||||
totalQueries: number;
|
||||
totalTime: number;
|
||||
slowQueries: number;
|
||||
chartData: ChartData[];
|
||||
};
|
||||
Vendored
-122
@@ -1,122 +0,0 @@
|
||||
import {
|
||||
UseColumnOrderInstanceProps,
|
||||
UseColumnOrderState,
|
||||
UseExpandedHooks,
|
||||
UseExpandedInstanceProps,
|
||||
UseExpandedOptions,
|
||||
UseExpandedRowProps,
|
||||
UseExpandedState,
|
||||
UseFiltersColumnOptions,
|
||||
UseFiltersColumnProps,
|
||||
UseFiltersInstanceProps,
|
||||
UseFiltersOptions,
|
||||
UseFiltersState,
|
||||
UseGlobalFiltersColumnOptions,
|
||||
UseGlobalFiltersInstanceProps,
|
||||
UseGlobalFiltersOptions,
|
||||
UseGlobalFiltersState,
|
||||
UseGroupByCellProps,
|
||||
UseGroupByColumnOptions,
|
||||
UseGroupByColumnProps,
|
||||
UseGroupByHooks,
|
||||
UseGroupByInstanceProps,
|
||||
UseGroupByOptions,
|
||||
UseGroupByRowProps,
|
||||
UseGroupByState,
|
||||
UsePaginationInstanceProps,
|
||||
UsePaginationOptions,
|
||||
UsePaginationState,
|
||||
UseResizeColumnsColumnOptions,
|
||||
UseResizeColumnsColumnProps,
|
||||
UseResizeColumnsOptions,
|
||||
UseResizeColumnsState,
|
||||
UseRowSelectHooks,
|
||||
UseRowSelectInstanceProps,
|
||||
UseRowSelectOptions,
|
||||
UseRowSelectRowProps,
|
||||
UseRowSelectState,
|
||||
UseRowStateCellProps,
|
||||
UseRowStateInstanceProps,
|
||||
UseRowStateOptions,
|
||||
UseRowStateRowProps,
|
||||
UseRowStateState,
|
||||
UseSortByColumnOptions,
|
||||
UseSortByColumnProps,
|
||||
UseSortByHooks,
|
||||
UseSortByInstanceProps,
|
||||
UseSortByOptions,
|
||||
UseSortByState,
|
||||
} from 'react-table';
|
||||
|
||||
declare module 'react-table' {
|
||||
// take this file as-is, or comment out the sections that don't apply to your plugin configuration
|
||||
|
||||
export interface TableOptions<D extends Record<string, unknown>>
|
||||
extends UseExpandedOptions<D>,
|
||||
UseFiltersOptions<D>,
|
||||
UseGlobalFiltersOptions<D>,
|
||||
UseGroupByOptions<D>,
|
||||
UsePaginationOptions<D>,
|
||||
UseResizeColumnsOptions<D>,
|
||||
UseRowSelectOptions<D>,
|
||||
UseRowStateOptions<D>,
|
||||
UseSortByOptions<D>,
|
||||
// note that having Record here allows you to add anything to the options, this matches the spirit of the
|
||||
// underlying js library, but might be cleaner if it's replaced by a more specific type that matches your
|
||||
// feature set, this is a safe default.
|
||||
Record<string, any> {}
|
||||
|
||||
export interface Hooks<D extends Record<string, unknown> = Record<string, unknown>>
|
||||
extends UseExpandedHooks<D>,
|
||||
UseGroupByHooks<D>,
|
||||
UseRowSelectHooks<D>,
|
||||
UseSortByHooks<D> {}
|
||||
|
||||
export interface TableInstance<D extends Record<string, unknown> = Record<string, unknown>>
|
||||
extends UseColumnOrderInstanceProps<D>,
|
||||
UseExpandedInstanceProps<D>,
|
||||
UseFiltersInstanceProps<D>,
|
||||
UseGlobalFiltersInstanceProps<D>,
|
||||
UseGroupByInstanceProps<D>,
|
||||
UsePaginationInstanceProps<D>,
|
||||
UseRowSelectInstanceProps<D>,
|
||||
UseRowStateInstanceProps<D>,
|
||||
UseSortByInstanceProps<D> {}
|
||||
|
||||
export interface TableState<D extends Record<string, unknown> = Record<string, unknown>>
|
||||
extends UseColumnOrderState<D>,
|
||||
UseExpandedState<D>,
|
||||
UseFiltersState<D>,
|
||||
UseGlobalFiltersState<D>,
|
||||
UseGroupByState<D>,
|
||||
UsePaginationState<D>,
|
||||
UseResizeColumnsState<D>,
|
||||
UseRowSelectState<D>,
|
||||
UseRowStateState<D>,
|
||||
UseSortByState<D> {}
|
||||
|
||||
export interface ColumnInterface<D extends Record<string, unknown> = Record<string, unknown>>
|
||||
extends UseFiltersColumnOptions<D>,
|
||||
UseGlobalFiltersColumnOptions<D>,
|
||||
UseGroupByColumnOptions<D>,
|
||||
UseResizeColumnsColumnOptions<D>,
|
||||
UseSortByColumnOptions<D> {}
|
||||
|
||||
export interface ColumnInstance<D extends Record<string, unknown> = Record<string, unknown>>
|
||||
extends UseFiltersColumnProps<D>,
|
||||
UseGroupByColumnProps<D>,
|
||||
UseResizeColumnsColumnProps<D>,
|
||||
UseSortByColumnProps<D> {
|
||||
getSortByToggleProps: (props?: Partial<TableSortByToggleProps> | undefined) => TableSortByToggleProps;
|
||||
}
|
||||
|
||||
export interface Cell<D extends Record<string, unknown> = Record<string, unknown>, V = any>
|
||||
extends UseGroupByCellProps<D>,
|
||||
UseRowStateCellProps<D> {}
|
||||
|
||||
export interface Row<D extends Record<string, unknown> = Record<string, unknown>>
|
||||
extends UseExpandedRowProps<D>,
|
||||
UseGroupByRowProps<D>,
|
||||
UseRowSelectRowProps<D>,
|
||||
UseRowStateRowProps<D> {}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
// Will return whether the current environment is in a regular browser
|
||||
// and not CEF
|
||||
export const isEnvBrowser = (): boolean => !(window as any).invokeNative;
|
||||
|
||||
// Basic no operation function
|
||||
export const noop = () => {};
|
||||
@@ -1,9 +0,0 @@
|
||||
// yoinked from https://github.com/project-error/npwd/blob/d8dc5b7f47faf5fc581ffee30f31ff61d184cfe7/phone/src/os/phone/hooks/useClipboard.ts#L1
|
||||
export const setClipboard = (value: string) => {
|
||||
const clipElem = document.createElement('input');
|
||||
clipElem.value = value;
|
||||
document.body.appendChild(clipElem);
|
||||
clipElem.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(clipElem);
|
||||
};
|
||||
@@ -1,20 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"printWidth": 120,
|
||||
"singleQuote": true,
|
||||
"useTabs": false,
|
||||
"tabWidth": 2,
|
||||
"semi": true,
|
||||
"bracketSpacing": true,
|
||||
"trailingComma": "es5",
|
||||
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
|
||||
"pluginSearchDirs": false
|
||||
}
|
||||
@@ -0,0 +1,394 @@
|
||||
@import 'https://use.typekit.net/wxh5ury.css';
|
||||
*,
|
||||
:before,
|
||||
:after {
|
||||
box-sizing: border-box;
|
||||
border-width: 0;
|
||||
border-style: solid;
|
||||
border-color: #e5e7eb;
|
||||
}
|
||||
:before,
|
||||
:after {
|
||||
--tw-content: '';
|
||||
}
|
||||
html {
|
||||
line-height: 1.5;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial,
|
||||
Noto Sans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', Segoe UI Symbol, 'Noto Color Emoji';
|
||||
font-feature-settings: normal;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
line-height: inherit;
|
||||
}
|
||||
hr {
|
||||
height: 0;
|
||||
color: inherit;
|
||||
border-top-width: 1px;
|
||||
}
|
||||
abbr:where([title]) {
|
||||
-webkit-text-decoration: underline dotted;
|
||||
text-decoration: underline dotted;
|
||||
}
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
font-size: inherit;
|
||||
font-weight: inherit;
|
||||
}
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: inherit;
|
||||
}
|
||||
b,
|
||||
strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
code,
|
||||
kbd,
|
||||
samp,
|
||||
pre {
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;
|
||||
font-size: 1em;
|
||||
}
|
||||
small {
|
||||
font-size: 80%;
|
||||
}
|
||||
sub,
|
||||
sup {
|
||||
font-size: 75%;
|
||||
line-height: 0;
|
||||
position: relative;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
table {
|
||||
text-indent: 0;
|
||||
border-color: inherit;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
button,
|
||||
input,
|
||||
optgroup,
|
||||
select,
|
||||
textarea {
|
||||
font-family: inherit;
|
||||
font-size: 100%;
|
||||
font-weight: inherit;
|
||||
line-height: inherit;
|
||||
color: inherit;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
button,
|
||||
select {
|
||||
text-transform: none;
|
||||
}
|
||||
button,
|
||||
[type='button'],
|
||||
[type='reset'],
|
||||
[type='submit'] {
|
||||
-webkit-appearance: button;
|
||||
background-color: transparent;
|
||||
background-image: none;
|
||||
}
|
||||
:-moz-focusring {
|
||||
outline: auto;
|
||||
}
|
||||
:-moz-ui-invalid {
|
||||
box-shadow: none;
|
||||
}
|
||||
progress {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
::-webkit-inner-spin-button,
|
||||
::-webkit-outer-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
[type='search'] {
|
||||
-webkit-appearance: textfield;
|
||||
outline-offset: -2px;
|
||||
}
|
||||
::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
::-webkit-file-upload-button {
|
||||
-webkit-appearance: button;
|
||||
font: inherit;
|
||||
}
|
||||
summary {
|
||||
display: list-item;
|
||||
}
|
||||
blockquote,
|
||||
dl,
|
||||
dd,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
hr,
|
||||
figure,
|
||||
p,
|
||||
pre {
|
||||
margin: 0;
|
||||
}
|
||||
fieldset {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
legend {
|
||||
padding: 0;
|
||||
}
|
||||
ol,
|
||||
ul,
|
||||
menu {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
textarea {
|
||||
resize: vertical;
|
||||
}
|
||||
input::-moz-placeholder,
|
||||
textarea::-moz-placeholder {
|
||||
opacity: 1;
|
||||
color: #9ca3af;
|
||||
}
|
||||
input::placeholder,
|
||||
textarea::placeholder {
|
||||
opacity: 1;
|
||||
color: #9ca3af;
|
||||
}
|
||||
button,
|
||||
[role='button'] {
|
||||
cursor: pointer;
|
||||
}
|
||||
:disabled {
|
||||
cursor: default;
|
||||
}
|
||||
img,
|
||||
svg,
|
||||
video,
|
||||
canvas,
|
||||
audio,
|
||||
iframe,
|
||||
embed,
|
||||
object {
|
||||
display: block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
img,
|
||||
video {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
[hidden] {
|
||||
display: none;
|
||||
}
|
||||
*,
|
||||
:before,
|
||||
:after {
|
||||
--tw-border-spacing-x: 0;
|
||||
--tw-border-spacing-y: 0;
|
||||
--tw-translate-x: 0;
|
||||
--tw-translate-y: 0;
|
||||
--tw-rotate: 0;
|
||||
--tw-skew-x: 0;
|
||||
--tw-skew-y: 0;
|
||||
--tw-scale-x: 1;
|
||||
--tw-scale-y: 1;
|
||||
--tw-pan-x: ;
|
||||
--tw-pan-y: ;
|
||||
--tw-pinch-zoom: ;
|
||||
--tw-scroll-snap-strictness: proximity;
|
||||
--tw-ordinal: ;
|
||||
--tw-slashed-zero: ;
|
||||
--tw-numeric-figure: ;
|
||||
--tw-numeric-spacing: ;
|
||||
--tw-numeric-fraction: ;
|
||||
--tw-ring-inset: ;
|
||||
--tw-ring-offset-width: 0px;
|
||||
--tw-ring-offset-color: #fff;
|
||||
--tw-ring-color: rgb(59 130 246 / 0.5);
|
||||
--tw-ring-offset-shadow: 0 0 #0000;
|
||||
--tw-ring-shadow: 0 0 #0000;
|
||||
--tw-shadow: 0 0 #0000;
|
||||
--tw-shadow-colored: 0 0 #0000;
|
||||
--tw-blur: ;
|
||||
--tw-brightness: ;
|
||||
--tw-contrast: ;
|
||||
--tw-grayscale: ;
|
||||
--tw-hue-rotate: ;
|
||||
--tw-invert: ;
|
||||
--tw-saturate: ;
|
||||
--tw-sepia: ;
|
||||
--tw-drop-shadow: ;
|
||||
--tw-backdrop-blur: ;
|
||||
--tw-backdrop-brightness: ;
|
||||
--tw-backdrop-contrast: ;
|
||||
--tw-backdrop-grayscale: ;
|
||||
--tw-backdrop-hue-rotate: ;
|
||||
--tw-backdrop-invert: ;
|
||||
--tw-backdrop-opacity: ;
|
||||
--tw-backdrop-saturate: ;
|
||||
--tw-backdrop-sepia: ;
|
||||
}
|
||||
::backdrop {
|
||||
--tw-border-spacing-x: 0;
|
||||
--tw-border-spacing-y: 0;
|
||||
--tw-translate-x: 0;
|
||||
--tw-translate-y: 0;
|
||||
--tw-rotate: 0;
|
||||
--tw-skew-x: 0;
|
||||
--tw-skew-y: 0;
|
||||
--tw-scale-x: 1;
|
||||
--tw-scale-y: 1;
|
||||
--tw-pan-x: ;
|
||||
--tw-pan-y: ;
|
||||
--tw-pinch-zoom: ;
|
||||
--tw-scroll-snap-strictness: proximity;
|
||||
--tw-ordinal: ;
|
||||
--tw-slashed-zero: ;
|
||||
--tw-numeric-figure: ;
|
||||
--tw-numeric-spacing: ;
|
||||
--tw-numeric-fraction: ;
|
||||
--tw-ring-inset: ;
|
||||
--tw-ring-offset-width: 0px;
|
||||
--tw-ring-offset-color: #fff;
|
||||
--tw-ring-color: rgb(59 130 246 / 0.5);
|
||||
--tw-ring-offset-shadow: 0 0 #0000;
|
||||
--tw-ring-shadow: 0 0 #0000;
|
||||
--tw-shadow: 0 0 #0000;
|
||||
--tw-shadow-colored: 0 0 #0000;
|
||||
--tw-blur: ;
|
||||
--tw-brightness: ;
|
||||
--tw-contrast: ;
|
||||
--tw-grayscale: ;
|
||||
--tw-hue-rotate: ;
|
||||
--tw-invert: ;
|
||||
--tw-saturate: ;
|
||||
--tw-sepia: ;
|
||||
--tw-drop-shadow: ;
|
||||
--tw-backdrop-blur: ;
|
||||
--tw-backdrop-brightness: ;
|
||||
--tw-backdrop-contrast: ;
|
||||
--tw-backdrop-grayscale: ;
|
||||
--tw-backdrop-hue-rotate: ;
|
||||
--tw-backdrop-invert: ;
|
||||
--tw-backdrop-opacity: ;
|
||||
--tw-backdrop-saturate: ;
|
||||
--tw-backdrop-sepia: ;
|
||||
}
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
.h-\[50px\] {
|
||||
height: 50px;
|
||||
}
|
||||
.h-\[650px\] {
|
||||
height: 650px;
|
||||
}
|
||||
.h-full {
|
||||
height: 100%;
|
||||
}
|
||||
.w-\[1200px\] {
|
||||
width: 1200px;
|
||||
}
|
||||
.w-\[50px\] {
|
||||
width: 50px;
|
||||
}
|
||||
.w-\[80px\] {
|
||||
width: 80px;
|
||||
}
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
.flex-col {
|
||||
flex-direction: column;
|
||||
}
|
||||
.items-center {
|
||||
align-items: center;
|
||||
}
|
||||
.justify-center {
|
||||
justify-content: center;
|
||||
}
|
||||
.justify-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
.gap-2 {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.rounded-md {
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
.rounded-bl-md {
|
||||
border-bottom-left-radius: 0.375rem;
|
||||
}
|
||||
.rounded-tl-md {
|
||||
border-top-left-radius: 0.375rem;
|
||||
}
|
||||
.bg-red-500 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(239 68 68 / var(--tw-bg-opacity));
|
||||
}
|
||||
.bg-slate-700 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(51 65 85 / var(--tw-bg-opacity));
|
||||
}
|
||||
.bg-slate-800 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(30 41 59 / var(--tw-bg-opacity));
|
||||
}
|
||||
.bg-slate-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(15 23 42 / var(--tw-bg-opacity));
|
||||
}
|
||||
.bg-opacity-30 {
|
||||
--tw-bg-opacity: 0.3;
|
||||
}
|
||||
.p-3 {
|
||||
padding: 0.75rem;
|
||||
}
|
||||
.p-4 {
|
||||
padding: 1rem;
|
||||
}
|
||||
.font-main {
|
||||
font-family: Roboto;
|
||||
}
|
||||
.text-red-500 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(239 68 68 / var(--tw-text-opacity));
|
||||
}
|
||||
.text-white {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(255 255 255 / var(--tw-text-opacity));
|
||||
}
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#app {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
.hover\:bg-slate-600:hover {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(71 85 105 / var(--tw-bg-opacity));
|
||||
}
|
||||
.hover\:bg-opacity-40:hover {
|
||||
--tw-bg-opacity: 0.4;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="./vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + Svelte + TS</title>
|
||||
<script type="module" crossorigin src="./assets/index-f801a622.js"></script>
|
||||
<link rel="stylesheet" href="./assets/index-08c28757.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + Svelte + TS</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "oxmysql",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
"start:game": "vite build --watch",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^2.0.3",
|
||||
"@tsconfig/svelte": "^3.0.0",
|
||||
"svelte": "^3.55.1",
|
||||
"svelte-check": "^2.10.3",
|
||||
"tslib": "^2.5.0",
|
||||
"typescript": "^4.9.3",
|
||||
"vite": "^4.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@tabler/icons-svelte": "^2.10.0",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"postcss": "^8.4.21",
|
||||
"prettier": "^2.8.4",
|
||||
"prettier-plugin-svelte": "^2.9.0",
|
||||
"prettier-plugin-tailwindcss": "^0.2.5",
|
||||
"tailwindcss": "^3.2.7"
|
||||
}
|
||||
}
|
||||
Generated
+1389
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,12 @@
|
||||
<script lang="ts">
|
||||
import Router from 'svelte-spa-router';
|
||||
import Navbar from './components/Navbar.svelte';
|
||||
import { routes } from './routes';
|
||||
</script>
|
||||
|
||||
<main class="w-full h-full flex justify-center items-center font-main">
|
||||
<div class="bg-slate-900 text-white w-[1200px] h-[650px] flex rounded-md">
|
||||
<Navbar />
|
||||
<Router {routes} />
|
||||
</div>
|
||||
</main>
|
||||
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
import { push, location } from 'svelte-spa-router';
|
||||
|
||||
export let route: string;
|
||||
</script>
|
||||
|
||||
<button
|
||||
on:click={() => push(route)}
|
||||
class="flex flex-col hover:bg-slate-600 w-[50px] h-[50px] justify-center items-center p-3 {$location === route
|
||||
? 'bg-slate-600'
|
||||
: 'bg-slate-700'} rounded-md"
|
||||
>
|
||||
<slot />
|
||||
</button>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script lang="ts">
|
||||
import { IconLayoutDashboard, IconLogout, IconSourceCode } from '@tabler/icons-svelte';
|
||||
import NavLink from './NavLink.svelte';
|
||||
</script>
|
||||
|
||||
<div class="bg-slate-800 w-[80px] h-full rounded-tl-md rounded-bl-md p-4 flex flex-col justify-between items-center">
|
||||
<div class="flex flex-col gap-2">
|
||||
<NavLink route="/">
|
||||
<IconLayoutDashboard />
|
||||
</NavLink>
|
||||
<NavLink route="/resources">
|
||||
<IconSourceCode />
|
||||
</NavLink>
|
||||
</div>
|
||||
<div
|
||||
class="bg-red-500 bg-opacity-30 text-red-500 hover:bg-opacity-40 rounded-md w-[50px] h-[50px] flex justify-center items-center"
|
||||
>
|
||||
<IconLogout />
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
@import url(https://use.typekit.net/wxh5ury.css);
|
||||
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#app {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import './index.css';
|
||||
import App from './App.svelte';
|
||||
|
||||
const app = new App({
|
||||
target: document.getElementById('app'),
|
||||
});
|
||||
|
||||
export default app;
|
||||
@@ -0,0 +1 @@
|
||||
<h2>Dashboard</h2>
|
||||
@@ -0,0 +1 @@
|
||||
<h2>Resources</h2>
|
||||
@@ -0,0 +1,9 @@
|
||||
import Dashboard from './pages/dashboard/Dashboard.svelte';
|
||||
import Resources from './pages/resources/Resources.svelte';
|
||||
import type { RouteDefinition } from 'svelte-spa-router';
|
||||
|
||||
export const routes: RouteDefinition = {
|
||||
'/': Dashboard,
|
||||
|
||||
'/resources': Resources,
|
||||
};
|
||||
@@ -13,7 +13,7 @@ interface DebugEvent<T = any> {
|
||||
* @param timer - How long until it should trigger (ms)
|
||||
*/
|
||||
export const debugData = <P>(events: DebugEvent<P>[], timer = 1000): void => {
|
||||
if (process.env.NODE_ENV === 'development' && isEnvBrowser()) {
|
||||
if (isEnvBrowser()) {
|
||||
for (const event of events) {
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(
|
||||
@@ -1,17 +1,11 @@
|
||||
/**
|
||||
* Simple wrapper around fetch API tailored for CEF/NUI use. This abstraction
|
||||
* can be extended to include AbortController if needed or if the response isn't
|
||||
* JSON. Tailor it to your needs.
|
||||
*
|
||||
* @param eventName - The endpoint eventname to target
|
||||
* @param data - Data you wish to send in the NUI Callback
|
||||
*
|
||||
* @return returnData - A promise for the data sent back by the NuiCallbacks CB argument
|
||||
*/
|
||||
|
||||
import { isEnvBrowser } from './misc';
|
||||
|
||||
export async function fetchNui<T = any>(eventName: string, data?: any): Promise<T> {
|
||||
export async function fetchNui<T = any>(eventName: string, data: unknown = {}): Promise<T> {
|
||||
const options = {
|
||||
method: 'post',
|
||||
headers: {
|
||||
@@ -20,15 +14,11 @@ export async function fetchNui<T = any>(eventName: string, data?: any): Promise<
|
||||
body: JSON.stringify(data),
|
||||
};
|
||||
|
||||
if (isEnvBrowser()) return undefined as any;
|
||||
|
||||
const resourceName = (window as any).GetParentResourceName
|
||||
? (window as any).GetParentResourceName()
|
||||
: 'nui-frame-app';
|
||||
|
||||
const resp = await fetch(`https://${resourceName}/${eventName}`, options);
|
||||
|
||||
const respFormatted = await resp.json();
|
||||
|
||||
return respFormatted;
|
||||
return await resp.json();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export const isEnvBrowser = (): boolean => !(window as any).invokeNative;
|
||||
@@ -0,0 +1,28 @@
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
|
||||
interface NuiMessage<T = unknown> {
|
||||
action: string;
|
||||
data: T;
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that manage events listeners for receiving data from the client scripts
|
||||
* @param action The specific `action` that should be listened for.
|
||||
* @param handler The callback function that will handle data relayed by this function
|
||||
*
|
||||
* @example
|
||||
* useNuiEvent<{visibility: true, wasVisible: 'something'}>('setVisible', (data) => {
|
||||
* // whatever logic you want
|
||||
* })
|
||||
*
|
||||
**/
|
||||
|
||||
export function useNuiEvent<T = unknown>(action: string, handler: (data: T) => void) {
|
||||
const eventListener = (event: MessageEvent<NuiMessage<T>>) => {
|
||||
const { action: eventAction, data } = event.data;
|
||||
|
||||
eventAction === action && handler(data);
|
||||
};
|
||||
onMount(() => window.addEventListener('message', eventListener));
|
||||
onDestroy(() => window.removeEventListener('message', eventListener));
|
||||
}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
/// <reference types="svelte" />
|
||||
/// <reference types="vite/client" />
|
||||
@@ -0,0 +1,7 @@
|
||||
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||
|
||||
export default {
|
||||
// Consult https://svelte.dev/docs#compile-time-svelte-preprocess
|
||||
// for more information about preprocessors
|
||||
preprocess: vitePreprocess(),
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
content: ['./index.html', './src/**/*.{js,ts,svelte}'],
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
main: 'Roboto',
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"extends": "@tsconfig/svelte/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"resolveJsonModule": true,
|
||||
/**
|
||||
* Typecheck JS in `.svelte` and `.js` files by default.
|
||||
* Disable checkJs if you'd like to use dynamic types in JS.
|
||||
* Note that setting allowJs false does not prevent the use
|
||||
* of JS in `.svelte` files.
|
||||
*/
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"isolatedModules": true
|
||||
},
|
||||
"include": ["src/**/*.d.ts", "src/**/*.ts", "src/**/*.js", "src/**/*.svelte"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node"
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import { svelte } from '@sveltejs/vite-plugin-svelte';
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [svelte()],
|
||||
base: './',
|
||||
server: {
|
||||
port: 3000,
|
||||
},
|
||||
build: {
|
||||
outDir: 'build',
|
||||
},
|
||||
});
|
||||
Reference in new issue
Block a user