Skip to content

Commit

Permalink
Merge branch 'BubbleDK:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
zf-development authored Aug 27, 2024
2 parents 9c5d0e0 + 4bf0aa4 commit 5a55f56
Show file tree
Hide file tree
Showing 121 changed files with 8,745 additions and 6,820 deletions.
1 change: 1 addition & 0 deletions client/framework/qb_core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function qb.getOfficerData()
officer.firstname = playerData.charinfo.firstname
officer.lastname = playerData.charinfo.lastname
officer.role = playerData.job.grade.name
officer.grade = playerData.job.grade.level

return officer
end
Expand Down
1 change: 1 addition & 0 deletions client/framework/qbx_core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function qb.getOfficerData()
officer.firstname = playerData.charinfo.firstname
officer.lastname = playerData.charinfo.lastname
officer.role = playerData.job.grade.name
officer.grade = playerData.job.grade.level

return officer
end
Expand Down
10 changes: 10 additions & 0 deletions permissions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"create_announcement": 4,
"create_charge": 4,
"delete_charge": 4,
"edit_charge": 4,
"hire_officer": 4,
"set_officer_rank": 4,
"set_officer_roles": 4,
"fire_officer": 4
}

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion web/build/assets/index-40fcadd0.css

This file was deleted.

1 change: 1 addition & 0 deletions web/build/assets/index-eeb3b938.css

Large diffs are not rendered by default.

38 changes: 22 additions & 16 deletions web/build/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Nunito&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css" />
<title>Bubble MDT</title>
<script type="module" crossorigin src="./assets/index-3d12f69b.js"></script>
<link rel="stylesheet" href="./assets/index-40fcadd0.css">
</head>
<body>
<div id="root"></div>

</body>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Nunito&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css"
/>
<title>Bubble MDT</title>
<script type="module" crossorigin src="./assets/index-0518d1ff.js"></script>
<link rel="stylesheet" href="./assets/index-eeb3b938.css">
</head>
<body>
<div id="root"></div>

</body>
</html>
34 changes: 20 additions & 14 deletions web/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Nunito&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css" />
<title>Bubble MDT</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Nunito&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css"
/>
<title>Bubble MDT</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
8 changes: 4 additions & 4 deletions web/src/helpers/capitalizeFirstLetter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const capitalizeFirstLetter = (str: string): string => {
if (str.length === 0) {
return str;
}
if (str.length === 0) {
return str;
}

return str.charAt(0).toUpperCase() + str.slice(1);
return str.charAt(0).toUpperCase() + str.slice(1);
}
18 changes: 9 additions & 9 deletions web/src/helpers/convert.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Call, Unit, UnitsObject } from '../typings';

export interface CallsResponse extends Omit<Call, 'units'> {
units: UnitsObject;
units: UnitsObject;
}

export const convertUnitsToArray = (units: UnitsObject): Unit[] => {
if (!units) return [];
return Object.entries(units).map((unit) => ({ id: +unit[0], ...unit[1] }));
if (!units) return [];
return Object.entries(units).map((unit) => ({ id: +unit[0], ...unit[1] }));
};

export const convertCalls = (resp: { [key: string]: CallsResponse } | CallsResponse[]): Call[] => {
if (Array.isArray(resp)) return resp.map((entry) => ({ ...entry, units: convertUnitsToArray(entry.units) }));
return Object.entries(resp).map((entry: [string, CallsResponse]) => {
const call: Call = { ...entry[1], units: [] };
call.units = convertUnitsToArray(entry[1].units);
if (Array.isArray(resp)) return resp.map((entry) => ({ ...entry, units: convertUnitsToArray(entry.units) }));
return Object.entries(resp).map((entry: [string, CallsResponse]) => {
const call: Call = { ...entry[1], units: [] };
call.units = convertUnitsToArray(entry[1].units);

return call;
});
return call;
});
};
28 changes: 28 additions & 0 deletions web/src/helpers/hasPermission.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Character } from "../typings";
import permissions, { PermissionKey } from "../permissions";

export const hasPermission = (
character: Character,
permission: PermissionKey | PermissionKey[]
) => {
if (!Array.isArray(permission)) {
const perm = permissions[permission];

return character.grade >= perm;
}

let failedPerms = 0;
for (let i = 0; i < permission.length; i++) {
const perm = permissions[permission[i]];

if (character.grade < perm) {
failedPerms++;
}

if (failedPerms === permission.length) {
return false;
}
}

return true;
};
13 changes: 4 additions & 9 deletions web/src/helpers/shuffleArray.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
export const shuffleArray = <T>(array: T[]): T[] => {
let currentIndex = array.length, randomIndex;

// While there remain elements to shuffle...
while (currentIndex !== 0) {

// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex--;

// And swap it with the current element.
[array[currentIndex], array[randomIndex]] = [
array[randomIndex], array[currentIndex]];
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex--;

[array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]];
}

