2023-03-17 14:33:48 +00:00
|
|
|
<?php
|
|
|
|
|
2023-04-19 10:42:15 +00:00
|
|
|
use App\Http\Controllers\ApplicationController;
|
2023-06-07 13:08:35 +00:00
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Http\Controllers\MagicController;
|
2023-03-28 20:13:08 +00:00
|
|
|
use App\Http\Controllers\ProjectController;
|
2023-06-07 13:08:35 +00:00
|
|
|
use App\Http\Controllers\ServerController;
|
2023-04-25 07:38:05 +00:00
|
|
|
use App\Models\InstanceSettings;
|
2023-05-03 10:38:57 +00:00
|
|
|
use App\Models\PrivateKey;
|
2023-05-02 10:47:52 +00:00
|
|
|
use App\Models\StandaloneDocker;
|
|
|
|
use App\Models\SwarmDocker;
|
2023-05-08 11:36:49 +00:00
|
|
|
use App\Models\GithubApp;
|
2023-05-04 09:14:37 +00:00
|
|
|
use App\Models\Server;
|
2023-06-12 13:47:42 +00:00
|
|
|
use App\Models\User;
|
|
|
|
use App\Notifications\TransactionalEmails\ResetPasswordEmail;
|
2023-05-08 11:36:49 +00:00
|
|
|
use Illuminate\Http\Request;
|
2023-06-12 13:47:42 +00:00
|
|
|
use Illuminate\Support\Facades\DB;
|
2023-06-12 14:39:48 +00:00
|
|
|
use Illuminate\Support\Facades\Password;
|
2023-03-17 14:33:48 +00:00
|
|
|
use Illuminate\Support\Facades\Route;
|
2023-05-08 19:56:44 +00:00
|
|
|
use Illuminate\Support\Str;
|
2023-06-12 14:39:48 +00:00
|
|
|
use Laravel\Fortify\Contracts\FailedPasswordResetLinkRequestResponse;
|
|
|
|
use Laravel\Fortify\Contracts\SuccessfulPasswordResetLinkRequestResponse;
|
|
|
|
use Laravel\Fortify\Fortify;
|
2023-03-17 14:33:48 +00:00
|
|
|
|
2023-03-20 12:04:22 +00:00
|
|
|
|
2023-06-12 14:39:48 +00:00
|
|
|
|
|
|
|
Route::post('/forgot-password', function (Request $request) {
|
|
|
|
if (!is_transactional_emails_active()) {
|
|
|
|
set_transanctional_email_settings();
|
|
|
|
$request->validate([Fortify::email() => 'required|email']);
|
|
|
|
$status = Password::broker(config('fortify.passwords'))->sendResetLink(
|
|
|
|
$request->only(Fortify::email())
|
|
|
|
);
|
|
|
|
return $status == Password::RESET_LINK_SENT
|
|
|
|
? app(SuccessfulPasswordResetLinkRequestResponse::class, ['status' => $status])
|
|
|
|
: app(FailedPasswordResetLinkRequestResponse::class, ['status' => $status]);
|
2023-06-12 13:47:42 +00:00
|
|
|
}
|
2023-06-12 14:39:48 +00:00
|
|
|
return response()->json(['message' => 'Transactional emails are not active'], 400);
|
2023-06-12 13:47:42 +00:00
|
|
|
})->name('password.forgot');
|
2023-06-06 09:35:50 +00:00
|
|
|
Route::prefix('magic')->middleware(['auth'])->group(function () {
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::get('/servers', [MagicController::class, 'servers']);
|
|
|
|
Route::get('/destinations', [MagicController::class, 'destinations']);
|
|
|
|
Route::get('/projects', [MagicController::class, 'projects']);
|
|
|
|
Route::get('/environments', [MagicController::class, 'environments']);
|
|
|
|
Route::get('/project/new', [MagicController::class, 'new_project']);
|
|
|
|
Route::get('/environment/new', [MagicController::class, 'new_environment']);
|
2023-06-05 22:18:48 +00:00
|
|
|
});
|
2023-06-07 13:08:35 +00:00
|
|
|
|
2023-03-24 13:54:17 +00:00
|
|
|
Route::middleware(['auth'])->group(function () {
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::get('/projects', [ProjectController::class, 'all'])->name('projects');
|
|
|
|
Route::get('/project/{project_uuid}', [ProjectController::class, 'show'])->name('project.show');
|
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/new', [ProjectController::class, 'new'])->name('project.resources.new');
|
|
|
|
Route::get('/project/{project_uuid}/{environment_name}', [ProjectController::class, 'resources'])->name('project.resources');
|
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}', [ApplicationController::class, 'configuration'])->name('project.application.configuration');
|
2023-03-28 20:13:08 +00:00
|
|
|
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::get('/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment', [ApplicationController::class, 'deployments'])->name('project.application.deployments');
|
2023-06-02 10:34:45 +00:00
|
|
|
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::get(
|
|
|
|
'/project/{project_uuid}/{environment_name}/application/{application_uuid}/deployment/{deployment_uuid}',
|
|
|
|
[ApplicationController::class, 'deployment']
|
|
|
|
)->name('project.application.deployment');
|
|
|
|
});
|
2023-04-25 07:38:05 +00:00
|
|
|
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::middleware(['auth'])->group(function () {
|
|
|
|
Route::get('/servers', [ServerController::class, 'all'])->name('server.all');
|
|
|
|
Route::get('/server/new', [ServerController::class, 'create'])->name('server.create');
|
|
|
|
Route::get('/server/{server_uuid}', [ServerController::class, 'show'])->name('server.show');
|
|
|
|
Route::get('/server/{server_uuid}/proxy', [ServerController::class, 'proxy'])->name('server.proxy');
|
|
|
|
Route::get('/server/{server_uuid}/private-key', fn () => view('server.private-key'))->name('server.private-key');
|
|
|
|
});
|
2023-04-25 07:38:05 +00:00
|
|
|
|
|
|
|
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::middleware(['auth'])->group(function () {
|
|
|
|
Route::get('/', [Controller::class, 'dashboard'])->name('dashboard');
|
2023-06-07 20:07:26 +00:00
|
|
|
Route::get('/settings', [Controller::class, 'settings'])->name('settings.configuration');
|
|
|
|
Route::get('/settings/emails', [Controller::class, 'emails'])->name('settings.emails');
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::get('/profile', fn () => view('profile', ['request' => request()]))->name('profile');
|
2023-06-09 13:55:21 +00:00
|
|
|
Route::get('/profile/team', [Controller::class, 'team'])->name('team.show');
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::get('/profile/team/notifications', fn () => view('team.notifications'))->name('team.notifications');
|
|
|
|
Route::get('/command-center', fn () => view('command-center', ['servers' => Server::validated()->get()]))->name('command-center');
|
2023-06-12 10:00:01 +00:00
|
|
|
Route::get('/invitations/{uuid}', [Controller::class, 'accept_invitation'])->name('team.invitation.accept');
|
|
|
|
Route::get('/invitations/{uuid}/revoke', [Controller::class, 'revoke_invitation'])->name('team.invitation.revoke');
|
2023-04-25 07:38:05 +00:00
|
|
|
});
|
|
|
|
|
2023-05-03 10:38:57 +00:00
|
|
|
Route::middleware(['auth'])->group(function () {
|
|
|
|
Route::get('/private-key/new', fn () => view('private-key.new'))->name('private-key.new');
|
2023-06-07 13:08:35 +00:00
|
|
|
Route::get('/private-key/{private_key_uuid}', fn () => view('private-key.show', [
|
|
|
|
'private_key' => PrivateKey::ownedByCurrentTeam()->whereUuid(request()->private_key_uuid)->firstOrFail()
|
|
|
|
]))->name('private-key.show');
|
2023-05-03 10:38:57 +00:00
|
|
|
});
|
2023-06-07 13:08:35 +00:00
|
|
|
|
|
|
|
|
2023-05-08 11:36:49 +00:00
|
|
|
Route::middleware(['auth'])->group(function () {
|
|
|
|
Route::get('/source/new', fn () => view('source.new'))->name('source.new');
|
|
|
|
Route::get('/source/github/{github_app_uuid}', function (Request $request) {
|
2023-05-09 09:33:50 +00:00
|
|
|
$github_app = GithubApp::where('uuid', request()->github_app_uuid)->first();
|
2023-05-09 12:42:10 +00:00
|
|
|
$name = Str::of(Str::kebab($github_app->name))->start('coolify-');
|
2023-05-16 15:09:50 +00:00
|
|
|
$settings = InstanceSettings::get();
|
2023-05-08 19:56:44 +00:00
|
|
|
$host = $request->schemeAndHttpHost();
|
|
|
|
if ($settings->fqdn) {
|
|
|
|
$host = $settings->fqdn;
|
|
|
|
}
|
2023-05-09 09:33:50 +00:00
|
|
|
$installation_path = $github_app->html_url === 'https://github.com' ? 'apps' : 'github-apps';
|
|
|
|
$installation_url = "$github_app->html_url/$installation_path/$name/installations/new";
|
2023-05-08 19:56:44 +00:00
|
|
|
return view('source.github.show', [
|
|
|
|
'github_app' => $github_app,
|
|
|
|
'host' => $host,
|
2023-05-09 09:33:50 +00:00
|
|
|
'name' => $name,
|
|
|
|
'installation_url' => $installation_url,
|
2023-05-08 19:56:44 +00:00
|
|
|
]);
|
2023-05-08 11:36:49 +00:00
|
|
|
})->name('source.github.show');
|
|
|
|
});
|
2023-04-25 08:47:13 +00:00
|
|
|
|
2023-05-02 10:47:52 +00:00
|
|
|
Route::middleware(['auth'])->group(function () {
|
2023-05-03 09:16:08 +00:00
|
|
|
Route::get('/destination/new', function () {
|
2023-06-07 13:08:35 +00:00
|
|
|
$servers = Server::validated()->get();
|
2023-05-12 11:10:09 +00:00
|
|
|
$pre_selected_server_uuid = data_get(request()->query(), 'server');
|
|
|
|
if ($pre_selected_server_uuid) {
|
|
|
|
$server = $servers->firstWhere('uuid', $pre_selected_server_uuid);
|
|
|
|
if ($server) {
|
|
|
|
$server_id = $server->id;
|
|
|
|
}
|
|
|
|
}
|
2023-05-03 09:16:08 +00:00
|
|
|
return view('destination.new', [
|
2023-05-04 09:14:37 +00:00
|
|
|
"servers" => $servers,
|
2023-05-12 11:10:09 +00:00
|
|
|
"server_id" => $server_id ?? null,
|
2023-05-03 09:16:08 +00:00
|
|
|
]);
|
|
|
|
})->name('destination.new');
|
2023-05-02 10:47:52 +00:00
|
|
|
Route::get('/destination/{destination_uuid}', function () {
|
|
|
|
$standalone_dockers = StandaloneDocker::where('uuid', request()->destination_uuid)->first();
|
|
|
|
$swarm_dockers = SwarmDocker::where('uuid', request()->destination_uuid)->first();
|
|
|
|
if (!$standalone_dockers && !$swarm_dockers) {
|
|
|
|
abort(404);
|
|
|
|
}
|
|
|
|
$destination = $standalone_dockers ? $standalone_dockers : $swarm_dockers;
|
|
|
|
return view('destination.show', [
|
2023-05-04 09:14:37 +00:00
|
|
|
'destination' => $destination->load(['server']),
|
2023-05-02 10:47:52 +00:00
|
|
|
]);
|
|
|
|
})->name('destination.show');
|
|
|
|
});
|