# CONX

This is a guide for cloning this repository.

#Requirements

- Node js version >= 18 
- Composer >= 1.10
- PHP >= 8.00
- 
- MySQL >= 5.7

## Installation

Go to your desired working directory

Open your VS Code or terminal and enter this:

```bash
git clone https://github.com/cmaa14/conx.git

or

git@github.com:cmaa14/conx.git
```

After successfully cloning the entire repo enter this commands to install the Node js, Packages and other dependencies.

```bash
cd client
npm install

cd ../mobile
npm install

cd ../server
composer install
```

After running the commands 

- Go to "Client" directory and copy all the contents from .env.example to .env (if .env file is not present on the client root folder create it).
- Go to "Mobile" directory and copy all the contents from .env.example to .env (if .env file is not present on the client root folder create it).
- Go to "Server" directory and copy all the contents from .env.example to .env (if .env file is not present on the client root folder create it).

## Server

Create a database named conx in your local DB.

```bash
cd server

php artisan migrate:fresh --seed
php artisan Populate:company --length=10  --workers=50 --owner=1 --supervisor=1 --projectmanager=1
php artisan serve

```

You can use those email addresses returned by the Populate command (password is 123456789) for loging in 

Open a new terminal window

```bash
cd client

npm run dev
```
_The command above also applies for the Mobile PWA just change he "client" to "mobile"_


## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please don't forget to create your own branch, SOP for updating on the repo should be

```bash
git remote -v //to check list of remotes
git remote add yourremote  https://yourusername@github.com/cmaa14/conx.git
``` 

- Update code on your branch.
- Commit and push.
- Merge to development branch.
- When all updates are ready to go live merge the development branch to live-updates (Discuss with sir Patrick before going on this step).

Please make sure to update tests as appropriate.


## Cron
```bash
sudo crontab -e

sudo chmod +x queues.sh
./queues.sh

``` 
 - crontab -e : Command to view the cron. This is where you can register and update crons.
 - chmod +x : Change the access mode of the file. So that the system has the authority to access it.
 - ./fileName.sh : execute the file. Inside the file are the commands. 
 
 ## QUEUE
```bash
sudo ps -x
sudo kill PID
``` 
 -  ps -x : View the processes running on the background
 -  kill PID : PID (ID of the process), use to kill the process
 
## Manual Update on Cloud Server(Linux)
When error on workflow after pushing to dev-release-conx-client-mobile or dev-release-conx-server repository
Login to the cloud server using putty with your username

### Client
```bash
cd /var/www/conx-workflow/_work/conx/conx/client

sudo chown -R $USER:$USER node_modules
sudo chown -R $USER:$USER package.json
sudo chown -R $USER:$USER package-lock.json
sudo npm install
sudo npm run build
sudo pm2 reload conx-client
```

When theres no namespace "conx-client" create one

```bash
sudo pm2 start npm --name "conx-client" -- start
```

Don't forget to return back to user patrick after you've changed the user of files and directories.

```bash
sudo chown -R patrick101:patrick101 /var/www/conx-workflow
```

### Mobile
```bash
cd /var/www/conx-workflow/_work/conx/conx/mobile

sudo chown -R $USER:$USER node_modules
sudo chown -R $USER:$USER package.json
sudo chown -R $USER:$USER package-lock.json
sudo npm install
sudo npm run build
sudo pm2 reload conx-mobile
```

When theres no namespace "conx-mobile" create one

```bash
sudo pm2 start npm --name "conx-mobile" -- start
```

Don't forget to return back to user patrick after you've changed the user of files and directories.

```bashS
sudo chown -R patrick101:patrick101 /var/www/conx-workflow
```

### Server
Currently the dev server is on /var/www/conx-old/ due to some errors on workflow

```bash
cd /var/www/conx-old/

sudo git remote add yourusername https://github.com/cmaa14/conx.git
sudo git pull yourusername development
```
To exit

```bash
Ctrl + x
```

If the server is not running

```bash
sudo php artisan serve
```


## License
[MIT](https://choosealicense.com/licenses/mit/)
