8 Commits

Author SHA1 Message Date
ee3e111e9b Merge pull request 'Update README.md' (#3) from tobaojo-patch-1 into develop
Reviewed-on: #3
2025-11-11 13:50:02 +00:00
a8178269c2 Update README.md 2025-11-11 13:49:46 +00:00
0c7d99f7ea minor bugfix: removed csv check for update files 2025-11-11 12:50:48 +00:00
f2e10f958d Merge pull request 'added wifi validation' (#1) from bugfix/wifi into develop
Reviewed-on: #1
2025-11-11 12:40:15 +00:00
903b856303 added wifi validation 2025-11-11 12:37:28 +00:00
672ff1d2f1 Merged main into develop 2025-11-11 10:49:06 +00:00
08a07b7ffb Merged in develop (pull request #38)
Develop
2025-11-11 10:46:53 +00:00
d60c546db1 Merged in bugfix/Matttesting (pull request #37)
Bugfix/Matttesting
2025-11-11 10:45:25 +00:00
3 changed files with 136 additions and 118 deletions

124
README.md
View File

@@ -1,69 +1,77 @@
# 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:
- [@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
## Expanding the ESLint configuration ## Getting started
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules: ### Prerequisites
- Node.js (v18 or higher recommended)
- Yarn (v1.22+) (https://yarnpkg.com/)
```js ### Installation
export default tseslint.config([ ```bash
globalIgnores(['dist']), git clone https://mavportal.com/TobaOjo/Mav-Mobile-UI.git
{ cd Mav-Mobile-UI
files: ['**/*.{ts,tsx}'], yarn install
extends: [ ```
// Other configs... ### Running Locally
```bash
yarn dev
```
The app will be available at `http://localhost:5173`.
// 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... To run on locally on other devices
], ```bash
languageOptions: { yarn dev --host
parserOptions: { ```
project: ['./tsconfig.node.json', './tsconfig.app.json'], The app will be available at the exposed addresses to access e.g. http://192.168.0.123:5173/Mobile
tsconfigRootDir: import.meta.dirname,
}, ## Tech Stack
// other options... - **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://100.118.196.113:8080
``` ```
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: ## 🧪 Development
### Linting & Formatting
```js ```bash
// eslint.config.js yarn lint
import reactX from 'eslint-plugin-react-x' yarn format
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...
},
},
])
``` ```
### Testing
(Currently not implemented consider adding Jest or Vitest)
## 🚢 Deployment
To build for production:
```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
```

View File

@@ -14,9 +14,6 @@ export async function sendBlobFileUpload({ file, opts }: BlobFileUpload): Promis
if (!file) throw new Error("No file supplied"); if (!file) throw new Error("No file supplied");
if (!opts?.uploadUrl) throw new Error("No URL 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 timeoutMs = opts?.timeoutMs ?? 30000;
const fieldName = opts?.fieldName ?? "upload"; const fieldName = opts?.fieldName ?? "upload";
const fileName = opts?.overrideFileName ?? file?.name; const fileName = opts?.overrideFileName ?? file?.name;

View File

@@ -5,6 +5,7 @@ import { useWifiAndModem } from "../../../hooks/useCameraWifiandModem";
import { useState } from "react"; import { useState } from "react";
import { faEyeSlash, faEye } from "@fortawesome/free-solid-svg-icons"; import { faEyeSlash, faEye } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { toast, Toaster } from "sonner";
const WiFiSettingsForm = () => { const WiFiSettingsForm = () => {
const [showPwd, setShowPwd] = useState(false); const [showPwd, setShowPwd] = useState(false);
@@ -19,6 +20,13 @@ const WiFiSettingsForm = () => {
encryption: "WPA2", 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 handleSubmit = async (values: WifiSettingValues) => {
const wifiConfig = { const wifiConfig = {
id: "ModemAndWifiManager-wifi", id: "ModemAndWifiManager-wifi",
@@ -37,6 +45,7 @@ const WiFiSettingsForm = () => {
await wifiMutation.mutateAsync(wifiConfig); await wifiMutation.mutateAsync(wifiConfig);
}; };
return ( return (
<>
<Formik initialValues={initialValues} onSubmit={handleSubmit} enableReinitialize> <Formik initialValues={initialValues} onSubmit={handleSubmit} enableReinitialize>
{({ isSubmitting }) => ( {({ isSubmitting }) => (
<Form className="flex flex-col space-y-5 px-2"> <Form className="flex flex-col space-y-5 px-2">
@@ -63,7 +72,9 @@ const WiFiSettingsForm = () => {
type={showPwd ? "text" : "password"} type={showPwd ? "text" : "password"}
className="p-2 border border-gray-400 rounded-lg w-full" className="p-2 border border-gray-400 rounded-lg w-full"
placeholder="Enter Password" placeholder="Enter Password"
validate={validatePassword}
/> />
<FontAwesomeIcon <FontAwesomeIcon
type="button" type="button"
className="absolute right-5 end-0" className="absolute right-5 end-0"
@@ -97,6 +108,8 @@ const WiFiSettingsForm = () => {
</Form> </Form>
)} )}
</Formik> </Formik>
<Toaster />
</>
); );
}; };