mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
init
This commit is contained in:
48
app/Http/Controllers/Auth/AuthenticatedSessionController.php
Normal file
48
app/Http/Controllers/Auth/AuthenticatedSessionController.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Auth\LoginRequest;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class AuthenticatedSessionController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the login view.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('auth.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming authentication request.
|
||||
*/
|
||||
public function store(LoginRequest $request): RedirectResponse
|
||||
{
|
||||
$request->authenticate();
|
||||
|
||||
$request->session()->regenerate();
|
||||
|
||||
return redirect()->intended(RouteServiceProvider::HOME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy an authenticated session.
|
||||
*/
|
||||
public function destroy(Request $request): RedirectResponse
|
||||
{
|
||||
Auth::guard('web')->logout();
|
||||
|
||||
$request->session()->invalidate();
|
||||
|
||||
$request->session()->regenerateToken();
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
41
app/Http/Controllers/Auth/ConfirmablePasswordController.php
Normal file
41
app/Http/Controllers/Auth/ConfirmablePasswordController.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class ConfirmablePasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show the confirm password view.
|
||||
*/
|
||||
public function show(): View
|
||||
{
|
||||
return view('auth.confirm-password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm the user's password.
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
if (! Auth::guard('web')->validate([
|
||||
'email' => $request->user()->email,
|
||||
'password' => $request->password,
|
||||
])) {
|
||||
throw ValidationException::withMessages([
|
||||
'password' => __('auth.password'),
|
||||
]);
|
||||
}
|
||||
|
||||
$request->session()->put('auth.password_confirmed_at', time());
|
||||
|
||||
return redirect()->intended(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
61
app/Http/Controllers/Auth/NewPasswordController.php
Normal file
61
app/Http/Controllers/Auth/NewPasswordController.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Auth\Events\PasswordReset;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rules;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class NewPasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the password reset view.
|
||||
*/
|
||||
public function create(Request $request): View
|
||||
{
|
||||
return view('auth.reset-password', ['request' => $request]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming new password request.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'token' => ['required'],
|
||||
'email' => ['required', 'email'],
|
||||
'password' => ['required', 'confirmed', Rules\Password::defaults()],
|
||||
]);
|
||||
|
||||
// Here we will attempt to reset the user's password. If it is successful we
|
||||
// will update the password on an actual user model and persist it to the
|
||||
// database. Otherwise we will parse the error and return the response.
|
||||
$status = Password::reset(
|
||||
$request->only('email', 'password', 'password_confirmation', 'token'),
|
||||
function ($user) use ($request) {
|
||||
$user->forceFill([
|
||||
'password' => Hash::make($request->password),
|
||||
'remember_token' => Str::random(60),
|
||||
])->save();
|
||||
|
||||
event(new PasswordReset($user));
|
||||
}
|
||||
);
|
||||
|
||||
// If the password was successfully reset, we will redirect the user back to
|
||||
// the application's home authenticated view. If there is an error we can
|
||||
// redirect them back to where they came from with their error message.
|
||||
return $status == Password::PASSWORD_RESET
|
||||
? redirect()->route('login')->with('status', __($status))
|
||||
: back()->withInput($request->only('email'))
|
||||
->withErrors(['email' => __($status)]);
|
||||
}
|
||||
}
|
29
app/Http/Controllers/Auth/PasswordController.php
Normal file
29
app/Http/Controllers/Auth/PasswordController.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
|
||||
class PasswordController extends Controller
|
||||
{
|
||||
/**
|
||||
* Update the user's password.
|
||||
*/
|
||||
public function update(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validateWithBag('updatePassword', [
|
||||
'current_password' => ['required', 'current_password'],
|
||||
'password' => ['required', Password::defaults(), 'confirmed'],
|
||||
]);
|
||||
|
||||
$request->user()->update([
|
||||
'password' => Hash::make($validated['password']),
|
||||
]);
|
||||
|
||||
return back()->with('status', 'password-updated');
|
||||
}
|
||||
}
|
44
app/Http/Controllers/Auth/PasswordResetLinkController.php
Normal file
44
app/Http/Controllers/Auth/PasswordResetLinkController.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Password;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class PasswordResetLinkController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the password reset link request view.
|
||||
*/
|
||||
public function create(): View
|
||||
{
|
||||
return view('auth.forgot-password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming password reset link request.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'email' => ['required', 'email'],
|
||||
]);
|
||||
|
||||
// We will send the password reset link to this user. Once we have attempted
|
||||
// to send the link, we will examine the response then see the message we
|
||||
// need to show to the user. Finally, we'll send out a proper response.
|
||||
$status = Password::sendResetLink(
|
||||
$request->only('email')
|
||||
);
|
||||
|
||||
return $status == Password::RESET_LINK_SENT
|
||||
? back()->with('status', __($status))
|
||||
: back()->withInput($request->only('email'))
|
||||
->withErrors(['email' => __($status)]);
|
||||
}
|
||||
}
|
12
app/Http/Controllers/Controller.php
Normal file
12
app/Http/Controllers/Controller.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, ValidatesRequests;
|
||||
}
|
15
app/Http/Controllers/CronjobController.php
Normal file
15
app/Http/Controllers/CronjobController.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Server;
|
||||
|
||||
class CronjobController extends Controller
|
||||
{
|
||||
public function index(Server $server)
|
||||
{
|
||||
return view('cronjobs.index', [
|
||||
'server' => $server,
|
||||
]);
|
||||
}
|
||||
}
|
15
app/Http/Controllers/DaemonController.php
Normal file
15
app/Http/Controllers/DaemonController.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Server;
|
||||
|
||||
class DaemonController extends Controller
|
||||
{
|
||||
public function index(Server $server)
|
||||
{
|
||||
return view('daemons.index', [
|
||||
'server' => $server,
|
||||
]);
|
||||
}
|
||||
}
|
15
app/Http/Controllers/DatabaseController.php
Normal file
15
app/Http/Controllers/DatabaseController.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Server;
|
||||
|
||||
class DatabaseController extends Controller
|
||||
{
|
||||
public function index(Server $server)
|
||||
{
|
||||
return view('databases.index', [
|
||||
'server' => $server,
|
||||
]);
|
||||
}
|
||||
}
|
15
app/Http/Controllers/FirewallController.php
Normal file
15
app/Http/Controllers/FirewallController.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Server;
|
||||
|
||||
class FirewallController extends Controller
|
||||
{
|
||||
public function index(Server $server)
|
||||
{
|
||||
return view('firewall.index', [
|
||||
'server' => $server,
|
||||
]);
|
||||
}
|
||||
}
|
15
app/Http/Controllers/PHPController.php
Normal file
15
app/Http/Controllers/PHPController.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Server;
|
||||
|
||||
class PHPController extends Controller
|
||||
{
|
||||
public function index(Server $server)
|
||||
{
|
||||
return view('php.index', [
|
||||
'server' => $server,
|
||||
]);
|
||||
}
|
||||
}
|
15
app/Http/Controllers/SSHKeyController.php
Normal file
15
app/Http/Controllers/SSHKeyController.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Server;
|
||||
|
||||
class SSHKeyController extends Controller
|
||||
{
|
||||
public function index(Server $server)
|
||||
{
|
||||
return view('server-ssh-keys.index', [
|
||||
'server' => $server,
|
||||
]);
|
||||
}
|
||||
}
|
28
app/Http/Controllers/ServerController.php
Normal file
28
app/Http/Controllers/ServerController.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Server;
|
||||
|
||||
class ServerController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('servers.index');
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('servers.create');
|
||||
}
|
||||
|
||||
public function show(Server $server)
|
||||
{
|
||||
return view('servers.show', compact('server'));
|
||||
}
|
||||
|
||||
public function logs(Server $server)
|
||||
{
|
||||
return view('servers.logs', compact('server'));
|
||||
}
|
||||
}
|
13
app/Http/Controllers/ServerSettingController.php
Normal file
13
app/Http/Controllers/ServerSettingController.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Server;
|
||||
|
||||
class ServerSettingController extends Controller
|
||||
{
|
||||
public function index(Server $server)
|
||||
{
|
||||
return view('server-settings.index', compact('server'));
|
||||
}
|
||||
}
|
15
app/Http/Controllers/ServiceController.php
Normal file
15
app/Http/Controllers/ServiceController.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Server;
|
||||
|
||||
class ServiceController extends Controller
|
||||
{
|
||||
public function index(Server $server)
|
||||
{
|
||||
return view('services.index', [
|
||||
'server' => $server,
|
||||
]);
|
||||
}
|
||||
}
|
72
app/Http/Controllers/SiteController.php
Normal file
72
app/Http/Controllers/SiteController.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Site;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
class SiteController extends Controller
|
||||
{
|
||||
public function index(Server $server): View
|
||||
{
|
||||
return view('sites.index', [
|
||||
'server' => $server,
|
||||
]);
|
||||
}
|
||||
|
||||
public function create(Server $server): View
|
||||
{
|
||||
return view('sites.create', [
|
||||
'server' => $server,
|
||||
]);
|
||||
}
|
||||
|
||||
public function show(Server $server, Site $site): View
|
||||
{
|
||||
return view('sites.show', [
|
||||
'server' => $server,
|
||||
'site' => $site,
|
||||
]);
|
||||
}
|
||||
|
||||
public function application(Server $server, Site $site): View
|
||||
{
|
||||
return view('sites.application', [
|
||||
'server' => $server,
|
||||
'site' => $site,
|
||||
]);
|
||||
}
|
||||
|
||||
public function ssl(Server $server, Site $site): View
|
||||
{
|
||||
return view('sites.ssl', [
|
||||
'server' => $server,
|
||||
'site' => $site,
|
||||
]);
|
||||
}
|
||||
|
||||
public function queues(Server $server, Site $site): View
|
||||
{
|
||||
return view('sites.queues', [
|
||||
'server' => $server,
|
||||
'site' => $site,
|
||||
]);
|
||||
}
|
||||
|
||||
public function settings(Server $server, Site $site): View
|
||||
{
|
||||
return view('sites.settings', [
|
||||
'server' => $server,
|
||||
'site' => $site,
|
||||
]);
|
||||
}
|
||||
|
||||
public function logs(Server $server, Site $site): View
|
||||
{
|
||||
return view('sites.logs', [
|
||||
'server' => $server,
|
||||
'site' => $site,
|
||||
]);
|
||||
}
|
||||
}
|
67
app/Http/Kernel.php
Normal file
67
app/Http/Kernel.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's middleware aliases.
|
||||
*
|
||||
* Aliases may be used to conveniently assign middleware to routes and groups.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $middlewareAliases = [
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
];
|
||||
}
|
35
app/Http/Livewire/Application/ChangeBranch.php
Normal file
35
app/Http/Livewire/Application/ChangeBranch.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Application;
|
||||
|
||||
use App\Actions\Site\UpdateBranch;
|
||||
use App\Models\Site;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ChangeBranch extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public string $branch;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->branch = $this->site->branch;
|
||||
}
|
||||
|
||||
public function change(): void
|
||||
{
|
||||
app(UpdateBranch::class)->update($this->site, $this->all());
|
||||
|
||||
session()->flash('status', 'updating-branch');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.application.change-branch');
|
||||
}
|
||||
}
|
40
app/Http/Livewire/Application/Deploy.php
Normal file
40
app/Http/Livewire/Application/Deploy.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?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;
|
||||
|
||||
class Deploy extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
use HasToast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public function deploy(): void
|
||||
{
|
||||
try {
|
||||
$this->site->deploy();
|
||||
|
||||
$this->toast()->success(__('Deployment started!'));
|
||||
|
||||
$this->emitTo(DeploymentsList::class, '$refresh');
|
||||
|
||||
$this->emitTo(DeploymentScript::class, '$refresh');
|
||||
} catch (SourceControlIsNotConnected $e) {
|
||||
session()->flash('toast.type', 'error');
|
||||
session()->flash('toast.message', $e->getMessage());
|
||||
$this->redirect(route('source-controls'));
|
||||
}
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.application.deploy');
|
||||
}
|
||||
}
|
37
app/Http/Livewire/Application/DeploymentScript.php
Normal file
37
app/Http/Livewire/Application/DeploymentScript.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Application;
|
||||
|
||||
use App\Actions\Site\UpdateDeploymentScript;
|
||||
use App\Models\Site;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class DeploymentScript extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public string $script;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->script = $this->site->deploymentScript->content;
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
{
|
||||
app(UpdateDeploymentScript::class)->update($this->site, $this->all());
|
||||
|
||||
session()->flash('status', 'script-updated');
|
||||
|
||||
$this->emit(Deploy::class, '$refresh');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.application.deployment-script');
|
||||
}
|
||||
}
|
34
app/Http/Livewire/Application/DeploymentsList.php
Normal file
34
app/Http/Livewire/Application/DeploymentsList.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Application;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Traits\HasCustomPaginationView;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class DeploymentsList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
use HasCustomPaginationView;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public string $logContent;
|
||||
|
||||
public function showLog(int $id): void
|
||||
{
|
||||
$deployment = $this->site->deployments()->findOrFail($id);
|
||||
$this->logContent = $deployment->log->content;
|
||||
|
||||
$this->dispatchBrowserEvent('open-modal', 'show-log');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.application.deployments-list', [
|
||||
'deployments' => $this->site->deployments()->latest()->simplePaginate(10),
|
||||
]);
|
||||
}
|
||||
}
|
20
app/Http/Livewire/Application/LaravelApp.php
Normal file
20
app/Http/Livewire/Application/LaravelApp.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Application;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class LaravelApp extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.application.laravel-app');
|
||||
}
|
||||
}
|
20
app/Http/Livewire/Application/PhpApp.php
Normal file
20
app/Http/Livewire/Application/PhpApp.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Application;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class PhpApp extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.application.php-app');
|
||||
}
|
||||
}
|
20
app/Http/Livewire/Application/WordpressApp.php
Normal file
20
app/Http/Livewire/Application/WordpressApp.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Application;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class WordpressApp extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.application.wordpress-app');
|
||||
}
|
||||
}
|
34
app/Http/Livewire/Cronjobs/CreateCronjob.php
Normal file
34
app/Http/Livewire/Cronjobs/CreateCronjob.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Cronjobs;
|
||||
|
||||
use App\Models\Server;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class CreateCronjob extends Component
|
||||
{
|
||||
public Server $server;
|
||||
|
||||
public string $user = '';
|
||||
|
||||
public string $command;
|
||||
|
||||
public string $frequency = '';
|
||||
|
||||
public string $custom;
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
app(\App\Actions\CronJob\CreateCronJob::class)->create($this->server, $this->all());
|
||||
|
||||
$this->emitTo(CronjobsList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('created', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.cronjobs.create-cronjob');
|
||||
}
|
||||
}
|
35
app/Http/Livewire/Cronjobs/CronjobsList.php
Normal file
35
app/Http/Livewire/Cronjobs/CronjobsList.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Cronjobs;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class CronjobsList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$cronjob = $this->server->cronJobs()->where('id', $this->deleteId)->firstOrFail();
|
||||
|
||||
$cronjob->removeFromServer();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.cronjobs.cronjobs-list', [
|
||||
'cronjobs' => $this->server->cronJobs,
|
||||
]);
|
||||
}
|
||||
}
|
65
app/Http/Livewire/Databases/DatabaseList.php
Normal file
65
app/Http/Livewire/Databases/DatabaseList.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Databases;
|
||||
|
||||
use App\Actions\Database\CreateDatabase;
|
||||
use App\Actions\Database\CreateDatabaseUser;
|
||||
use App\Models\Database;
|
||||
use App\Models\Server;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class DatabaseList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
public string $name;
|
||||
|
||||
public bool $user;
|
||||
|
||||
public string $username;
|
||||
|
||||
public string $password;
|
||||
|
||||
public bool $remote = false;
|
||||
|
||||
public string $host = '%';
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
app(CreateDatabase::class)->create($this->server, $this->all());
|
||||
|
||||
if ($this->all()['user']) {
|
||||
app(CreateDatabaseUser::class)->create($this->server, $this->all());
|
||||
}
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('database-created', true);
|
||||
}
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$database = Database::query()->findOrFail($this->deleteId);
|
||||
|
||||
$database->deleteFromServer();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->emitTo(DatabaseUserList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.databases.database-list', [
|
||||
'databases' => $this->server->databases,
|
||||
]);
|
||||
}
|
||||
}
|
94
app/Http/Livewire/Databases/DatabaseUserList.php
Normal file
94
app/Http/Livewire/Databases/DatabaseUserList.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Databases;
|
||||
|
||||
use App\Actions\Database\CreateDatabaseUser;
|
||||
use App\Actions\Database\LinkUser;
|
||||
use App\Models\DatabaseUser;
|
||||
use App\Models\Server;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class DatabaseUserList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
public string $username;
|
||||
|
||||
public string $password;
|
||||
|
||||
public bool $remote;
|
||||
|
||||
public string $host = '%';
|
||||
|
||||
public int $linkId;
|
||||
|
||||
public array $link = [];
|
||||
|
||||
public string $viewPassword = '';
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
app(CreateDatabaseUser::class)->create($this->server, $this->all());
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('database-user-created', true);
|
||||
}
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$databaseUser = DatabaseUser::query()->findOrFail($this->deleteId);
|
||||
|
||||
$databaseUser->deleteFromServer();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->emitTo(DatabaseList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
}
|
||||
|
||||
public function viewPassword(int $id): void
|
||||
{
|
||||
$databaseUser = DatabaseUser::query()->findOrFail($id);
|
||||
|
||||
$this->viewPassword = $databaseUser->password;
|
||||
|
||||
$this->dispatchBrowserEvent('open-modal', 'database-user-password');
|
||||
}
|
||||
|
||||
public function showLink(int $id): void
|
||||
{
|
||||
$databaseUser = DatabaseUser::query()->findOrFail($id);
|
||||
|
||||
$this->linkId = $id;
|
||||
$this->link = $databaseUser->databases;
|
||||
|
||||
$this->dispatchBrowserEvent('open-modal', 'link-database-user');
|
||||
}
|
||||
|
||||
public function link(): void
|
||||
{
|
||||
$databaseUser = DatabaseUser::query()->findOrFail($this->linkId);
|
||||
|
||||
app(LinkUser::class)->link($databaseUser, $this->link);
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('linked', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.databases.database-user-list', [
|
||||
'databases' => $this->server->databases,
|
||||
'databaseUsers' => $this->server->databaseUsers,
|
||||
]);
|
||||
}
|
||||
}
|
40
app/Http/Livewire/Firewall/CreateFirewallRule.php
Normal file
40
app/Http/Livewire/Firewall/CreateFirewallRule.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Firewall;
|
||||
|
||||
use App\Actions\FirewallRule\CreateRule;
|
||||
use App\Models\Server;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class CreateFirewallRule extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public string $type = 'allow';
|
||||
|
||||
public string $protocol = 'tcp';
|
||||
|
||||
public string $port;
|
||||
|
||||
public string $source = '0.0.0.0';
|
||||
|
||||
public string $mask = '0';
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
app(CreateRule::class)->create($this->server, $this->all());
|
||||
|
||||
$this->emitTo(FirewallRulesList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('created', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.firewall.create-firewall-rule');
|
||||
}
|
||||
}
|
36
app/Http/Livewire/Firewall/FirewallRulesList.php
Normal file
36
app/Http/Livewire/Firewall/FirewallRulesList.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Firewall;
|
||||
|
||||
use App\Models\FirewallRule;
|
||||
use App\Models\Server;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class FirewallRulesList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$rule = FirewallRule::query()->findOrFail($this->deleteId);
|
||||
|
||||
$rule->removeFromServer();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.firewall.firewall-rules-list', [
|
||||
'rules' => $this->server->firewallRules,
|
||||
]);
|
||||
}
|
||||
}
|
34
app/Http/Livewire/NotificationChannels/AddChannel.php
Normal file
34
app/Http/Livewire/NotificationChannels/AddChannel.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\NotificationChannels;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class AddChannel extends Component
|
||||
{
|
||||
public string $provider = '';
|
||||
|
||||
public string $label;
|
||||
|
||||
public string $webhook_url;
|
||||
|
||||
public string $email;
|
||||
|
||||
public function add(): void
|
||||
{
|
||||
app(\App\Actions\NotificationChannels\AddChannel::class)->add(
|
||||
auth()->user(),
|
||||
$this->all()
|
||||
);
|
||||
|
||||
$this->emitTo(KeysList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('added', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.notification-channels.add-channel');
|
||||
}
|
||||
}
|
37
app/Http/Livewire/NotificationChannels/ChannelsList.php
Normal file
37
app/Http/Livewire/NotificationChannels/ChannelsList.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\NotificationChannels;
|
||||
|
||||
use App\Models\NotificationChannel;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ChannelsList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
protected $listeners = [
|
||||
'$refresh',
|
||||
];
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$channel = NotificationChannel::query()->findOrFail($this->deleteId);
|
||||
|
||||
$channel->delete();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.notification-channels.channels-list', [
|
||||
'channels' => NotificationChannel::query()->latest()->get(),
|
||||
]);
|
||||
}
|
||||
}
|
30
app/Http/Livewire/Php/DefaultCli.php
Normal file
30
app/Http/Livewire/Php/DefaultCli.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Php;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class DefaultCli extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public function change(string $version): void
|
||||
{
|
||||
$this->server->php($version)->handler()->setDefaultCli();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.php.default-cli', [
|
||||
'defaultPHP' => $this->server->defaultService('php'),
|
||||
'phps' => $this->server->services()->where('type', 'php')->get(), //
|
||||
]);
|
||||
}
|
||||
}
|
85
app/Http/Livewire/Php/InstalledVersions.php
Normal file
85
app/Http/Livewire/Php/InstalledVersions.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Php;
|
||||
|
||||
use App\Actions\PHP\InstallNewPHP;
|
||||
use App\Actions\PHP\UpdatePHPIni;
|
||||
use App\Models\Server;
|
||||
use App\Models\Service;
|
||||
use App\SSHCommands\GetPHPIniCommand;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
use Throwable;
|
||||
|
||||
class InstalledVersions extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public int $uninstallId;
|
||||
|
||||
public int $iniId;
|
||||
|
||||
public string $ini = 'Loading php.ini';
|
||||
|
||||
public function install(string $version): void
|
||||
{
|
||||
app(InstallNewPHP::class)->install($this->server, [
|
||||
'version' => $version,
|
||||
]);
|
||||
|
||||
$this->refreshComponent([]);
|
||||
}
|
||||
|
||||
public function restart(int $id): void
|
||||
{
|
||||
$service = Service::query()->findOrFail($id);
|
||||
$service->restart();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
}
|
||||
|
||||
public function uninstall(): void
|
||||
{
|
||||
$service = Service::query()->findOrFail($this->uninstallId);
|
||||
$service->uninstall();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
}
|
||||
|
||||
public function loadIni(int $id): void
|
||||
{
|
||||
$this->iniId = $id;
|
||||
$this->ini = 'Loading php.ini';
|
||||
|
||||
$service = Service::query()->findOrFail($this->iniId);
|
||||
|
||||
try {
|
||||
$this->ini = $service->server->ssh()->exec(new GetPHPIniCommand($service->version));
|
||||
} catch (Throwable) {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
public function saveIni(): void
|
||||
{
|
||||
$service = Service::query()->findOrFail($this->iniId);
|
||||
|
||||
app(UpdatePHPIni::class)->update($service, $this->all()['ini']);
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
session()->flash('status', 'ini-updated');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.php.installed-versions', [
|
||||
'phps' => $this->server->services()->where('type', 'php')->get(),
|
||||
]);
|
||||
}
|
||||
}
|
32
app/Http/Livewire/Profile/UpdatePassword.php
Normal file
32
app/Http/Livewire/Profile/UpdatePassword.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Profile;
|
||||
|
||||
use App\Actions\User\UpdateUserPassword;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class UpdatePassword extends Component
|
||||
{
|
||||
public string $current_password;
|
||||
|
||||
public string $password;
|
||||
|
||||
public string $password_confirmation;
|
||||
|
||||
public function update(): void
|
||||
{
|
||||
app(UpdateUserPassword::class)->update(auth()->user(), $this->all());
|
||||
|
||||
$this->current_password = '';
|
||||
$this->password = '';
|
||||
$this->password_confirmation = '';
|
||||
|
||||
session()->flash('status', 'password-updated');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.profile.update-password');
|
||||
}
|
||||
}
|
48
app/Http/Livewire/Profile/UpdateProfileInformation.php
Normal file
48
app/Http/Livewire/Profile/UpdateProfileInformation.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Profile;
|
||||
|
||||
use App\Actions\User\UpdateUserProfileInformation;
|
||||
use App\Http\Livewire\UserDropdown;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class UpdateProfileInformation extends Component
|
||||
{
|
||||
public string $name;
|
||||
|
||||
public string $email;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->name = auth()->user()->name;
|
||||
$this->email = auth()->user()->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function submit(): void
|
||||
{
|
||||
app(UpdateUserProfileInformation::class)->update(auth()->user(), $this->all());
|
||||
|
||||
session()->flash('status', 'profile-updated');
|
||||
|
||||
$this->emitTo(UserDropdown::class, '$refresh');
|
||||
}
|
||||
|
||||
public function sendVerificationEmail(): void
|
||||
{
|
||||
if (! auth()->user()->hasVerifiedEmail()) {
|
||||
auth()->user()->sendEmailVerificationNotification();
|
||||
|
||||
session()->flash('status', 'verification-link-sent');
|
||||
}
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.profile.update-profile-information');
|
||||
}
|
||||
}
|
36
app/Http/Livewire/Queues/CreateQueue.php
Normal file
36
app/Http/Livewire/Queues/CreateQueue.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Queues;
|
||||
|
||||
use App\Models\Site;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class CreateQueue extends Component
|
||||
{
|
||||
public Site $site;
|
||||
|
||||
public string $command;
|
||||
|
||||
public string $user = '';
|
||||
|
||||
public int $auto_start = 1;
|
||||
|
||||
public int $auto_restart = 1;
|
||||
|
||||
public int $numprocs;
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
app(\App\Actions\Queue\CreateQueue::class)->create($this->site, $this->all());
|
||||
|
||||
$this->emitTo(QueuesList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('created', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.queues.create-queue');
|
||||
}
|
||||
}
|
57
app/Http/Livewire/Queues/QueuesList.php
Normal file
57
app/Http/Livewire/Queues/QueuesList.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Queues;
|
||||
|
||||
use App\Models\Queue;
|
||||
use App\Models\Site;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class QueuesList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$queue = $this->site->queues()->findOrFail($this->deleteId);
|
||||
|
||||
$queue->remove();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
}
|
||||
|
||||
public function start(Queue $queue): void
|
||||
{
|
||||
$queue->start();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
}
|
||||
|
||||
public function restart(Queue $queue): void
|
||||
{
|
||||
$queue->restart();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
}
|
||||
|
||||
public function stop(Queue $queue): void
|
||||
{
|
||||
$queue->stop();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.queues.queues-list', [
|
||||
'queues' => $this->site->queues,
|
||||
]);
|
||||
}
|
||||
}
|
58
app/Http/Livewire/ServerLogs/LogsList.php
Normal file
58
app/Http/Livewire/ServerLogs/LogsList.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\ServerLogs;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Site;
|
||||
use App\Traits\HasCustomPaginationView;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class LogsList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
use HasCustomPaginationView;
|
||||
|
||||
public ?int $count = null;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public ?Site $site = null;
|
||||
|
||||
public string $logContent;
|
||||
|
||||
public function showLog(int $id): void
|
||||
{
|
||||
$log = $this->server->logs()->findOrFail($id);
|
||||
$this->logContent = $log->content;
|
||||
|
||||
$this->dispatchBrowserEvent('open-modal', 'show-log');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
if ($this->site) {
|
||||
return $this->renderSite();
|
||||
}
|
||||
|
||||
if ($this->count) {
|
||||
$logs = $this->server->logs()->latest()->take(10)->get();
|
||||
} else {
|
||||
$logs = $this->server->logs()->latest()->simplePaginate(10);
|
||||
}
|
||||
|
||||
return view('livewire.server-logs.logs-list', compact('logs'));
|
||||
}
|
||||
|
||||
private function renderSite(): View
|
||||
{
|
||||
if ($this->count) {
|
||||
$logs = $this->site->logs()->latest()->take(10)->get();
|
||||
} else {
|
||||
$logs = $this->site->logs()->latest()->simplePaginate(10);
|
||||
}
|
||||
|
||||
return view('livewire.server-logs.logs-list', compact('logs'));
|
||||
}
|
||||
}
|
40
app/Http/Livewire/ServerProviders/ConnectProvider.php
Normal file
40
app/Http/Livewire/ServerProviders/ConnectProvider.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\ServerProviders;
|
||||
|
||||
use App\Actions\ServerProvider\CreateServerProvider;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ConnectProvider extends Component
|
||||
{
|
||||
public string $provider = '';
|
||||
|
||||
public string $name;
|
||||
|
||||
public string $token;
|
||||
|
||||
public string $key;
|
||||
|
||||
public string $secret;
|
||||
|
||||
public function connect(): void
|
||||
{
|
||||
app(CreateServerProvider::class)->create(auth()->user(), $this->all());
|
||||
|
||||
$this->emitTo(ProvidersList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('connected', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
if (request()->query('provider')) {
|
||||
$this->provider = request()->query('provider');
|
||||
}
|
||||
|
||||
return view('livewire.server-providers.connect-provider', [
|
||||
'open' => ! is_null(request()->query('provider')),
|
||||
]);
|
||||
}
|
||||
}
|
37
app/Http/Livewire/ServerProviders/ProvidersList.php
Normal file
37
app/Http/Livewire/ServerProviders/ProvidersList.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\ServerProviders;
|
||||
|
||||
use App\Models\ServerProvider;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ProvidersList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
protected $listeners = [
|
||||
'$refresh',
|
||||
];
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$provider = ServerProvider::query()->findOrFail($this->deleteId);
|
||||
|
||||
$provider->delete();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.server-providers.providers-list', [
|
||||
'providers' => ServerProvider::query()->latest()->get(),
|
||||
]);
|
||||
}
|
||||
}
|
24
app/Http/Livewire/ServerSettings/CheckConnection.php
Normal file
24
app/Http/Livewire/ServerSettings/CheckConnection.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\ServerSettings;
|
||||
|
||||
use App\Models\Server;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class CheckConnection extends Component
|
||||
{
|
||||
public Server $server;
|
||||
|
||||
public function check(): void
|
||||
{
|
||||
$this->server->checkConnection();
|
||||
|
||||
session()->flash('status', 'checking-connection');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.server-settings.check-connection');
|
||||
}
|
||||
}
|
40
app/Http/Livewire/ServerSettings/EditServer.php
Normal file
40
app/Http/Livewire/ServerSettings/EditServer.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\ServerSettings;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class EditServer extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public string $name;
|
||||
|
||||
public string $ip;
|
||||
|
||||
public string $port;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->name = $this->server->name;
|
||||
$this->ip = $this->server->ip;
|
||||
$this->port = $this->server->port;
|
||||
}
|
||||
|
||||
public function update(): void
|
||||
{
|
||||
app(\App\Actions\Server\EditServer::class)->edit($this->server, $this->all());
|
||||
|
||||
session()->flash('status', 'server-updated');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.server-settings.edit-server');
|
||||
}
|
||||
}
|
24
app/Http/Livewire/ServerSettings/RebootServer.php
Normal file
24
app/Http/Livewire/ServerSettings/RebootServer.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\ServerSettings;
|
||||
|
||||
use App\Models\Server;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class RebootServer extends Component
|
||||
{
|
||||
public Server $server;
|
||||
|
||||
public function reboot(): void
|
||||
{
|
||||
$this->server->reboot();
|
||||
|
||||
session()->flash('status', 'rebooting-server');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.server-settings.reboot-server');
|
||||
}
|
||||
}
|
20
app/Http/Livewire/ServerSettings/ServerDetails.php
Normal file
20
app/Http/Livewire/ServerSettings/ServerDetails.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\ServerSettings;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ServerDetails extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.server-settings.server-details');
|
||||
}
|
||||
}
|
33
app/Http/Livewire/ServerSshKeys/AddExistingKey.php
Normal file
33
app/Http/Livewire/ServerSshKeys/AddExistingKey.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\ServerSshKeys;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\SshKey;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class AddExistingKey extends Component
|
||||
{
|
||||
public Server $server;
|
||||
|
||||
public string $key_id = '';
|
||||
|
||||
public function add(): void
|
||||
{
|
||||
$key = SshKey::query()->findOrFail($this->all()['key_id']);
|
||||
|
||||
$key->deployTo($this->server);
|
||||
|
||||
$this->emitTo(ServerKeysList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('added', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.server-ssh-keys.add-existing-key', [
|
||||
'keys' => SshKey::all(),
|
||||
]);
|
||||
}
|
||||
}
|
36
app/Http/Livewire/ServerSshKeys/AddNewKey.php
Normal file
36
app/Http/Livewire/ServerSshKeys/AddNewKey.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\ServerSshKeys;
|
||||
|
||||
use App\Actions\SshKey\CreateSshKey;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class AddNewKey extends Component
|
||||
{
|
||||
public Server $server;
|
||||
|
||||
public string $name;
|
||||
|
||||
public string $public_key;
|
||||
|
||||
public function add(): void
|
||||
{
|
||||
$key = app(CreateSshKey::class)->create(
|
||||
auth()->user(),
|
||||
$this->all()
|
||||
);
|
||||
|
||||
$key->deployTo($this->server);
|
||||
|
||||
$this->emitTo(ServerKeysList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('added', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.server-ssh-keys.add-new-key');
|
||||
}
|
||||
}
|
40
app/Http/Livewire/ServerSshKeys/ServerKeysList.php
Normal file
40
app/Http/Livewire/ServerSshKeys/ServerKeysList.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\ServerSshKeys;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\SshKey;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ServerKeysList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
protected $listeners = [
|
||||
'$refresh',
|
||||
];
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$key = SshKey::query()->findOrFail($this->deleteId);
|
||||
|
||||
$key->deleteFrom($this->server);
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.server-ssh-keys.server-keys-list', [
|
||||
'keys' => $this->server->sshKeys,
|
||||
]);
|
||||
}
|
||||
}
|
64
app/Http/Livewire/Servers/CreateServer.php
Normal file
64
app/Http/Livewire/Servers/CreateServer.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Servers;
|
||||
|
||||
use App\Enums\Database;
|
||||
use App\Enums\OperatingSystem;
|
||||
use App\Enums\ServerType;
|
||||
use App\Enums\Webserver;
|
||||
use App\Models\ServerProvider;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
use Throwable;
|
||||
|
||||
class CreateServer extends Component
|
||||
{
|
||||
public string $provider = 'custom';
|
||||
|
||||
public string $server_provider = '';
|
||||
|
||||
public string $type = ServerType::REGULAR;
|
||||
|
||||
public string $name;
|
||||
|
||||
public string $ip;
|
||||
|
||||
public string $port;
|
||||
|
||||
public string $os = OperatingSystem::UBUNTU22;
|
||||
|
||||
public string $webserver = Webserver::NGINX;
|
||||
|
||||
public string $database = Database::MYSQL80;
|
||||
|
||||
public string $php = '8.2';
|
||||
|
||||
public string $plan = '';
|
||||
|
||||
public string $region = '';
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function submit(): void
|
||||
{
|
||||
$server = app(\App\Actions\Server\CreateServer::class)->create(
|
||||
auth()->user(),
|
||||
$this->all()
|
||||
);
|
||||
|
||||
$this->redirect(route('servers.show', ['server' => $server]));
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
$serverProviders = ServerProvider::query()->where('provider', $this->provider)->get();
|
||||
|
||||
return view(
|
||||
'livewire.servers.create-server',
|
||||
compact([
|
||||
'serverProviders',
|
||||
])
|
||||
);
|
||||
}
|
||||
}
|
29
app/Http/Livewire/Servers/DeleteServer.php
Normal file
29
app/Http/Livewire/Servers/DeleteServer.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Servers;
|
||||
|
||||
use App\Models\Server;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class DeleteServer extends Component
|
||||
{
|
||||
public Server $server;
|
||||
|
||||
public function mount(Server $server): void
|
||||
{
|
||||
$this->server = $server;
|
||||
}
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$this->server->delete();
|
||||
|
||||
$this->redirect(route('servers'));
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.servers.delete-server');
|
||||
}
|
||||
}
|
20
app/Http/Livewire/Servers/ServersList.php
Normal file
20
app/Http/Livewire/Servers/ServersList.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Servers;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ServersList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.servers.servers-list', [
|
||||
'servers' => Server::all(),
|
||||
]);
|
||||
}
|
||||
}
|
31
app/Http/Livewire/Servers/ShowServer.php
Normal file
31
app/Http/Livewire/Servers/ShowServer.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Servers;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ShowServer extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public function refreshComponent(array $data): void
|
||||
{
|
||||
if (isset($data['type']) && $data['type'] == 'install-server-finished') {
|
||||
$this->redirect(route('servers.show', ['server' => $this->server]));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->emit('refreshComponent');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.servers.show-server');
|
||||
}
|
||||
}
|
49
app/Http/Livewire/Services/ServicesList.php
Normal file
49
app/Http/Livewire/Services/ServicesList.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Services;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ServicesList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public function stop(int $id): void
|
||||
{
|
||||
$service = $this->server->services()->where('id', $id)->firstOrFail();
|
||||
|
||||
$service->stop();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
}
|
||||
|
||||
public function start(int $id): void
|
||||
{
|
||||
$service = $this->server->services()->where('id', $id)->firstOrFail();
|
||||
|
||||
$service->start();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
}
|
||||
|
||||
public function restart(int $id): void
|
||||
{
|
||||
$service = $this->server->services()->where('id', $id)->firstOrFail();
|
||||
|
||||
$service->restart();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.services.services-list', [
|
||||
'services' => $this->server->services,
|
||||
]);
|
||||
}
|
||||
}
|
41
app/Http/Livewire/Sites/ChangePhpVersion.php
Normal file
41
app/Http/Livewire/Sites/ChangePhpVersion.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Sites;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ChangePhpVersion extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public string $version;
|
||||
|
||||
public function mount(Site $site): void
|
||||
{
|
||||
$this->version = $site->php_version;
|
||||
}
|
||||
|
||||
public function change(): void
|
||||
{
|
||||
$this->site->changePHPVersion($this->version);
|
||||
|
||||
session()->flash('status', 'changing-php-version');
|
||||
}
|
||||
|
||||
public function refreshComponent(array $data): void
|
||||
{
|
||||
if (isset($data['type'])) {
|
||||
session()->flash('status', $data['type']);
|
||||
}
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.sites.change-php-version');
|
||||
}
|
||||
}
|
59
app/Http/Livewire/Sites/CreateSite.php
Normal file
59
app/Http/Livewire/Sites/CreateSite.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Sites;
|
||||
|
||||
use App\Enums\SiteType;
|
||||
use App\Exceptions\SourceControlIsNotConnected;
|
||||
use App\Models\Server;
|
||||
use App\Models\SourceControl;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class CreateSite extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @throws SourceControlIsNotConnected
|
||||
*/
|
||||
public function create(): void
|
||||
{
|
||||
$site = app(\App\Actions\Site\CreateSite::class)->create(
|
||||
$this->server,
|
||||
$this->all()
|
||||
);
|
||||
|
||||
$this->redirect(route('servers.sites.show', [
|
||||
'server' => $site->server,
|
||||
'site' => $site,
|
||||
]));
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.sites.create-site', [
|
||||
'sourceControls' => SourceControl::all(),
|
||||
]);
|
||||
}
|
||||
}
|
27
app/Http/Livewire/Sites/DeleteSite.php
Normal file
27
app/Http/Livewire/Sites/DeleteSite.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Sites;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class DeleteSite extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$this->site->remove();
|
||||
|
||||
$this->redirect(route('servers.sites', ['server' => $this->site->server]));
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.sites.delete-site');
|
||||
}
|
||||
}
|
20
app/Http/Livewire/Sites/ShowSite.php
Normal file
20
app/Http/Livewire/Sites/ShowSite.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Sites;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class ShowSite extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.sites.show-site');
|
||||
}
|
||||
}
|
38
app/Http/Livewire/Sites/SitesList.php
Normal file
38
app/Http/Livewire/Sites/SitesList.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Sites;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class SitesList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Server $server;
|
||||
|
||||
public function refreshComponent(array $data): void
|
||||
{
|
||||
if (isset($data['type']) && $data['type'] == 'install-site-finished') {
|
||||
$this->redirect(
|
||||
route('servers.sites.show', [
|
||||
'server' => $this->server,
|
||||
'site' => $data['data']['site']['id'],
|
||||
])
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->emit('refreshComponent');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.sites.sites-list', [
|
||||
'sites' => $this->server->sites()->latest()->get(),
|
||||
]);
|
||||
}
|
||||
}
|
36
app/Http/Livewire/SourceControls/Bitbucket.php
Normal file
36
app/Http/Livewire/SourceControls/Bitbucket.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\SourceControls;
|
||||
|
||||
use App\Actions\SourceControl\ConnectSourceControl;
|
||||
use App\Models\SourceControl;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class Bitbucket extends Component
|
||||
{
|
||||
public string $token;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->token = SourceControl::query()
|
||||
->where('provider', \App\Enums\SourceControl::BITBUCKET)
|
||||
->first()?->access_token ?? '';
|
||||
}
|
||||
|
||||
public function connect(): void
|
||||
{
|
||||
app(ConnectSourceControl::class)->connect(\App\Enums\SourceControl::BITBUCKET, $this->all());
|
||||
|
||||
session()->flash('status', 'bitbucket-updated');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.source-controls.bitbucket', [
|
||||
'sourceControl' => SourceControl::query()
|
||||
->where('provider', \App\Enums\SourceControl::BITBUCKET)
|
||||
->first(),
|
||||
]);
|
||||
}
|
||||
}
|
36
app/Http/Livewire/SourceControls/Github.php
Normal file
36
app/Http/Livewire/SourceControls/Github.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\SourceControls;
|
||||
|
||||
use App\Actions\SourceControl\ConnectSourceControl;
|
||||
use App\Models\SourceControl;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class Github extends Component
|
||||
{
|
||||
public string $token;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->token = SourceControl::query()
|
||||
->where('provider', \App\Enums\SourceControl::GITHUB)
|
||||
->first()?->access_token ?? '';
|
||||
}
|
||||
|
||||
public function connect(): void
|
||||
{
|
||||
app(ConnectSourceControl::class)->connect(\App\Enums\SourceControl::GITHUB, $this->all());
|
||||
|
||||
session()->flash('status', 'github-updated');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.source-controls.github', [
|
||||
'sourceControl' => SourceControl::query()
|
||||
->where('provider', \App\Enums\SourceControl::GITHUB)
|
||||
->first(),
|
||||
]);
|
||||
}
|
||||
}
|
36
app/Http/Livewire/SourceControls/Gitlab.php
Normal file
36
app/Http/Livewire/SourceControls/Gitlab.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\SourceControls;
|
||||
|
||||
use App\Actions\SourceControl\ConnectSourceControl;
|
||||
use App\Models\SourceControl;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class Gitlab extends Component
|
||||
{
|
||||
public string $token;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
$this->token = SourceControl::query()
|
||||
->where('provider', \App\Enums\SourceControl::GITLAB)
|
||||
->first()?->access_token ?? '';
|
||||
}
|
||||
|
||||
public function connect(): void
|
||||
{
|
||||
app(ConnectSourceControl::class)->connect(\App\Enums\SourceControl::GITLAB, $this->all());
|
||||
|
||||
session()->flash('status', 'gitlab-updated');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.source-controls.gitlab', [
|
||||
'sourceControl' => SourceControl::query()
|
||||
->where('provider', \App\Enums\SourceControl::GITLAB)
|
||||
->first(),
|
||||
]);
|
||||
}
|
||||
}
|
31
app/Http/Livewire/SshKeys/AddKey.php
Normal file
31
app/Http/Livewire/SshKeys/AddKey.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\SshKeys;
|
||||
|
||||
use App\Actions\SshKey\CreateSshKey;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class AddKey extends Component
|
||||
{
|
||||
public string $name;
|
||||
|
||||
public string $public_key;
|
||||
|
||||
public function add(): void
|
||||
{
|
||||
app(CreateSshKey::class)->create(
|
||||
auth()->user(),
|
||||
$this->all()
|
||||
);
|
||||
|
||||
$this->emitTo(KeysList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('added', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.ssh-keys.add-key');
|
||||
}
|
||||
}
|
37
app/Http/Livewire/SshKeys/KeysList.php
Normal file
37
app/Http/Livewire/SshKeys/KeysList.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\SshKeys;
|
||||
|
||||
use App\Models\SshKey;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class KeysList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
protected $listeners = [
|
||||
'$refresh',
|
||||
];
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$key = SshKey::query()->findOrFail($this->deleteId);
|
||||
|
||||
$key->delete();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.ssh-keys.keys-list', [
|
||||
'keys' => SshKey::query()->latest()->get(),
|
||||
]);
|
||||
}
|
||||
}
|
35
app/Http/Livewire/Ssl/CreateSsl.php
Normal file
35
app/Http/Livewire/Ssl/CreateSsl.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Ssl;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class CreateSsl extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public string $type = '';
|
||||
|
||||
public string $certificate;
|
||||
|
||||
public string $private;
|
||||
|
||||
public function create(): void
|
||||
{
|
||||
app(\App\Actions\SSL\CreateSSL::class)->create($this->site, $this->all());
|
||||
|
||||
$this->emitTo(SslsList::class, '$refresh');
|
||||
|
||||
$this->dispatchBrowserEvent('created', true);
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.ssl.create-ssl');
|
||||
}
|
||||
}
|
46
app/Http/Livewire/Ssl/SslsList.php
Normal file
46
app/Http/Livewire/Ssl/SslsList.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Ssl;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\Traits\HasToast;
|
||||
use App\Traits\RefreshComponentOnBroadcast;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class SslsList extends Component
|
||||
{
|
||||
use RefreshComponentOnBroadcast;
|
||||
use HasToast;
|
||||
|
||||
public Site $site;
|
||||
|
||||
public int $deleteId;
|
||||
|
||||
public function delete(): void
|
||||
{
|
||||
$ssl = $this->site->ssls()->where('id', $this->deleteId)->firstOrFail();
|
||||
|
||||
$ssl->remove();
|
||||
|
||||
$this->refreshComponent([]);
|
||||
|
||||
$this->dispatchBrowserEvent('confirmed', true);
|
||||
}
|
||||
|
||||
public function refreshComponent(array $data): void
|
||||
{
|
||||
if (isset($data['type']) && $data['type'] == 'deploy-ssl-failed') {
|
||||
$this->toast()->error(__('SSL creation failed!'));
|
||||
}
|
||||
|
||||
$this->emit('refreshComponent');
|
||||
}
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.ssl.ssls-list', [
|
||||
'ssls' => $this->site->ssls,
|
||||
]);
|
||||
}
|
||||
}
|
18
app/Http/Livewire/UserDropdown.php
Normal file
18
app/Http/Livewire/UserDropdown.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Livewire\Component;
|
||||
|
||||
class UserDropdown extends Component
|
||||
{
|
||||
protected $listeners = [
|
||||
'$refresh',
|
||||
];
|
||||
|
||||
public function render(): View
|
||||
{
|
||||
return view('livewire.user-dropdown');
|
||||
}
|
||||
}
|
17
app/Http/Middleware/Authenticate.php
Normal file
17
app/Http/Middleware/Authenticate.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*/
|
||||
protected function redirectTo(Request $request): ?string
|
||||
{
|
||||
return $request->expectsJson() ? null : route('login');
|
||||
}
|
||||
}
|
17
app/Http/Middleware/EncryptCookies.php
Normal file
17
app/Http/Middleware/EncryptCookies.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
17
app/Http/Middleware/PreventRequestsDuringMaintenance.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
30
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
30
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, string ...$guards): Response
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
19
app/Http/Middleware/TrimStrings.php
Normal file
19
app/Http/Middleware/TrimStrings.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
20
app/Http/Middleware/TrustHosts.php
Normal file
20
app/Http/Middleware/TrustHosts.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts(): array
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
28
app/Http/Middleware/TrustProxies.php
Normal file
28
app/Http/Middleware/TrustProxies.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
22
app/Http/Middleware/ValidateSignature.php
Normal file
22
app/Http/Middleware/ValidateSignature.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||
|
||||
class ValidateSignature extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
// 'fbclid',
|
||||
// 'utm_campaign',
|
||||
// 'utm_content',
|
||||
// 'utm_medium',
|
||||
// 'utm_source',
|
||||
// 'utm_term',
|
||||
];
|
||||
}
|
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
17
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
85
app/Http/Requests/Auth/LoginRequest.php
Normal file
85
app/Http/Requests/Auth/LoginRequest.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
|
||||
use Illuminate\Auth\Events\Lockout;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\RateLimiter;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class LoginRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'email' => ['required', 'string', 'email'],
|
||||
'password' => ['required', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to authenticate the request's credentials.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function authenticate(): void
|
||||
{
|
||||
$this->ensureIsNotRateLimited();
|
||||
|
||||
if (! Auth::attempt($this->only('email', 'password'), $this->boolean('remember'))) {
|
||||
RateLimiter::hit($this->throttleKey());
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'email' => trans('auth.failed'),
|
||||
]);
|
||||
}
|
||||
|
||||
RateLimiter::clear($this->throttleKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the login request is not rate limited.
|
||||
*
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function ensureIsNotRateLimited(): void
|
||||
{
|
||||
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
|
||||
return;
|
||||
}
|
||||
|
||||
event(new Lockout($this));
|
||||
|
||||
$seconds = RateLimiter::availableIn($this->throttleKey());
|
||||
|
||||
throw ValidationException::withMessages([
|
||||
'email' => trans('auth.throttle', [
|
||||
'seconds' => $seconds,
|
||||
'minutes' => ceil($seconds / 60),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rate limiting throttle key for the request.
|
||||
*/
|
||||
public function throttleKey(): string
|
||||
{
|
||||
return Str::transliterate(Str::lower($this->input('email')).'|'.$this->ip());
|
||||
}
|
||||
}
|
23
app/Http/Requests/ProfileUpdateRequest.php
Normal file
23
app/Http/Requests/ProfileUpdateRequest.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class ProfileUpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\Rule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['string', 'max:255'],
|
||||
'email' => ['email', 'max:255', Rule::unique(User::class)->ignore($this->user()->id)],
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user