mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 14:06:15 +00:00
Compare commits
58 Commits
Author | SHA1 | Date | |
---|---|---|---|
9db310a06b | |||
f70963d6bb | |||
b75df8e1c5 | |||
a22e9cb946 | |||
b2b9bea0b1 | |||
3f4a2bce3a | |||
8bffefabef | |||
3da1f4fe4c | |||
2214a76e09 | |||
55bf8b8ecf | |||
0420babdef | |||
1c3d78a5ed | |||
8665435bc4 | |||
0ec6a9dea2 | |||
bdfda05398 | |||
919cdc6892 | |||
902548e463 | |||
2462b31f3b | |||
e997d0deea | |||
f06b8f7d20 | |||
f120a570e8 | |||
2d7f225ff2 | |||
31bd146239 | |||
10a6bb57a8 | |||
fd2244d382 | |||
551f1ce40e | |||
1ce92d9361 | |||
ec6e55e30c | |||
4cda14f4b8 | |||
5e6d338bdc | |||
7312e3f515 | |||
b771db882b | |||
94977797cc | |||
c45872df55 | |||
16fae5334c | |||
7b8deddeca | |||
1bf3c94358 | |||
700cc5f44c | |||
9d13cc0756 | |||
f51d7900f0 | |||
4bd4b34d24 | |||
7c5505be16 | |||
7249cf9ed6 | |||
8282d39722 | |||
38e23a1ceb | |||
1e1204fe40 | |||
7d98986f52 | |||
2c81e324f6 | |||
422da431ec | |||
6c27215ea1 | |||
fb840204ad | |||
e07e197dd9 | |||
3a2dba4ad3 | |||
b990f9ce32 | |||
a6727ff459 | |||
170535760f | |||
648529c3bd | |||
84192b7cb7 |
42
.env.example
42
.env.example
@ -2,7 +2,7 @@ APP_NAME=Vito
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost:2080
|
||||
APP_URL=http://vito.test
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
@ -15,52 +15,24 @@ DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=null
|
||||
CACHE_DRIVER=redis
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=sync
|
||||
QUEUE_CONNECTION=default
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MEMCACHED_HOST=127.0.0.1
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_HOST=
|
||||
MAIL_PORT=
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
FORWARD_REDIS_PORT=2060
|
||||
FORWARD_DB_PORT=2070
|
||||
APP_PORT=2080
|
||||
HMR_PORT=2090
|
||||
|
||||
SENTRY_LARAVEL_DSN=
|
||||
|
||||
APP_SERVICE=vito
|
||||
|
||||
GITHUB_CLIENT_ID=
|
||||
GITHUB_CLIENT_SECRET=
|
||||
|
||||
ABLY_KEY=
|
||||
ABLY_PUBLIC_KEY=
|
||||
SSH_PUBLIC_KEY_NAME=ssh-public.key
|
||||
SSH_PRIVATE_KEY_NAME=ssh-private.pem
|
||||
|
32
.env.prod
32
.env.prod
@ -14,7 +14,7 @@ DB_DATABASE=
|
||||
DB_USERNAME=
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=pusher
|
||||
BROADCAST_DRIVER=null
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=default
|
||||
@ -26,39 +26,13 @@ REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=mailhog
|
||||
MAIL_PORT=1025
|
||||
MAIL_HOST=
|
||||
MAIL_PORT=
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
AWS_ACCESS_KEY_ID=
|
||||
AWS_SECRET_ACCESS_KEY=
|
||||
AWS_DEFAULT_REGION=us-east-1
|
||||
AWS_BUCKET=
|
||||
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
PUSHER_APP_ID=app-id
|
||||
PUSHER_APP_KEY=app-key
|
||||
PUSHER_APP_SECRET=app-secret
|
||||
PUSHER_HOST=soketi
|
||||
PUSHER_PORT=6001
|
||||
PUSHER_SCHEME=http
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
VITE_PUSHER_HOST="${PUSHER_HOST}"
|
||||
VITE_PUSHER_PORT="${PUSHER_PORT}"
|
||||
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
||||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
SSH_PUBLIC_KEY_NAME=ssh-public.key
|
||||
SSH_PRIVATE_KEY_NAME=ssh-private.pem
|
||||
|
||||
GITHUB_CLIENT_ID=
|
||||
GITHUB_CLIENT_SECRET=
|
||||
|
||||
ABLY_KEY=
|
||||
ABLY_PUBLIC_KEY=
|
||||
|
45
.env.sail
Normal file
45
.env.sail
Normal file
@ -0,0 +1,45 @@
|
||||
APP_NAME=Vito
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://vito.test
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=mysql
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=vito
|
||||
DB_USERNAME=sail
|
||||
DB_PASSWORD=password
|
||||
|
||||
BROADCAST_DRIVER=null
|
||||
CACHE_DRIVER=redis
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=default
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
REDIS_HOST=redis
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=
|
||||
MAIL_PORT=
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
SSH_PUBLIC_KEY_NAME=ssh-public.key
|
||||
SSH_PRIVATE_KEY_NAME=ssh-private.pem
|
||||
|
||||
APP_SERVICE=vito
|
||||
|
||||
FORWARD_REDIS_PORT=2060
|
||||
FORWARD_DB_PORT=2070
|
||||
APP_PORT=2080
|
||||
HMR_PORT=2090
|
16
.env.testing
16
.env.testing
@ -14,7 +14,7 @@ DB_DATABASE=vito_test
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=pusher
|
||||
BROADCAST_DRIVER=null
|
||||
CACHE_DRIVER=array
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=database
|
||||
@ -23,19 +23,5 @@ SESSION_LIFETIME=120
|
||||
|
||||
MAIL_MAILER=array
|
||||
|
||||
PUSHER_APP_ID=app-id
|
||||
PUSHER_APP_KEY=app-key
|
||||
PUSHER_APP_SECRET=app-secret
|
||||
PUSHER_HOST=soketi
|
||||
PUSHER_PORT=6001
|
||||
PUSHER_SCHEME=http
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
VITE_PUSHER_HOST="${PUSHER_HOST}"
|
||||
VITE_PUSHER_PORT="${PUSHER_PORT}"
|
||||
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
|
||||
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
SSH_PUBLIC_KEY_NAME=ssh-public.key
|
||||
SSH_PRIVATE_KEY_NAME=ssh-private.pem
|
||||
|
27
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
27
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
12
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
12
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: feature
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
To request a feature or suggest an idea please add it to the feedback boards
|
||||
|
||||
https://features.vitodeploy.com/
|
2
.github/workflows/code-style.yml
vendored
2
.github/workflows/code-style.yml
vendored
@ -8,7 +8,7 @@ on:
|
||||
|
||||
jobs:
|
||||
code-style:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
strategy:
|
||||
fail-fast: true
|
||||
|
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -8,7 +8,7 @@ on:
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
services:
|
||||
mysql:
|
||||
|
23
CONTRIBUTING.md
Normal file
23
CONTRIBUTING.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Contributing
|
||||
Thank you for your interest in contributing! There are a couple of contribution guidelines that make it easier to apply the incoming suggestions.
|
||||
|
||||
If you want to contribute please start with the issues. Issues labeled with "Bug" are the higher priorities.
|
||||
|
||||
## Issues
|
||||
1. Issues are the best place to propose a new feature.
|
||||
2. If you are adding a feature that there is no issue for yet, please first open an issue and label it as "feature" and lets discuss it before you implement it.
|
||||
3. Search the issues before proposing a feature to see if it is already under discussion. Referencing existing issues is a good way to increase the priority of your own.
|
||||
4. We don't have an issue template yet, but the more detailed your explanation, the more quickly we'll be able to evaluate it.
|
||||
5. Search for the issue that you also have. Give it a reaction (and comment, if you have something to add). We note that!
|
||||
|
||||
## Pull Requests
|
||||
1. Open PRs represent issues that we're actively thinking about merging (at a pace we can manage). If we think a proposal needs more discussion, or that the existing code would require a lot of back-and-forth to merge, we might close it and suggest you make an issue.
|
||||
2. All PRs should be made against the `main` branch. This can be changed in the future.
|
||||
3. If you are making changes to the front-end layer, Please build the assets via `npm run build` and push it with the other changes.
|
||||
4. Write tests for your code. Tests can be Unit or Feature.
|
||||
5. Code refactors will be closed. For the architectural refactors open an issue first.
|
||||
6. Use `./vendor/bin/pint` to style your code before opening a PR otherwise the actions will fail.
|
||||
7. Typo fixes in documentation are welcome, but if it's at all debatable we might just close it.
|
||||
|
||||
## Misc
|
||||
1. If you think we closed something incorrectly, feel free to (politely) tell us why! We're human and make mistakes.
|
16
README.md
16
README.md
@ -4,15 +4,29 @@ # Vito
|
||||
|
||||

