Compare commits
15 Commits
bugfix/Mat
...
3d1cc09a5b
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d1cc09a5b | |||
| f571ab80a2 | |||
| b2335d2d4d | |||
| a873da8ef5 | |||
| 5014c97b4d | |||
| e374456588 | |||
| ee3e111e9b | |||
| a8178269c2 | |||
| c057ce5084 | |||
| 0c7d99f7ea | |||
| f2e10f958d | |||
| 903b856303 | |||
| 672ff1d2f1 | |||
| 08a07b7ffb | |||
| d60c546db1 |
163
README.md
163
README.md
@@ -1,69 +1,116 @@
|
||||
# React + TypeScript + Vite
|
||||
# Mav Mobile UI
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
This is a React-based web application built with Vite (react and typescript).
|
||||
|
||||
Currently, two official plugins are available:
|
||||
## Getting started
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||
### Prerequisites
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
- Node.js (v18 or higher recommended)
|
||||
- Yarn (v1.22+) (https://yarnpkg.com/)
|
||||
|
||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||
### Installation
|
||||
|
||||
```js
|
||||
export default tseslint.config([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
|
||||
// Remove tseslint.configs.recommended and replace with this
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
...tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
...tseslint.configs.stylisticTypeChecked,
|
||||
|
||||
// Other configs...
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```bash
|
||||
git clone https://mavportal.com/TobaOjo/Mav-Mobile-UI.git
|
||||
cd Mav-Mobile-UI
|
||||
yarn install
|
||||
```
|
||||
|
||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||
### Running Locally
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
```
|
||||
|
||||
The app will be available at `http://localhost:5173`.
|
||||
|
||||
To run on locally on other devices
|
||||
|
||||
```bash
|
||||
yarn dev --host
|
||||
```
|
||||
|
||||
The app will be available at the exposed addresses to access e.g. http://1xx.xxx.x.xxx:<PORT>/Mobile
|
||||
|
||||
## Tech Stack
|
||||
|
||||
- **React** – UI library
|
||||
- **Vite** – Build tool
|
||||
- **Yarn** – Package manager
|
||||
|
||||
## Configuration
|
||||
|
||||
Create a `.env` file to access the Mav Mobile box in unit 5 for or for any environment-specific settings:
|
||||
|
||||
```env
|
||||
VITE_AGX_BOX_URL=http://1xx.xxx.xxx.xxx:<PORT>
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
### Linting & Formatting
|
||||
|
||||
```bash
|
||||
yarn lint
|
||||
yarn format
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
(Currently not implemented – consider adding Jest or Vitest)
|
||||
|
||||
## Deployment
|
||||
|
||||
To build for production:
|
||||
Navigate to the Mav-Mobile-UI folder
|
||||
|
||||
```bash
|
||||
cd Mav-Mobile-UI
|
||||
```
|
||||
|
||||
**Delete** the local .env (Production will use its own domain)
|
||||
|
||||
run
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
- Navigate to your Mav-Mobile-UI folder
|
||||
- Select the Dist folder
|
||||
- Compress to (ZIP)
|
||||
- Log into box on Moba using Session > SSH and putting IP in Remote Host.
|
||||
- Creds are mav:mav
|
||||
- Drag and drop dist.zip into file explorer menu on left hand side (has to be named dist.zip exactly).
|
||||
- Run command
|
||||
|
||||
```bash
|
||||
sudo ./integrate-web-ui.sh
|
||||
```
|
||||
|
||||
Run
|
||||
|
||||
```bash
|
||||
sudo nano web-static/index.html
|
||||
```
|
||||
|
||||
- add the following between the lines </body> & </html>
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
|
||||
export default tseslint.config([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
// Enable lint rules for React
|
||||
reactX.configs['recommended-typescript'],
|
||||
// Enable lint rules for React DOM
|
||||
reactDom.configs.recommended,
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
<foot>
|
||||
<script>
|
||||
if (window.location.pathname !== "/Mobile") {
|
||||
window.location.replace(window.location.origin + "/Mobile");
|
||||
}
|
||||
</script>
|
||||
</foot>
|
||||
```
|
||||
|
||||
- Run
|
||||
|
||||
```bash
|
||||
sudo reboot
|
||||
```
|
||||
|
||||
It should come back up all working
|
||||
|
||||
@@ -14,9 +14,6 @@ export async function sendBlobFileUpload({ file, opts }: BlobFileUpload): Promis
|
||||
if (!file) throw new Error("No file supplied");
|
||||
if (!opts?.uploadUrl) throw new Error("No URL supplied");
|
||||
|
||||
if (file?.type !== "text/csv") {
|
||||
throw new Error("This file is not supported, please upload a CSV file.");
|
||||
}
|
||||
const timeoutMs = opts?.timeoutMs ?? 30000;
|
||||
const fieldName = opts?.fieldName ?? "upload";
|
||||
const fileName = opts?.overrideFileName ?? file?.name;
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useWifiAndModem } from "../../../hooks/useCameraWifiandModem";
|
||||
import { useState } from "react";
|
||||
import { faEyeSlash, faEye } from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { toast, Toaster } from "sonner";
|
||||
|
||||
const WiFiSettingsForm = () => {
|
||||
const [showPwd, setShowPwd] = useState(false);
|
||||
@@ -19,6 +20,13 @@ const WiFiSettingsForm = () => {
|
||||
encryption: "WPA2",
|
||||
};
|
||||
|
||||
const validatePassword = (password: string) => {
|
||||
if (password.length < 8) {
|
||||
toast.error("Password must be at least 8 characters long", { id: "password" });
|
||||
return "Password must be at least 8 characters long";
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = async (values: WifiSettingValues) => {
|
||||
const wifiConfig = {
|
||||
id: "ModemAndWifiManager-wifi",
|
||||
@@ -37,66 +45,71 @@ const WiFiSettingsForm = () => {
|
||||
await wifiMutation.mutateAsync(wifiConfig);
|
||||
};
|
||||
return (
|
||||
<Formik initialValues={initialValues} onSubmit={handleSubmit} enableReinitialize>
|
||||
{({ isSubmitting }) => (
|
||||
<Form className="flex flex-col space-y-5 px-2">
|
||||
<FormGroup>
|
||||
<label htmlFor="ssid" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
SSID
|
||||
</label>
|
||||
<Field
|
||||
id="ssid"
|
||||
name="ssid"
|
||||
type="text"
|
||||
className="p-1.5 border border-gray-400 rounded-lg"
|
||||
placeholder="Enter SSID"
|
||||
/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="password" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
Password
|
||||
</label>
|
||||
<div className="flex gap-2 items-center relative mb-4">
|
||||
<>
|
||||
<Formik initialValues={initialValues} onSubmit={handleSubmit} enableReinitialize>
|
||||
{({ isSubmitting }) => (
|
||||
<Form className="flex flex-col space-y-5 px-2">
|
||||
<FormGroup>
|
||||
<label htmlFor="ssid" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
SSID
|
||||
</label>
|
||||
<Field
|
||||
id="password"
|
||||
name="password"
|
||||
type={showPwd ? "text" : "password"}
|
||||
className="p-2 border border-gray-400 rounded-lg w-full"
|
||||
placeholder="Enter Password"
|
||||
id="ssid"
|
||||
name="ssid"
|
||||
type="text"
|
||||
className="p-1.5 border border-gray-400 rounded-lg"
|
||||
placeholder="Enter SSID"
|
||||
/>
|
||||
<FontAwesomeIcon
|
||||
type="button"
|
||||
className="absolute right-5 end-0"
|
||||
onClick={() => setShowPwd((s) => !s)}
|
||||
icon={showPwd ? faEyeSlash : faEye}
|
||||
/>
|
||||
</div>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="encryption" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
WPA/Encryption Type
|
||||
</label>
|
||||
<Field
|
||||
id="encryption"
|
||||
name="encryption"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] flex-1 w-2/3"
|
||||
as="select"
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="password" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
Password
|
||||
</label>
|
||||
<div className="flex gap-2 items-center relative mb-4">
|
||||
<Field
|
||||
id="password"
|
||||
name="password"
|
||||
type={showPwd ? "text" : "password"}
|
||||
className="p-2 border border-gray-400 rounded-lg w-full"
|
||||
placeholder="Enter Password"
|
||||
validate={validatePassword}
|
||||
/>
|
||||
|
||||
<FontAwesomeIcon
|
||||
type="button"
|
||||
className="absolute right-5 end-0"
|
||||
onClick={() => setShowPwd((s) => !s)}
|
||||
icon={showPwd ? faEyeSlash : faEye}
|
||||
/>
|
||||
</div>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<label htmlFor="encryption" className="font-medium whitespace-nowrap md:w-2/3">
|
||||
WPA/Encryption Type
|
||||
</label>
|
||||
<Field
|
||||
id="encryption"
|
||||
name="encryption"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] flex-1 w-2/3"
|
||||
as="select"
|
||||
>
|
||||
<option value="WPA2">WPA2</option>
|
||||
<option value="WPA3">WPA3</option>
|
||||
<option value="WEP">WEP</option>
|
||||
<option value="None">None</option>
|
||||
</Field>
|
||||
</FormGroup>
|
||||
<button
|
||||
type="submit"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
>
|
||||
<option value="WPA2">WPA2</option>
|
||||
<option value="WPA3">WPA3</option>
|
||||
<option value="WEP">WEP</option>
|
||||
<option value="None">None</option>
|
||||
</Field>
|
||||
</FormGroup>
|
||||
<button
|
||||
type="submit"
|
||||
className="w-1/4 text-white bg-green-700 hover:bg-green-800 font-small rounded-lg text-sm px-2 py-2.5"
|
||||
>
|
||||
{isSubmitting || wifiMutation.isPending ? "Saving..." : " Save WiFi settings"}
|
||||
</button>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
{isSubmitting || wifiMutation.isPending ? "Saving..." : " Save WiFi settings"}
|
||||
</button>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
<Toaster />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -160,12 +160,13 @@ const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }:
|
||||
<dd className="font-medium text-2xl">{sighting?.seenCount ?? "-"}</dd>
|
||||
</div>
|
||||
|
||||
{sighting?.make && (
|
||||
<div>
|
||||
<dt className="text-gray-300">Make</dt>
|
||||
<dd className="font-medium text-2xl">{sighting?.make ?? "-"}</dd>
|
||||
</div>
|
||||
)}
|
||||
{sighting?.make ||
|
||||
(sighting?.make.trim() && (
|
||||
<div>
|
||||
<dt className="text-gray-300">Make</dt>
|
||||
<dd className="font-medium text-2xl">{sighting?.make ?? "-"}</dd>
|
||||
</div>
|
||||
))}
|
||||
{sighting?.model ||
|
||||
(!sighting?.model.trim() && (
|
||||
<div>
|
||||
@@ -173,12 +174,13 @@ const SightingModal = ({ isSightingModalOpen, handleClose, sighting, onDelete }:
|
||||
<dd className="font-medium text-2xl">{sighting?.model ?? "-"}</dd>
|
||||
</div>
|
||||
))}
|
||||
{sighting?.color && (
|
||||
<div className="sm:col-span-2">
|
||||
<dt className="text-gray-300">Colour</dt>
|
||||
<dd className="font-medium text-2xl">{sighting?.color ?? "-"}</dd>
|
||||
</div>
|
||||
)}
|
||||
{sighting?.color ||
|
||||
(!sighting?.color.trim() && (
|
||||
<div className="sm:col-span-2">
|
||||
<dt className="text-gray-300">Colour</dt>
|
||||
<dd className="font-medium text-2xl">{sighting?.color ?? "-"}</dd>
|
||||
</div>
|
||||
))}
|
||||
|
||||
<div>
|
||||
<dt className="text-gray-300">Time</dt>
|
||||
|
||||
Reference in New Issue
Block a user