return array;
Expand Down
177 changes: 95 additions & 82 deletions web/src/layers/dev/Dev.tsx
Original file line number Diff line number Diff line change
@@ -1,92 +1,105 @@
import React from 'react';
import { ActionIcon, Button, Drawer, Select, Stack, Tooltip } from '@mantine/core';
import { IconTools } from '@tabler/icons-react';
import { debugData } from '../../utils/debugData';
import { Call } from '../../typings';
import { useAppVisibilityStore } from '../../stores';
import React from "react";
import {
ActionIcon,
Button,
Drawer,
Select,
Stack,
Tooltip,
} from "@mantine/core";
import { IconTools } from "@tabler/icons-react";
import { debugData } from "../../utils/debugData";
import { Call } from "../../typings";
import { useAppVisibilityStore } from "../../stores";

const setBackground = (bg: string) => {
const root = document.getElementById('root');
const root = document.getElementById("root");

// https://i.imgur.com/iPTAdYV.png - Night time img
// https://i.imgur.com/3pzRj9n.png - Day time
root!.style.backgroundImage = `url(${bg})`;
root!.style.backgroundSize = 'cover';
root!.style.backgroundRepeat = 'no-repeat';
root!.style.backgroundPosition = 'center';
// https://i.imgur.com/iPTAdYV.png - Night time img
// https://i.imgur.com/3pzRj9n.png - Day time
root!.style.backgroundImage = `url(${bg})`;
root!.style.backgroundSize = "cover";
root!.style.backgroundRepeat = "no-repeat";
root!.style.backgroundPosition = "center";
};

const Dev: React.FC = () => {
const [opened, setOpened] = React.useState(false);
const toggleVisibility = useAppVisibilityStore((state) => state.toggle);
const [opened, setOpened] = React.useState(false);
const toggleVisibility = useAppVisibilityStore((state) => state.toggle);

return (
<>
<Tooltip label="Developer drawer" position="bottom">
<ActionIcon
onClick={() => setOpened(true)}
radius="xl"
variant="filled"
color="orange"
sx={{ position: 'absolute', bottom: 0, right: 0, width: 50, height: 50 }}
size="xl"
mr={50}
mb={50}
>
<IconTools />
</ActionIcon>
</Tooltip>
return (
<>
<Tooltip label='Developer drawer' position='bottom'>
<ActionIcon
onClick={() => setOpened(true)}
radius='xl'
variant='filled'
color='orange'
sx={{
position: "absolute",
bottom: 0,
right: 0,
width: 50,
height: 50,
}}
size='xl'
mr={50}
mb={50}
>
<IconTools />
</ActionIcon>
</Tooltip>

<Drawer
position="left"
onClose={() => setOpened(false)}
opened={opened}
title="Developer drawer"
padding="xl"
size="xs"
zIndex={1}
>
<Stack>
<Select
onChange={(val) => setBackground(val as string)}
defaultValue="https://i.imgur.com/3pzRj9n.png"
data={[
{ label: 'Day', value: 'https://i.imgur.com/3pzRj9n.png' },
{ label: 'Night', value: 'https://i.imgur.com/iPTAdYV.png' },
]}
label="Background"
/>
<Button onClick={() => toggleVisibility()}>Toggle MDT</Button>
<Button
onClick={() =>
debugData<Call>([
{
action: 'addCall',
data: {
id: 4,
offense: 'Vehicle theft',
code: '10-15',
blip: 51,
coords: [1, 1],
linked: false,
time: Date.now(),
location: 'Strawberry Ave',
info: [
{ label: 'Sultan RS', icon: 'car' },
{ label: 'XYZ 123', icon: 'badge-tm' },
],
units: [],
},
},
])
}
>
Add call
</Button>
</Stack>
</Drawer>
</>
);
<Drawer
position='left'
onClose={() => setOpened(false)}
opened={opened}
title='Developer drawer'
padding='xl'
size='xs'
zIndex={1}
>
<Stack>
<Select
onChange={(val) => setBackground(val as string)}
defaultValue='https://i.imgur.com/3pzRj9n.png'
data={[
{ label: "Day", value: "https://i.imgur.com/3pzRj9n.png" },
{ label: "Night", value: "https://i.imgur.com/iPTAdYV.png" },
]}
label='Background'
/>
<Button onClick={() => toggleVisibility()}>Toggle MDT</Button>
<Button
onClick={() =>
debugData<Call>([
{
action: "addCall",
data: {
id: 4,
offense: "Vehicle theft",
code: "10-15",
blip: 51,
coords: [1, 1],
linked: false,
time: Date.now(),
location: "Strawberry Ave",
info: [
{ label: "Sultan RS", icon: "car" },
{ label: "XYZ 123", icon: "badge-tm" },
],
units: [],
},
},
])
}
>
Add call
</Button>
</Stack>
</Drawer>
</>
);
};

export default Dev;
export default Dev;
Loading

0 comments on commit 5a55f56

Please sign in to comment.