mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-03 14:38:50 +00:00
feat(ui): Setting resource list from NUI message
This commit is contained in:
1 parent
49bf5bb3ce
commit
ce802e7553
7 files changed
+40
-32
No files matched your search
@@ -2,6 +2,9 @@
|
|||||||
import VisibilityProvider from './providers/VisibilityProvider.svelte';
|
import VisibilityProvider from './providers/VisibilityProvider.svelte';
|
||||||
import Main from './components/Main.svelte';
|
import Main from './components/Main.svelte';
|
||||||
import { debugData } from './utils/debugData';
|
import { debugData } from './utils/debugData';
|
||||||
|
import { useNuiEvent } from './utils/useNuiEvent';
|
||||||
|
import { resources } from './store/stores';
|
||||||
|
import type { InitData } from './types/init';
|
||||||
|
|
||||||
debugData([
|
debugData([
|
||||||
{
|
{
|
||||||
@@ -9,6 +12,21 @@
|
|||||||
data: true,
|
data: true,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
debugData([
|
||||||
|
{
|
||||||
|
action: 'init',
|
||||||
|
data: {
|
||||||
|
resources: ['ox_inventory', 'luke_garages', 'npwd'],
|
||||||
|
totalQueries: 350,
|
||||||
|
totalTime: 75000,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
useNuiEvent<InitData>('init', (data) => {
|
||||||
|
resources.set(data.resources);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { currentResource } from '../../store/stores';
|
import { currentResource } from '../../store/stores';
|
||||||
const executingResources = ['luke_garages', 'ox_inventory', 'npwd'];
|
import { resources } from '../../store/stores';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a href="#/"><div class="home-header">Home</div></a>
|
<a href="#/"><div class="home-header">Home</div></a>
|
||||||
{#each executingResources as resource}
|
{#each $resources as resource}
|
||||||
<div class="resource-wrapper">
|
<div class="resource-wrapper">
|
||||||
<a href={`#/${resource}`}>
|
<a href={`#/${resource}`}>
|
||||||
<div class="resource" on:click={() => currentResource.set(resource)}>
|
<div class="resource" on:click={() => currentResource.set(resource)}>
|
||||||
@@ -55,7 +55,10 @@
|
|||||||
background-color: grey;
|
background-color: grey;
|
||||||
}
|
}
|
||||||
|
|
||||||
a:visited {
|
a,
|
||||||
|
a:visited,
|
||||||
|
a:active,
|
||||||
|
a:focus {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,29 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { useNuiEvent } from '../../utils/useNuiEvent';
|
import { useNuiEvent } from '../../utils/useNuiEvent';
|
||||||
import { debugData } from '../../utils/debugData';
|
import type { InitData } from '../../types/init';
|
||||||
|
|
||||||
debugData([
|
let initData: InitData;
|
||||||
{
|
|
||||||
action: 'init',
|
|
||||||
data: {
|
|
||||||
resources: ['ox_inventory', 'luke_garages', 'npwd'],
|
|
||||||
totalQueries: 350,
|
|
||||||
totalTime: 75000,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
|
|
||||||
interface QueryData {
|
useNuiEvent<InitData>('init', (data) => {
|
||||||
date: number;
|
|
||||||
query: string;
|
|
||||||
executionTime: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
type QueryLog = Record<string, QueryData[]>;
|
|
||||||
|
|
||||||
let initData: QueryLog;
|
|
||||||
|
|
||||||
useNuiEvent('init', (data: QueryLog) => {
|
|
||||||
initData = data;
|
initData = data;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -4,16 +4,11 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { useNuiEvent } from '../../utils/useNuiEvent';
|
import { useNuiEvent } from '../../utils/useNuiEvent';
|
||||||
import { debugData } from '../../utils/debugData';
|
import { debugData } from '../../utils/debugData';
|
||||||
|
import type { QueryData } from '../../types/query';
|
||||||
|
|
||||||
export let params: { wild: string };
|
export let params: { wild: string };
|
||||||
|
|
||||||
interface QueryData {
|
let queryData: QueryData[];
|
||||||
date: number;
|
|
||||||
query: string;
|
|
||||||
executionTime: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
let queryData: QueryData[] | undefined;
|
|
||||||
let isDataLoaded: boolean = false;
|
let isDataLoaded: boolean = false;
|
||||||
|
|
||||||
onMount(() => currentResource.set(params.wild));
|
onMount(() => currentResource.set(params.wild));
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ import { writable } from "svelte/store";
|
|||||||
|
|
||||||
export const visibility = writable(false);
|
export const visibility = writable(false);
|
||||||
export const currentResource = writable('');
|
export const currentResource = writable('');
|
||||||
|
export const resources = writable<string[]>([])
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export type InitData = {
|
||||||
|
resources: string[];
|
||||||
|
totalQueries: number;
|
||||||
|
totalTime: number;
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export type QueryData = {
|
||||||
|
date: number;
|
||||||
|
query: string;
|
||||||
|
executionTime: number;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user