|
||||
|
||||
[[Discord](https://discord.gg/dcUWA5DV)]
|
||||
|
||||
Better Readme will come soon... :)
|
||||
|
||||
## Documentation
|
||||
|
||||
https://vitodeploy.com
|
||||
|
||||
## Feedbacks
|
||||
|
||||
https://vitodeploy.featurebase.app
|
||||
|
||||
## Roadmap
|
||||
|
||||
https://vitodeploy.featurebase.app/roadmap
|
||||
|
||||
## Contribution
|
||||
|
||||
Feel free to open a PR
|
||||
Please read the contribution guide [Here](/CONTRIBUTING.md)
|
||||
|
||||
## Security
|
||||
|
||||
Please read the security policy [Here](/SECURITY.md)
|
||||
|
||||
## Credits
|
||||
|
||||
|
11
SECURITY.md
Normal file
11
SECURITY.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 0.x | :white_check_mark: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If you see a vulnerability, please open an issue or report it directly to me (sa.vaziry@gmail.com)
|
@ -21,16 +21,25 @@ public function add(User $user, array $input): void
|
||||
'label' => $input['label'],
|
||||
]);
|
||||
$this->validateType($channel, $input);
|
||||
$channel->data = $channel->provider()->data($input);
|
||||
$channel->data = $channel->provider()->createData($input);
|
||||
$channel->save();
|
||||
|
||||
if (! $channel->provider()->connect()) {
|
||||
$channel->delete();
|
||||
|
||||
if ($channel->provider === \App\Enums\NotificationChannel::EMAIL) {
|
||||
throw ValidationException::withMessages([
|
||||
'email' => __('Could not connect! Make sure you configured `.env` file correctly.'),
|
||||
]);
|
||||
}
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'provider' => __('Could not connect'),
|
||||
]);
|
||||
}
|
||||
|
||||
$channel->connected = true;
|
||||
$channel->save();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -49,7 +58,7 @@ protected function validate(array $input): void
|
||||
*/
|
||||
protected function validateType(NotificationChannel $channel, array $input): void
|
||||
{
|
||||
Validator::make($input, $channel->provider()->validationRules())
|
||||
Validator::make($input, $channel->provider()->createRules($input))
|
||||
->validate();
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,12 @@ public function update(Service $service, string $ini): void
|
||||
{
|
||||
$tmpName = Str::random(10).strtotime('now');
|
||||
try {
|
||||
Storage::disk('local')->put($tmpName, $ini);
|
||||
/** @var \Illuminate\Filesystem\FilesystemAdapter $storageDisk */
|
||||
$storageDisk = Storage::disk('local');
|
||||
|
||||
$storageDisk->put($tmpName, $ini);
|
||||
$service->server->ssh('root')->upload(
|
||||
Storage::disk('local')->path($tmpName),
|
||||
$storageDisk->path($tmpName),
|
||||
"/etc/php/$service->version/cli/php.ini"
|
||||
);
|
||||
$this->deleteTempFile($tmpName);
|
||||
|
36
app/Actions/Projects/CreateProject.php
Normal file
36
app/Actions/Projects/CreateProject.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Projects;
|
||||
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class CreateProject
|
||||
{
|
||||
public function create(User $user, array $input): Project
|
||||
{
|
||||
$this->validate($user, $input);
|
||||
|
||||
$project = new Project([
|
||||
'user_id' => $user->id,
|
||||
'name' => $input['name'],
|
||||
]);
|
||||
|
||||
$project->save();
|
||||
|
||||
return $project;
|
||||
}
|
||||
|
||||
private function validate(User $user, array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'name' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
'unique:projects,name,NULL,id,user_id,'.$user->id,
|
||||
],
|
||||
])->validate();
|
||||
}
|
||||
}
|
31
app/Actions/Projects/DeleteProject.php
Normal file
31
app/Actions/Projects/DeleteProject.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Projects;
|
||||
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class DeleteProject
|
||||
{
|
||||
public function delete(User $user, int $projectId): void
|
||||
{
|
||||
/** @var Project $project */
|
||||
$project = $user->projects()->findOrFail($projectId);
|
||||
|
||||
if ($user->projects()->count() === 1) {
|
||||
throw ValidationException::withMessages([
|
||||
'project' => __('Cannot delete the last project.'),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($user->current_project_id == $project->id) {
|
||||
/** @var Project $randomProject */
|
||||
$randomProject = $user->projects()->where('id', '!=', $project->id)->first();
|
||||
$user->current_project_id = $randomProject->id;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
$project->delete();
|
||||
}
|
||||
}
|
33
app/Actions/Projects/UpdateProject.php
Normal file
33
app/Actions/Projects/UpdateProject.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Projects;
|
||||
|
||||
use App\Models\Project;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpdateProject
|
||||
{
|
||||
public function update(Project $project, array $input): Project
|
||||
{
|
||||
$this->validate($project, $input);
|
||||
|
||||
$project->name = $input['name'];
|
||||
|
||||
$project->save();
|
||||
|
||||
return $project;
|
||||
}
|
||||
|
||||
private function validate(Project $project, array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'name' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
Rule::unique('projects')->ignore($project->id),
|
||||
],
|
||||
])->validate();
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@ public function create(User $creator, array $input): Server
|
||||
$this->validateInputs($input);
|
||||
|
||||
$server = new Server([
|
||||
'project_id' => $creator->currentProject->id,
|
||||
'user_id' => $creator->id,
|
||||
'name' => $input['name'],
|
||||
'ssh_user' => config('core.server_providers_default_user')[$input['provider']][$input['os']],
|
||||
@ -43,9 +44,8 @@ public function create(User $creator, array $input): Server
|
||||
'progress_step' => 'Initializing',
|
||||
]);
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
if ($server->provider != 'custom') {
|
||||
$server->provider_id = $input['server_provider'];
|
||||
}
|
||||
@ -118,7 +118,6 @@ private function validateInputs(array $input): void
|
||||
if ($input['provider'] == 'custom') {
|
||||
$rules['ip'] = [
|
||||
'required',
|
||||
'ip',
|
||||
new RestrictedIPAddressesRule(),
|
||||
];
|
||||
$rules['port'] = [
|
||||
|
@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Database;
|
||||
namespace App\Actions\Service;
|
||||
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Models\Server;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
@ -18,23 +19,21 @@ public function install(Server $server, array $input): Service
|
||||
|
||||
$phpMyAdmin = $server->defaultService('phpmyadmin');
|
||||
if ($phpMyAdmin) {
|
||||
if ($phpMyAdmin->status === 'ready') {
|
||||
throw ValidationException::withMessages([
|
||||
'install' => __('Already installed'),
|
||||
])->errorBag('installPHPMyAdmin');
|
||||
}
|
||||
$phpMyAdmin->delete();
|
||||
throw ValidationException::withMessages([
|
||||
'allowed_ip' => __('Already installed'),
|
||||
]);
|
||||
}
|
||||
$phpMyAdmin = new Service([
|
||||
'server_id' => $server->id,
|
||||
'type' => 'phpmyadmin',
|
||||
'type_data' => [
|
||||
'allowed_ip' => $input['allowed_ip'],
|
||||
'port' => $input['port'],
|
||||
'php' => $server->defaultService('php')->version,
|
||||
],
|
||||
'name' => 'phpmyadmin',
|
||||
'version' => '5.1.2',
|
||||
'status' => 'installing',
|
||||
'status' => ServiceStatus::INSTALLING,
|
||||
'is_default' => 1,
|
||||
]);
|
||||
$phpMyAdmin->save();
|
||||
@ -50,6 +49,12 @@ private function validate(array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'allowed_ip' => 'required',
|
||||
])->validateWithBag('installPHPMyAdmin');
|
||||
'port' => [
|
||||
'required',
|
||||
'numeric',
|
||||
'min:1',
|
||||
'max:65535',
|
||||
],
|
||||
])->validate();
|
||||
}
|
||||
}
|
@ -23,9 +23,8 @@ public function create(Server $server, array $input): Site
|
||||
{
|
||||
$this->validateInputs($server, $input);
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
DB::beginTransaction();
|
||||
|
||||
$site = new Site([
|
||||
'server_id' => $server->id,
|
||||
'type' => $input['type'],
|
||||
@ -49,11 +48,6 @@ public function create(Server $server, array $input): Site
|
||||
]);
|
||||
}
|
||||
|
||||
// detect php version
|
||||
if ($site->type()->language() === 'php') {
|
||||
$site->php_version = $input['php_version'];
|
||||
}
|
||||
|
||||
// validate type
|
||||
$this->validateType($site, $input);
|
||||
|
||||
|
35
app/Actions/Site/UpdateSourceControl.php
Executable file
35
app/Actions/Site/UpdateSourceControl.php
Executable file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Site;
|
||||
|
||||
use App\Models\Site;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class UpdateSourceControl
|
||||
{
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function update(Site $site, array $input): void
|
||||
{
|
||||
$this->validate($input);
|
||||
|
||||
$site->source_control_id = $input['source_control'];
|
||||
$site->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function validate(array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'source_control' => [
|
||||
'required',
|
||||
Rule::exists('source_controls', 'id'),
|
||||
],
|
||||
])->validate();
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
namespace App\Actions\SourceControl;
|
||||
|
||||
use App\Models\SourceControl;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
@ -16,6 +17,7 @@ public function connect(array $input): void
|
||||
'provider' => $input['provider'],
|
||||
'profile' => $input['name'],
|
||||
'access_token' => $input['token'],
|
||||
'url' => Arr::has($input, 'url') ? $input['url'] : null,
|
||||
]);
|
||||
|
||||
if (! $sourceControl->provider()->connect()) {
|
||||
@ -44,6 +46,11 @@ private function validate(array $input): void
|
||||
'token' => [
|
||||
'required',
|
||||
],
|
||||
'url' => [
|
||||
'nullable',
|
||||
'url:http,https',
|
||||
'ends_with:/',
|
||||
],
|
||||
];
|
||||
Validator::make($input, $rules)->validate();
|
||||
}
|
||||
|
@ -21,13 +21,15 @@ public function create(User $user, array $input): void
|
||||
'user_id' => $user->id,
|
||||
'provider' => $input['provider'],
|
||||
'profile' => $input['name'],
|
||||
'credentials' => [
|
||||
'token' => $input['token'],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->validateProvider($input, $storageProvider->provider()->validationRules());
|
||||
|
||||
$storageProvider->credentials = $storageProvider->provider()->credentialData($input);
|
||||
|
||||
if (! $storageProvider->provider()->connect()) {
|
||||
throw ValidationException::withMessages([
|
||||
'token' => __("Couldn't connect to the provider"),
|
||||
'provider' => __("Couldn't connect to the provider"),
|
||||
]);
|
||||
}
|
||||
$storageProvider->save();
|
||||
@ -44,9 +46,11 @@ private function validate(User $user, array $input): void
|
||||
'required',
|
||||
Rule::unique('storage_providers', 'profile')->where('user_id', $user->id),
|
||||
],
|
||||
'token' => [
|
||||
'required',
|
||||
],
|
||||
])->validate();
|
||||
}
|
||||
|
||||
private function validateProvider(array $input, array $rules): void
|
||||
{
|
||||
Validator::make($input, $rules)->validate();
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,10 @@ public function update(User $user, array $input): void
|
||||
Validator::make($input, [
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)],
|
||||
'timezone' => [
|
||||
'required',
|
||||
Rule::in(timezone_identifiers_list()),
|
||||
],
|
||||
])->validateWithBag('updateProfileInformation');
|
||||
|
||||
if ($input['email'] !== $user->email) {
|
||||
@ -27,6 +31,7 @@ public function update(User $user, array $input): void
|
||||
$user->forceFill([
|
||||
'name' => $input['name'],
|
||||
'email' => $input['email'],
|
||||
'timezone' => $input['timezone'],
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
@ -39,6 +44,7 @@ protected function updateVerifiedUser(User $user, array $input): void
|
||||
$user->forceFill([
|
||||
'name' => $input['name'],
|
||||
'email' => $input['email'],
|
||||
'timezone' => $input['timezone'],
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
|
@ -2,9 +2,17 @@
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
interface Notification
|
||||
{
|
||||
public function subject(): string;
|
||||
public function rawText(): string;
|
||||
|
||||
public function message(bool $mail = false): mixed;
|
||||
public function toEmail(object $notifiable): MailMessage;
|
||||
|
||||
public function toSlack(object $notifiable): string;
|
||||
|
||||
public function toDiscord(object $notifiable): string;
|
||||
|
||||
public function toTelegram(object $notifiable): string;
|
||||
}
|
||||
|
@ -4,11 +4,13 @@
|
||||
|
||||
interface NotificationChannel
|
||||
{
|
||||
public function validationRules(): array;
|
||||
public function createRules(array $input): array;
|
||||
|
||||
public function data(array $input): array;
|
||||
public function createData(array $input): array;
|
||||
|
||||
public function data(): array;
|
||||
|
||||
public function connect(): bool;
|
||||
|
||||
public function sendMessage(string $subject, string $text): void;
|
||||
public function send(object $notifiable, Notification $notification): void;
|
||||
}
|
||||
|
@ -15,13 +15,13 @@ public function create(
|
||||
?int $siteId = null
|
||||
): void;
|
||||
|
||||
public function delete(int $id, int $siteId = null): void;
|
||||
public function delete(int $id, ?int $siteId = null): void;
|
||||
|
||||
public function restart(int $id, int $siteId = null): void;
|
||||
public function restart(int $id, ?int $siteId = null): void;
|
||||
|
||||
public function stop(int $id, int $siteId = null): void;
|
||||
public function stop(int $id, ?int $siteId = null): void;
|
||||
|
||||
public function start(int $id, int $siteId = null): void;
|
||||
public function start(int $id, ?int $siteId = null): void;
|
||||
|
||||
public function getLogs(string $logPath): string;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public function credentialData(array $input): array;
|
||||
|
||||
public function data(array $input): array;
|
||||
|
||||
public function connect(array $credentials = null): bool;
|
||||
public function connect(?array $credentials = null): bool;
|
||||
|
||||
public function plans(): array;
|
||||
|
||||
|
@ -6,6 +6,8 @@ interface SiteType
|
||||
{
|
||||
public function language(): string;
|
||||
|
||||
public function supportedFeatures(): array;
|
||||
|
||||
public function createValidationRules(array $input): array;
|
||||
|
||||
public function createFields(array $input): array;
|
||||
|
@ -6,7 +6,7 @@ interface SourceControlProvider
|
||||
{
|
||||
public function connect(): bool;
|
||||
|
||||
public function getRepo(string $repo = null): mixed;
|
||||
public function getRepo(?string $repo = null): mixed;
|
||||
|
||||
public function fullRepoUrl(string $repo, string $key): string;
|
||||
|
||||
|
@ -6,6 +6,10 @@
|
||||
|
||||
interface StorageProvider
|
||||
{
|
||||
public function validationRules(): array;
|
||||
|
||||
public function credentialData(array $input): array;
|
||||
|
||||
public function connect(): bool;
|
||||
|
||||
public function upload(Server $server, string $src, string $dest): array;
|
||||
|
@ -9,7 +9,9 @@ interface Webserver
|
||||
{
|
||||
public function createVHost(Site $site): void;
|
||||
|
||||
public function updateVHost(Site $site): void;
|
||||
public function updateVHost(Site $site, bool $noSSL = false, ?string $vhost = null): void;
|
||||
|
||||
public function getVHost(Site $site): string;
|
||||
|
||||
public function deleteSite(Site $site): void;
|
||||
|
||||
|
@ -11,4 +11,6 @@ final class NotificationChannel extends Enum
|
||||
const SLACK = 'slack';
|
||||
|
||||
const DISCORD = 'discord';
|
||||
|
||||
const TELEGRAM = 'telegram';
|
||||
}
|
||||
|
16
app/Enums/SiteFeature.php
Normal file
16
app/Enums/SiteFeature.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class SiteFeature extends Enum
|
||||
{
|
||||
const DEPLOYMENT = 'deployment';
|
||||
|
||||
const ENV = 'env';
|
||||
|
||||
const SSL = 'ssl';
|
||||
|
||||
const QUEUES = 'queues';
|
||||
}
|
@ -8,6 +8,8 @@ final class SiteType extends Enum
|
||||
{
|
||||
const PHP = 'php';
|
||||
|
||||
const PHP_BLANK = 'php-blank';
|
||||
|
||||
const LARAVEL = 'laravel';
|
||||
|
||||
const WORDPRESS = 'wordpress';
|
||||
|
@ -11,6 +11,4 @@ final class SourceControl extends Enum
|
||||
const GITLAB = 'gitlab';
|
||||
|
||||
const BITBUCKET = 'bitbucket';
|
||||
|
||||
const CUSTOM = 'custom';
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
final class StorageProvider extends Enum
|
||||
{
|
||||
const GOOGLE = 'google';
|
||||
|
||||
const DROPBOX = 'dropbox';
|
||||
|
||||
const FTP = 'ftp';
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
class SourceControlIsNotConnected extends Exception
|
||||
{
|
||||
public function __construct(protected SourceControl|string $sourceControl, string $message = null)
|
||||
public function __construct(protected SourceControl|string|null $sourceControl, ?string $message = null)
|
||||
{
|
||||
parent::__construct($message ?? 'Source control is not connected');
|
||||
}
|
||||
|
17
app/Facades/Notifier.php
Normal file
17
app/Facades/Notifier.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Facades;
|
||||
|
||||
use App\Contracts\Notification;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* @method static void send(object $notifiable, Notification $notification)
|
||||
*/
|
||||
class Notifier extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor(): string
|
||||
{
|
||||
return 'notifier';
|
||||
}
|
||||
}
|
19
app/Helpers/Notifier.php
Normal file
19
app/Helpers/Notifier.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Contracts\Notification;
|
||||
use App\Models\NotificationChannel;
|
||||
|
||||
class Notifier
|
||||
{
|
||||
/**
|
||||
* In the future we can send notifications based on the notifiable instance,
|
||||
* For example, If it was a server then we will send the channels specified by that server
|
||||
* For now, we will send all channels.
|
||||
*/
|
||||
public function send(object $notifiable, Notification $notification): void
|
||||
{
|
||||
NotificationChannel::notifyAll($notification);
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ class SSH
|
||||
|
||||
protected PrivateKey $privateKey;
|
||||
|
||||
public function init(Server $server, string $asUser = null): self
|
||||
public function init(Server $server, ?string $asUser = null): self
|
||||
{
|
||||
$this->connection = null;
|
||||
$this->log = null;
|
||||
@ -64,11 +64,15 @@ public function setLog(string $logType, $siteId = null): void
|
||||
*/
|
||||
public function connect(bool $sftp = false): void
|
||||
{
|
||||
$ip = $this->server->ip;
|
||||
if (str($ip)->contains(':')) {
|
||||
$ip = '['.$ip.']';
|
||||
}
|
||||
try {
|
||||
if ($sftp) {
|
||||
$this->connection = new SFTP($this->server->ip, $this->server->port);
|
||||
$this->connection = new SFTP($ip, $this->server->port);
|
||||
} else {
|
||||
$this->connection = new SSH2($this->server->ip, $this->server->port);
|
||||
$this->connection = new SSH2($ip, $this->server->port);
|
||||
}
|
||||
|
||||
$login = $this->connection->login($this->user, $this->privateKey);
|
||||
@ -87,7 +91,7 @@ public function connect(bool $sftp = false): void
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function exec(string|array|SSHCommand $commands, string $log = '', int $siteId = null): string
|
||||
public function exec(string|array|SSHCommand $commands, string $log = '', ?int $siteId = null): string
|
||||
{
|
||||
if ($log) {
|
||||
$this->setLog($log, $siteId);
|
||||
|
@ -32,9 +32,6 @@ public function info(string $message): void
|
||||
|
||||
private function toast(string $type, string $message): void
|
||||
{
|
||||
$this->component->dispatchBrowserEvent('toast', [
|
||||
'type' => $type,
|
||||
'message' => $message,
|
||||
]);
|
||||
$this->component->dispatch('toast', type: $type, message: $message);
|
||||
}
|
||||
}
|
||||
|
42
app/Http/Controllers/GitHookController.php
Normal file
42
app/Http/Controllers/GitHookController.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Exceptions\SourceControlIsNotConnected;
|
||||
use App\Facades\Notifier;
|
||||
use App\Models\GitHook;
|
||||
use App\Notifications\SourceControlDisconnected;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Throwable;
|
||||
|
||||
class GitHookController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request)
|
||||
{
|
||||
if (! $request->input('secret')) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
/** @var GitHook $gitHook */
|
||||
$gitHook = GitHook::query()
|
||||
->where('secret', $request->input('secret'))
|
||||
->firstOrFail();
|
||||
|
||||
foreach ($gitHook->actions as $action) {
|
||||
if ($action == 'deploy') {
|
||||
try {
|
||||
$gitHook->site->deploy();
|
||||
} catch (SourceControlIsNotConnected) {
|
||||
Notifier::send($gitHook->sourceControl, new SourceControlDisconnected($gitHook->sourceControl));
|
||||
} catch (Throwable $e) {
|
||||
Log::error('git-hook-exception', (array) $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
]);
|
||||
}
|
||||
}
|
29
app/Http/Controllers/ProjectController.php
Normal file
29
app/Http/Controllers/ProjectController.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
class ProjectController extends Controller
|
||||
{
|
||||
public function index(): View
|
||||
{
|
||||
return view('projects.index');
|
||||
}
|
||||
|
||||
public function switch($projectId)
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
/** @var Project $project */
|
||||
$project = $user->projects()->findOrFail($projectId);
|
||||
|
||||
$user->current_project_id = $project->id;
|
||||
$user->save();
|
||||
|
||||
return redirect()->route('servers');
|
||||
}
|
||||
}
|
60
app/Http/Livewire/Application/AutoDeployment.php
Normal file
60
app/Http/Livewire/Application/AutoDeployment.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Application;
|
||||
|
||||
use App\Exceptions\SourceControlIsNotConnected;
|
||||
use App\Models\Site;
|
||||
use App\Traits\HasToast;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
use Throwable;
|
||||
|
||||
class AutoDeployment extends Component
|
||||
{
|
||||
use HasToast;
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function enable(): void
|
||||
{
|
||||
if (! $this->site->auto_deployment) {
|
||||
try {
|
||||
$this->site->enableAutoDeployment();
|
||||
|
||||
$this->site->refresh();
|
||||
|
||||
$this->toast()->success(__('Auto deployment has been enabled.'));
|
||||
} catch (SourceControlIsNotConnected) {
|
||||
$this->toast()->error(__('Source control is not connected. Check site\'s settings.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function disable(): void
|
||||
{
|
||||
if ($this->site->auto_deployment) {
|
||||
try {
|
||||
$this->site->disableAutoDeployment();
|
||||
|
||||
$this->site->refresh();
|
||||
|
||||
$this->toast()->success(__('Auto deployment has been disabled.'));
|
||||
} catch (SourceControlIsNotConnected) {
|
||||
$this->toast()->error(__('Source control is not connected. Check site\'s settings.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.application.auto-deployment');
|
||||
}
|
||||
}
|
@ -11,8 +11,8 @@
|
||||
|
||||
class Deploy extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
use HasToast;
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
@ -23,9 +23,9 @@ public function deploy(): void
|
||||
|
||||
$this->toast()->success(__('Deployment started!'));
|
||||
|
||||
$this->emitTo(DeploymentsList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(DeploymentsList::class);
|
||||
|
||||
$this->emitTo(DeploymentScript::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(DeploymentScript::class);
|
||||
} catch (SourceControlIsNotConnected $e) {
|
||||
session()->flash('toast.type', 'error');
|
||||
session()->flash('toast.message', $e->getMessage());
|
||||
|
@ -27,7 +27,8 @@ public function save(): void
|
||||
|
||||
session()->flash('status', 'script-updated');
|
||||
|
||||
$this->emitTo(Deploy::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(Deploy::class);
|
||||
$this->dispatch('$refresh')->to(AutoDeployment::class);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
class DeploymentsList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
use HasCustomPaginationView;
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
@ -22,7 +22,7 @@ public function showLog(int $id): void
|
||||
$deployment = $this->site->deployments()->findOrFail($id);
|
||||
$this->logContent = $deployment->log->content;
|
||||
|
||||
$this->dispatchBrowserEvent('open-modal', 'show-log');
|
||||
$this->dispatch('open-modal', 'show-log');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -27,7 +27,7 @@ public function save(): void
|
||||
|
||||
session()->flash('status', 'updating-env');
|
||||
|
||||
$this->emit(Deploy::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(Deploy::class);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
19
app/Http/Livewire/Application/PhpBlankApp.php
Normal file
19
app/Http/Livewire/Application/PhpBlankApp.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Application;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Livewire\Component;
|
||||
|
||||
class PhpBlankApp extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.application.php-blank-app');
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ public function render(): View
|
||||
$event = Cache::get('broadcast');
|
||||
if ($event) {
|
||||
Cache::forget('broadcast');
|
||||
$this->emit('broadcast', $event);
|
||||
$this->dispatch('broadcast', $event);
|
||||
}
|
||||
|
||||
return view('livewire.broadcast');
|
||||
|
@ -22,9 +22,9 @@ public function create(): void
|
||||
{
|
||||
app(\App\Actions\CronJob\CreateCronJob::class)->create($this->server, $this->all());
|
||||
|
||||
$this->emitTo(CronjobsList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(CronjobsList::class);
|
||||
|
||||
$this->dispatchBrowserEvent('created', true);
|
||||
$this->dispatch('created');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -23,7 +23,7 @@ public function delete(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -45,7 +45,7 @@ public function restore(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('restored', true);
|
||||
$this->dispatch('restored');
|
||||
}
|
||||
|
||||
public function delete(): void
|
||||
@ -55,7 +55,7 @@ public function delete(): void
|
||||
|
||||
$file->delete();
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -40,7 +40,7 @@ public function create(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('backup-created', true);
|
||||
$this->dispatch('backup-created');
|
||||
}
|
||||
|
||||
public function files(int $id): void
|
||||
@ -48,7 +48,7 @@ public function files(int $id): void
|
||||
$backup = Backup::query()->findOrFail($id);
|
||||
$this->backup = $backup;
|
||||
$this->files = $backup->files()->orderByDesc('id')->simplePaginate(1);
|
||||
$this->dispatchBrowserEvent('show-files', true);
|
||||
$this->dispatch('show-files');
|
||||
}
|
||||
|
||||
public function backup(): void
|
||||
@ -57,7 +57,7 @@ public function backup(): void
|
||||
|
||||
$this->files = $this->backup?->files()->orderByDesc('id')->simplePaginate();
|
||||
|
||||
$this->dispatchBrowserEvent('backup-running', true);
|
||||
$this->dispatch('backup-running');
|
||||
}
|
||||
|
||||
public function delete(): void
|
||||
@ -67,7 +67,7 @@ public function delete(): void
|
||||
|
||||
$backup->delete();
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -40,7 +40,7 @@ public function create(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('database-created', true);
|
||||
$this->dispatch('database-created');
|
||||
}
|
||||
|
||||
public function delete(): void
|
||||
@ -52,9 +52,9 @@ public function delete(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->emitTo(DatabaseUserList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(DatabaseUserList::class);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -38,7 +38,7 @@ public function create(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('database-user-created', true);
|
||||
$this->dispatch('database-user-created');
|
||||
}
|
||||
|
||||
public function delete(): void
|
||||
@ -50,9 +50,9 @@ public function delete(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->emitTo(DatabaseList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(DatabaseList::class);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function viewPassword(int $id): void
|
||||
@ -62,7 +62,7 @@ public function viewPassword(int $id): void
|
||||
|
||||
$this->viewPassword = $databaseUser->password;
|
||||
|
||||
$this->dispatchBrowserEvent('open-modal', 'database-user-password');
|
||||
$this->dispatch('open-modal', 'database-user-password');
|
||||
}
|
||||
|
||||
public function showLink(int $id): void
|
||||
@ -73,7 +73,7 @@ public function showLink(int $id): void
|
||||
$this->linkId = $id;
|
||||
$this->link = $databaseUser->databases ?? [];
|
||||
|
||||
$this->dispatchBrowserEvent('open-modal', 'link-database-user');
|
||||
$this->dispatch('open-modal', 'link-database-user');
|
||||
}
|
||||
|
||||
public function link(): void
|
||||
@ -85,7 +85,7 @@ public function link(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('linked', true);
|
||||
$this->dispatch('linked');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -28,9 +28,9 @@ public function create(): void
|
||||
{
|
||||
app(CreateRule::class)->create($this->server, $this->all());
|
||||
|
||||
$this->emitTo(FirewallRulesList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(FirewallRulesList::class);
|
||||
|
||||
$this->dispatchBrowserEvent('created', true);
|
||||
$this->dispatch('created');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -25,7 +25,7 @@ public function delete(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -15,6 +15,10 @@ class AddChannel extends Component
|
||||
|
||||
public string $email;
|
||||
|
||||
public string $bot_token;
|
||||
|
||||
public string $chat_id;
|
||||
|
||||
public function add(): void
|
||||
{
|
||||
app(\App\Actions\NotificationChannels\AddChannel::class)->add(
|
||||
@ -22,9 +26,9 @@ public function add(): void
|
||||
$this->all()
|
||||
);
|
||||
|
||||
$this->emitTo(ChannelsList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(ChannelsList::class);
|
||||
|
||||
$this->dispatchBrowserEvent('added', true);
|
||||
$this->dispatch('added');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -25,7 +25,7 @@ public function delete(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -3,11 +3,13 @@
|
||||
namespace App\Http\Livewire\Php;
|
||||
|
||||
use App\Actions\PHP\InstallNewPHP;
|
||||
use App\Actions\PHP\InstallPHPExtension;
|
||||
use App\Actions\PHP\UpdatePHPIni;
|
||||
use App\Models\Server;
|
||||
use App\Models\Service;
|
||||
use App\SSHCommands\PHP\GetPHPIniCommand;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
use Throwable;
|
||||
@ -24,6 +26,10 @@ class InstalledVersions extends Component
|
||||
|
||||
public string $ini = 'Loading php.ini';
|
||||
|
||||
public ?int $extensionId = null;
|
||||
|
||||
public string $extension = '';
|
||||
|
||||
public function install(string $version): void
|
||||
{
|
||||
app(InstallNewPHP::class)->install($this->server, [
|
||||
@ -35,6 +41,7 @@ public function install(string $version): void
|
||||
|
||||
public function restart(int $id): void
|
||||
{
|
||||
/** @var Service $service */
|
||||
$service = Service::query()->findOrFail($id);
|
||||
$service->restart();
|
||||
|
||||
@ -43,12 +50,13 @@ public function restart(int $id): void
|
||||
|
||||
public function uninstall(): void
|
||||
{
|
||||
/** @var Service $service */
|
||||
$service = Service::query()->findOrFail($this->uninstallId);
|
||||
$service->uninstall();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function loadIni(int $id): void
|
||||
@ -56,6 +64,7 @@ public function loadIni(int $id): void
|
||||
$this->iniId = $id;
|
||||
$this->ini = 'Loading php.ini';
|
||||
|
||||
/** @var Service $service */
|
||||
$service = Service::query()->findOrFail($this->iniId);
|
||||
|
||||
try {
|
||||
@ -67,6 +76,7 @@ public function loadIni(int $id): void
|
||||
|
||||
public function saveIni(): void
|
||||
{
|
||||
/** @var Service $service */
|
||||
$service = Service::query()->findOrFail($this->iniId);
|
||||
|
||||
app(UpdatePHPIni::class)->update($service, $this->all()['ini']);
|
||||
@ -76,10 +86,32 @@ public function saveIni(): void
|
||||
session()->flash('status', 'ini-updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function installExtension(): void
|
||||
{
|
||||
/** @var Service $service */
|
||||
$service = Service::query()->findOrFail($this->extensionId);
|
||||
|
||||
app(InstallPHPExtension::class)->handle($service, [
|
||||
'name' => $this->extension,
|
||||
]);
|
||||
|
||||
session()->flash('status', 'started-installation');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
if ($this->extensionId) {
|
||||
/** @var Service $php */
|
||||
$php = Service::query()->findOrFail($this->extensionId);
|
||||
$installedExtensions = $php->type_data['extensions'] ?? [];
|
||||
}
|
||||
|
||||
return view('livewire.php.installed-versions', [
|
||||
'phps' => $this->server->services()->where('type', 'php')->get(),
|
||||
'installedExtensions' => $installedExtensions ?? [],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,13 @@ class UpdateProfileInformation extends Component
|
||||
|
||||
public string $email;
|
||||
|
||||
public string $timezone;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->name = auth()->user()->name;
|
||||
$this->email = auth()->user()->email;
|
||||
$this->timezone = auth()->user()->timezone;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -30,7 +33,7 @@ public function submit(): void
|
||||
|
||||
session()->flash('status', 'profile-updated');
|
||||
|
||||
$this->emitTo(UserDropdown::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(UserDropdown::class);
|
||||
}
|
||||
|
||||
public function sendVerificationEmail(): void
|
||||
|
37
app/Http/Livewire/Projects/CreateProject.php
Normal file
37
app/Http/Livewire/Projects/CreateProject.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Projects;
|
||||
|
||||
use App\Traits\HasToast;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class CreateProject extends Component
|
||||
{
|
||||
use HasToast;
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public bool $open = false;
|
||||
|
||||
public array $inputs = [];
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
app(\App\Actions\Projects\CreateProject::class)
|
||||
->create(auth()->user(), $this->inputs);
|
||||
|
||||
$this->dispatch('$refresh')->to(ProjectsList::class);
|
||||
|
||||
$this->dispatch('created');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
if (request()->query('create')) {
|
||||
$this->open = true;
|
||||
}
|
||||
|
||||
return view('livewire.projects.create-project');
|
||||
}
|
||||
}
|
37
app/Http/Livewire/Projects/EditProject.php
Normal file
37
app/Http/Livewire/Projects/EditProject.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Projects;
|
||||
|
||||
use App\Actions\Projects\UpdateProject;
|
||||
use App\Models\Project;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class EditProject extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Project $project;
|
||||
|
||||
public array $inputs = [];
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
app(UpdateProject::class)->update($this->project, $this->inputs);
|
||||
|
||||
$this->redirect(route('projects'));
|
||||
}
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->inputs = [
|
||||
'name' => $this->project->name,
|
||||
];
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.projects.edit-project');
|
||||
}
|
||||
}
|
42
app/Http/Livewire/Projects/ProjectsList.php
Normal file
42
app/Http/Livewire/Projects/ProjectsList.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Projects;
|
||||
|
||||
use App\Actions\Projects\DeleteProject;
|
||||
use App\Traits\HasToast;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Livewire\Component;
|
||||
|
||||
class ProjectsList extends Component
|
||||
{
|
||||
use HasToast;
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
protected $listeners = [
|
||||
'$refresh',
|
||||
];
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
try {
|
||||
app(DeleteProject::class)->delete(auth()->user(), $this->deleteId);
|
||||
|
||||
$this->redirect(route('projects'));
|
||||
|
||||
return;
|
||||
} catch (ValidationException $e) {
|
||||
$this->toast()->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.projects.projects-list', [
|
||||
'projects' => auth()->user()->projects()->orderByDesc('id')->get(),
|
||||
]);
|
||||
}
|
||||
}
|
@ -24,9 +24,9 @@ public function create(): void
|
||||
{
|
||||
app(\App\Actions\Queue\CreateQueue::class)->create($this->site, $this->all());
|
||||
|
||||
$this->emitTo(QueuesList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(QueuesList::class);
|
||||
|
||||
$this->dispatchBrowserEvent('created', true);
|
||||
$this->dispatch('created');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -24,7 +24,7 @@ public function delete(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function start(Queue $queue): void
|
||||
|
@ -11,8 +11,8 @@
|
||||
|
||||
class LogsList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
use HasCustomPaginationView;
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public ?int $count = null;
|
||||
|
||||
@ -27,7 +27,7 @@ public function showLog(int $id): void
|
||||
$log = $this->server->logs()->findOrFail($id);
|
||||
$this->logContent = $log->content;
|
||||
|
||||
$this->dispatchBrowserEvent('open-modal', 'show-log');
|
||||
$this->dispatch('open-modal', 'show-log');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -22,9 +22,9 @@ public function connect(): void
|
||||
{
|
||||
app(CreateServerProvider::class)->create(auth()->user(), $this->all());
|
||||
|
||||
$this->emitTo(ProvidersList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(ProvidersList::class);
|
||||
|
||||
$this->dispatchBrowserEvent('connected', true);
|
||||
$this->dispatch('connected');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -25,7 +25,7 @@ public function delete(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -19,9 +19,9 @@ public function add(): void
|
||||
|
||||
$key->deployTo($this->server);
|
||||
|
||||
$this->emitTo(ServerKeysList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(ServerKeysList::class);
|
||||
|
||||
$this->dispatchBrowserEvent('added', true);
|
||||
$this->dispatch('added');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -24,9 +24,9 @@ public function add(): void
|
||||
|
||||
$key->deployTo($this->server);
|
||||
|
||||
$this->emitTo(ServerKeysList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(ServerKeysList::class);
|
||||
|
||||
$this->dispatchBrowserEvent('added', true);
|
||||
$this->dispatch('added');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -28,7 +28,7 @@ public function delete(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Http\Livewire\Servers;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\User;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
@ -13,8 +13,12 @@ class ServersList extends Component
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = auth()->user();
|
||||
$servers = $user->currentProject->servers()->orderByDesc('created_at')->get();
|
||||
|
||||
return view('livewire.servers.servers-list', [
|
||||
'servers' => Server::all(),
|
||||
'servers' => $servers,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public function refreshComponent(array $data): void
|
||||
return;
|
||||
}
|
||||
|
||||
$this->emit('refreshComponent');
|
||||
$this->dispatch('refreshComponent');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
31
app/Http/Livewire/Services/InstallPHPMyAdmin.php
Normal file
31
app/Http/Livewire/Services/InstallPHPMyAdmin.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Services;
|
||||
|
||||
use App\Actions\Service\InstallPHPMyAdmin as InstallPHPMyAdminAction;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class InstallPHPMyAdmin extends Component
|
||||
{
|
||||
public Server $server;
|
||||
|
||||
public string $allowed_ip;
|
||||
|
||||
public string $port = '5433';
|
||||
|
||||
public function install(): void
|
||||
{
|
||||
app(InstallPHPMyAdminAction::class)->install($this->server, $this->all());
|
||||
|
||||
$this->dispatch('started');
|
||||
|
||||
$this->dispatch('$refresh')->to(ServicesList::class);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.services.install-phpmyadmin');
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Livewire\Services;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Service;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
@ -15,6 +16,7 @@ class ServicesList extends Component
|
||||
|
||||
public function stop(int $id): void
|
||||
{
|
||||
/** @var Service $service */
|
||||
$service = $this->server->services()->where('id', $id)->firstOrFail();
|
||||
|
||||
$service->stop();
|
||||
@ -24,6 +26,7 @@ public function stop(int $id): void
|
||||
|
||||
public function start(int $id): void
|
||||
{
|
||||
/** @var Service $service */
|
||||
$service = $this->server->services()->where('id', $id)->firstOrFail();
|
||||
|
||||
$service->start();
|
||||
@ -33,6 +36,7 @@ public function start(int $id): void
|
||||
|
||||
public function restart(int $id): void
|
||||
{
|
||||
/** @var Service $service */
|
||||
$service = $this->server->services()->where('id', $id)->firstOrFail();
|
||||
|
||||
$service->restart();
|
||||
@ -40,6 +44,16 @@ public function restart(int $id): void
|
||||
$this->refreshComponent([]);
|
||||
}
|
||||
|
||||
public function uninstall(int $id): void
|
||||
{
|
||||
/** @var Service $service */
|
||||
$service = $this->server->services()->where('id', $id)->firstOrFail();
|
||||
|
||||
$service->uninstall();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.services.services-list', [
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Livewire\Sites;
|
||||
|
||||
use App\Enums\SiteType;
|
||||
use App\Exceptions\SourceControlIsNotConnected;
|
||||
use App\Models\Server;
|
||||
use App\Models\SourceControl;
|
||||
@ -16,23 +15,12 @@ class CreateSite extends Component
|
||||
|
||||
public Server $server;
|
||||
|
||||
public string $type = SiteType::LARAVEL;
|
||||
|
||||
public string $domain;
|
||||
|
||||
public string $alias;
|
||||
|
||||
public string $php_version = '';
|
||||
|
||||
public string $web_directory = 'public';
|
||||
|
||||
public string $source_control = '';
|
||||
|
||||
public string $repository;
|
||||
|
||||
public string $branch;
|
||||
|
||||
public bool $composer;
|
||||
public array $inputs = [
|
||||
'type' => '',
|
||||
'web_directory' => 'public',
|
||||
'source_control' => '',
|
||||
'php_version' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* @throws SourceControlIsNotConnected
|
||||
@ -41,7 +29,7 @@ public function create(): void
|
||||
{
|
||||
$site = app(\App\Actions\Site\CreateSite::class)->create(
|
||||
$this->server,
|
||||
$this->all()
|
||||
$this->inputs
|
||||
);
|
||||
|
||||
$this->redirect(route('servers.sites.show', [
|
||||
|
@ -26,7 +26,7 @@ public function refreshComponent(array $data): void
|
||||
return;
|
||||
}
|
||||
|
||||
$this->emit('refreshComponent');
|
||||
$this->dispatch('refreshComponent');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
33
app/Http/Livewire/Sites/UpdateSourceControlProvider.php
Normal file
33
app/Http/Livewire/Sites/UpdateSourceControlProvider.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Sites;
|
||||
|
||||
use App\Actions\Site\UpdateSourceControl;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class UpdateSourceControlProvider extends Component
|
||||
{
|
||||
public Site $site;
|
||||
|
||||
public $source_control = null;
|
||||
|
||||
public function update(): void
|
||||
{
|
||||
app(UpdateSourceControl::class)->update($this->site, $this->all());
|
||||
|
||||
$this->resetErrorBag();
|
||||
|
||||
session()->flash('status', 'source-control-updated');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
if (! $this->source_control) {
|
||||
$this->source_control = $this->site->source_control_id;
|
||||
}
|
||||
|
||||
return view('livewire.sites.update-source-control-provider');
|
||||
}
|
||||
}
|
41
app/Http/Livewire/Sites/UpdateVHost.php
Normal file
41
app/Http/Livewire/Sites/UpdateVHost.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Sites;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Traits\HasToast;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
use Throwable;
|
||||
|
||||
class UpdateVHost extends Component
|
||||
{
|
||||
use HasToast;
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public string $vHost = 'Loading...';
|
||||
|
||||
public function loadVHost(): void
|
||||
{
|
||||
$this->vHost = $this->site->server->webserver()->handler()->getVHost($this->site);
|
||||
}
|
||||
|
||||
public function update(): void
|
||||
{
|
||||
try {
|
||||
$this->site->server->webserver()->handler()->updateVHost($this->site, false, $this->vHost);
|
||||
|
||||
$this->toast()->success('VHost updated successfully!');
|
||||
} catch (Throwable $e) {
|
||||
$this->toast()->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.sites.update-v-host');
|
||||
}
|
||||
}
|
@ -20,9 +20,9 @@ public function connect(): void
|
||||
{
|
||||
app(ConnectSourceControl::class)->connect($this->all());
|
||||
|
||||
$this->emitTo(SourceControlsList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(SourceControlsList::class);
|
||||
|
||||
$this->dispatchBrowserEvent('connected', true);
|
||||
$this->dispatch('connected');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -25,7 +25,7 @@ public function delete(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -19,9 +19,9 @@ public function add(): void
|
||||
$this->all()
|
||||
);
|
||||
|
||||
$this->emitTo(KeysList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(KeysList::class);
|
||||
|
||||
$this->dispatchBrowserEvent('added', true);
|
||||
$this->dispatch('added');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -25,7 +25,7 @@ public function delete(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -23,9 +23,9 @@ public function create(): void
|
||||
{
|
||||
app(\App\Actions\SSL\CreateSSL::class)->create($this->site, $this->all());
|
||||
|
||||
$this->emitTo(SslsList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(SslsList::class);
|
||||
|
||||
$this->dispatchBrowserEvent('created', true);
|
||||
$this->dispatch('created');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
class SslsList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
use HasToast;
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
@ -25,7 +25,7 @@ public function delete(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function refreshComponent(array $data): void
|
||||
@ -34,7 +34,7 @@ public function refreshComponent(array $data): void
|
||||
$this->toast()->error(__('SSL creation failed!'));
|
||||
}
|
||||
|
||||
$this->emit('refreshComponent');
|
||||
$this->dispatch('refreshComponent');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -14,13 +14,27 @@ class ConnectProvider extends Component
|
||||
|
||||
public string $token;
|
||||
|
||||
public string $host;
|
||||
|
||||
public string $port;
|
||||
|
||||
public string $path = '/';
|
||||
|
||||
public string $username;
|
||||
|
||||
public string $password;
|
||||
|
||||
public int $ssl = 1;
|
||||
|
||||
public int $passive = 0;
|
||||
|
||||
public function connect(): void
|
||||
{
|
||||
app(CreateStorageProvider::class)->create(auth()->user(), $this->all());
|
||||
|
||||
$this->emitTo(ProvidersList::class, '$refresh');
|
||||
$this->dispatch('$refresh')->to(ProvidersList::class);
|
||||
|
||||
$this->dispatchBrowserEvent('connected', true);
|
||||
$this->dispatch('connected');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -25,7 +25,7 @@ public function delete(): void
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
$this->dispatch('confirmed');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
|
@ -13,7 +13,7 @@ class Initialize extends InstallationJob
|
||||
|
||||
protected ?string $asUser;
|
||||
|
||||
public function __construct(Server $server, string $asUser = null)
|
||||
public function __construct(Server $server, ?string $asUser = null)
|
||||
{
|
||||
$this->server = $server->refresh();
|
||||
$this->asUser = $asUser;
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Jobs\Installation;
|
||||
|
||||
use App\Actions\FirewallRule\CreateRule;
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Jobs\Job;
|
||||
use App\Models\FirewallRule;
|
||||
use App\Models\Service;
|
||||
@ -32,6 +33,9 @@ public function handle(): void
|
||||
$this->downloadSource();
|
||||
$this->setUpVHost();
|
||||
$this->restartPHP();
|
||||
$this->service->update([
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,7 +45,7 @@ private function setUpFirewall(): void
|
||||
{
|
||||
$this->firewallRule = FirewallRule::query()
|
||||
->where('server_id', $this->service->server_id)
|
||||
->where('port', '54331')
|
||||
->where('port', $this->service->type_data['port'])
|
||||
->first();
|
||||
if ($this->firewallRule) {
|
||||
$this->firewallRule->source = $this->service->type_data['allowed_ip'];
|
||||
@ -52,7 +56,7 @@ private function setUpFirewall(): void
|
||||
[
|
||||
'type' => 'allow',
|
||||
'protocol' => 'tcp',
|
||||
'port' => '54331',
|
||||
'port' => $this->service->type_data['port'],
|
||||
'source' => $this->service->type_data['allowed_ip'],
|
||||
'mask' => '0',
|
||||
]
|
||||
@ -78,6 +82,7 @@ private function setUpVHost(): void
|
||||
{
|
||||
$vhost = File::get(resource_path('commands/webserver/nginx/phpmyadmin-vhost.conf'));
|
||||
$vhost = Str::replace('__php_version__', $this->service->server->defaultService('php')->version, $vhost);
|
||||
$vhost = Str::replace('__port__', $this->service->type_data['port'], $vhost);
|
||||
$this->service->server->ssh()->exec(
|
||||
new CreateNginxPHPMyAdminVHostCommand($vhost),
|
||||
'create-phpmyadmin-vhost'
|
||||
@ -98,6 +103,9 @@ private function restartPHP(): void
|
||||
public function failed(Throwable $throwable): Throwable
|
||||
{
|
||||
$this->firewallRule?->removeFromServer();
|
||||
$this->service->update([
|
||||
'status' => ServiceStatus::INSTALLATION_FAILED,
|
||||
]);
|
||||
throw $throwable;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ private function removeFirewallRule(): void
|
||||
/** @var ?FirewallRule $rule */
|
||||
$rule = FirewallRule::query()
|
||||
->where('server_id', $this->service->server_id)
|
||||
->where('port', '54331')
|
||||
->where('port', $this->service->type_data['port'])
|
||||
->first();
|
||||
$rule?->removeFromServer();
|
||||
}
|
||||
|
@ -3,13 +3,12 @@
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
abstract class Job implements ShouldQueue, ShouldBeUnique
|
||||
abstract class Job implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
}
|
||||
|
@ -3,8 +3,10 @@
|
||||
namespace App\Jobs\Server;
|
||||
|
||||
use App\Events\Broadcast;
|
||||
use App\Facades\Notifier;
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Server;
|
||||
use App\Notifications\ServerDisconnected;
|
||||
use Throwable;
|
||||
|
||||
class CheckConnection extends Job
|
||||
@ -39,7 +41,7 @@ public function failed(): void
|
||||
{
|
||||
$this->server->status = 'disconnected';
|
||||
$this->server->save();
|
||||
/** @todo notify */
|
||||
Notifier::send($this->server, new ServerDisconnected($this->server));
|
||||
event(
|
||||
new Broadcast('server-status-failed', [
|
||||
'server' => $this->server,
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
use App\Enums\DeploymentStatus;
|
||||
use App\Events\Broadcast;
|
||||
use App\Helpers\SSH;
|
||||
use App\Jobs\Job;
|
||||
use App\Models\Deployment;
|
||||
use App\SSHCommands\System\RunScriptCommand;
|
||||
@ -18,13 +17,11 @@ class Deploy extends Job
|
||||
|
||||
protected string $script;
|
||||
|
||||
protected SSH $ssh;
|
||||
|
||||
public function __construct(Deployment $deployment, string $path, string $script)
|
||||
public function __construct(Deployment $deployment, string $path)
|
||||
{
|
||||
$this->script = $deployment->deploymentScript->content;
|
||||
$this->deployment = $deployment;
|
||||
$this->path = $path;
|
||||
$this->script = $script;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,28 +29,31 @@ public function __construct(Deployment $deployment, string $path, string $script
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->ssh = $this->deployment->site->server->ssh();
|
||||
$this->ssh->exec(
|
||||
new RunScriptCommand($this->path, $this->script),
|
||||
'deploy',
|
||||
$this->deployment->site_id
|
||||
);
|
||||
$this->deployment->status = DeploymentStatus::FINISHED;
|
||||
$this->deployment->log_id = $this->ssh->log->id;
|
||||
$this->deployment->save();
|
||||
event(
|
||||
new Broadcast('deploy-site-finished', [
|
||||
'deployment' => $this->deployment,
|
||||
])
|
||||
);
|
||||
$ssh = $this->deployment->site->server->ssh();
|
||||
try {
|
||||
$ssh->exec(
|
||||
new RunScriptCommand($this->path, $this->script),
|
||||
'deploy',
|
||||
$this->deployment->site_id
|
||||
);
|
||||
$this->deployment->status = DeploymentStatus::FINISHED;
|
||||
$this->deployment->log_id = $ssh->log->id;
|
||||
$this->deployment->save();
|
||||
event(
|
||||
new Broadcast('deploy-site-finished', [
|
||||
'deployment' => $this->deployment,
|
||||
])
|
||||
);
|
||||
} catch (Throwable) {
|
||||
$this->deployment->log_id = $ssh->log->id;
|
||||
$this->deployment->save();
|
||||
$this->failed();
|
||||
}
|
||||
}
|
||||
|
||||
public function failed(): void
|
||||
{
|
||||
$this->deployment->status = DeploymentStatus::FAILED;
|
||||
if ($this->ssh->log) {
|
||||
$this->deployment->log_id = $this->ssh->log->id;
|
||||
}
|
||||
$this->deployment->save();
|
||||
event(
|
||||
new Broadcast('deploy-site-failed', [
|
||||
|
@ -52,7 +52,7 @@ public function handle(): void
|
||||
$this->site->id
|
||||
);
|
||||
|
||||
if (! Str::contains($result, 'Wordpress installed!')) {
|
||||
if (! Str::contains($result, 'Success')) {
|
||||
throw new FailedToInstallWordpress($result);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public function __construct()
|
||||
|
||||
public function handle(Broadcast $event): void
|
||||
{
|
||||
Cache::set('broadcast', [
|
||||
Cache::put('broadcast', [
|
||||
'type' => $event->type,
|
||||
'data' => $event->data,
|
||||
], now()->addMinutes(5));
|
||||
|
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class NotificationChannelMessage extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
public $text;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($subject, $text)
|
||||
{
|
||||
$this->subject = $subject;
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
if ($this->text instanceof MailMessage) {
|
||||
return $this->markdown('vendor.notifications.email', $this->text->data());
|
||||
}
|
||||
|
||||
return $this->markdown('emails.notification-channel-message', [
|
||||
'subject' => $this->subject,
|
||||
'text' => $this->text,
|
||||
]);
|
||||
}
|
||||
}
|
25
app/Mail/NotificationMail.php
Normal file
25
app/Mail/NotificationMail.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class NotificationMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public string $text;
|
||||
|
||||
public function __construct(string $subject, string $text)
|
||||
{
|
||||
$this->subject = $subject;
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
public function build(): self
|
||||
{
|
||||
return $this->html($this->text);
|
||||
}
|
||||
}
|
@ -76,7 +76,7 @@ public function getPathAttribute(): string
|
||||
|
||||
public function getStoragePathAttribute(): string
|
||||
{
|
||||
return '/'.$this->backup->database->name.'/'.$this->name.'.zip';
|
||||
return '/'.$this->name.'.zip';
|
||||
}
|
||||
|
||||
public function restore(Database $database): void
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user