mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-02 22:22:50 +00:00
feat(ui): Client-side wrapper
This commit is contained in:
1 parent
8fb5ca2e8c
commit
0290ea17e3
22 files changed
+57
-14
No files matched your search
@@ -0,0 +1,49 @@
|
||||
<script lang="ts">
|
||||
import Router from 'svelte-spa-router';
|
||||
import Resources from './menu/NavMenu.svelte';
|
||||
import Home from './routes/Home.svelte';
|
||||
import ResourceData from './routes/ResourceData.svelte';
|
||||
|
||||
const routes = {
|
||||
'/': Home,
|
||||
'/*': ResourceData,
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
<Resources />
|
||||
<div class="content-wrapper">
|
||||
<div class="content-container">
|
||||
<Router {routes} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
width: 55%;
|
||||
height: 65%;
|
||||
background-color: rgb(44, 62, 80);
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
border-radius: 0.25vh;
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
margin-left: 18vh;
|
||||
height: 100%;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
}
|
||||
|
||||
.content-container {
|
||||
width: 85%;
|
||||
height: 85%;
|
||||
background-color: #34495e;
|
||||
border-radius: 0.25vh;
|
||||
color: white;
|
||||
font-family: 'Inter', sans-serif;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,61 @@
|
||||
<script lang="ts">
|
||||
import { currentResource } from '../../store/stores';
|
||||
const executingResources = ['luke_garages', 'ox_inventory', 'npwd'];
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
<a href="#/"><div class="home-header">Home</div></a>
|
||||
{#each executingResources as resource}
|
||||
<div class="resource-wrapper">
|
||||
<a href={`#/${resource}`}>
|
||||
<div class="resource" on:click={() => currentResource.set(resource)}>
|
||||
{resource}
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
width: 18vh;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
background-color: #34495e;
|
||||
height: 100%;
|
||||
border-top-left-radius: 0.25vh;
|
||||
border-bottom-left-radius: 0.25vh;
|
||||
color: white;
|
||||
font-family: 'Inter', sans-serif;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.home-header {
|
||||
font-size: 2.2vh;
|
||||
text-align: left;
|
||||
padding: 1vh;
|
||||
border-bottom: 0.25vh solid grey;
|
||||
}
|
||||
|
||||
.resource-wrapper {
|
||||
padding: 1vh;
|
||||
}
|
||||
|
||||
.resource {
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 2.2vh;
|
||||
width: 100%;
|
||||
height: 5%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.resource-wrapper:hover,
|
||||
.home-header:hover {
|
||||
background-color: grey;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1 @@
|
||||
<div>Some data here</div>
|
||||
@@ -0,0 +1,38 @@
|
||||
<script lang="ts">
|
||||
import { currentResource } from '../../store/stores';
|
||||
import { fetchNui } from '../../utils/fetchNui';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
export let params: { wild: string };
|
||||
|
||||
interface Data {
|
||||
[key: string]: number[];
|
||||
}
|
||||
|
||||
let queryData: number[];
|
||||
let resource: string;
|
||||
|
||||
const debugQueries: Data = {
|
||||
['luke_garages']: [300, 200, 100],
|
||||
['npwd']: [600, 300, 723],
|
||||
['ox_inventory']: [30, 270, 350],
|
||||
};
|
||||
|
||||
onMount(() => currentResource.set(params.wild));
|
||||
|
||||
currentResource.subscribe((value) => {
|
||||
resource = value;
|
||||
fetchNui('getResourceData', resource)
|
||||
.then((retData) => {
|
||||
queryData = retData;
|
||||
})
|
||||
.catch((e) => {
|
||||
queryData = debugQueries[resource];
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div>
|
||||
{resource}
|
||||
{queryData}
|
||||
</div>
|
||||
Reference in new issue
Block a user