<p align="center">
<a href="https://metariom.com/" target="_blank">
<img src="public/icons/logo-full.png" width="400" alt="Metariom Logo">
</a>
</p>

<p align="center" style="font-size: x-large; background: -webkit-linear-gradient(#6bcce1, #69549e); -webkit-text-fill-color: transparent; -webkit-background-clip: text;">
<b>
Monitoring Control Panel
</b>
</p>

## Setup Instructions

First clone project source files from [GitHub Repository](https://github.com/SoroushSaDev/bms-admin).
Then follow the steps below :

1. Install PHP dependencies using Composer using the script below :

```bash
  composer install
```

2. Install JS dependencies using NPM using the script below :

```bash
  npm install
```

3. copy .env.example file and rename it to .env and ensure the availability of the variables below :

- REVERB_SERVER_HOST=0.0.0.0
- REVERB_SERVER_PORT=8080
- REVERB_APP_ID=259307
- REVERB_APP_KEY=sv6gaswl6mrw8o0xw5vf
- REVERB_APP_SECRET=jxhrbonrdl6ytbl44ggy
- REVERB_HOST= Application Domain
- REVERB_PORT=443
- REVERB_SCHEME=https


- MQTT_HOST= MQTT Broker Host (IP) Address
- MQTT_AUTH_USERNAME= Admin Username
- MQTT_AUTH_PASSWORD= Admin Password
- MQTT_PORT= MQTT Broker Port (Usually 1883)


- BRAND_NAME_MIN= Brand Abbreviation Name
- BRAND_NAME= Brand Full Name
- BRAND_LOGO_ICON=Logo Without Name
- BRAND_LOGO_FULL= Logo With Name
- BRAND_COLOR_1= First Color (Logo Color 1)
- BRAND_COLOR_2= Second Color (Logo Color 2)
- LOADING_GIF= Loading Ellipsis Gif

> Don't forget to change REVERB_APP_ID, REVERB_APP_KEY & REVERB_APP_SECRET values. only change some characters and keep
> the current format and character length.

4. Set Database credentials in .env file and then run the script below to generate AppKey in .env file :

```bash
  php artisan key:generate
```

5. Run the script below to run migrations to insert tables into database :

```bash
  php artisan migrate
```

6. To seed database and add Admin account and its role and permissions run the script below :

```bash
  php artisan db:seed
```

7. Build CSS & JS assets using Vite using the script below :

```bash
  npm run build
```

8. Add a broker at /brokers and a connection at /connections and put scripts below in supervisor config files :

- php artisan reverb:start
- php artisan queue:work
- php artisan mqtt:serve

## Important Notes

- To enable broadcasting to work with the APIs, ensure that the code below exists in the
  vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastController.php, first line of the **authenticate**
  function :
```php
GrantAPI($request);
```
