wip
This commit is contained in:
67
app/Http/Controllers/ApplicationController.php
Normal file
67
app/Http/Controllers/ApplicationController.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class ApplicationController extends Controller
|
||||
{
|
||||
public function configuration()
|
||||
{
|
||||
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||
if (!$project) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
||||
if (!$environment) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
|
||||
if (!$application) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
return view('project.applications.configuration', ['application' => $application]);
|
||||
}
|
||||
public function deployments()
|
||||
{
|
||||
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||
if (!$project) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
||||
if (!$environment) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
|
||||
if (!$application) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
return view('project.applications.deployments', ['application' => $application, 'deployments' => $application->deployments()]);
|
||||
}
|
||||
|
||||
public function deployment()
|
||||
{
|
||||
$deployment_uuid = request()->route('deployment_uuid');
|
||||
|
||||
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||
if (!$project) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
||||
if (!$environment) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
|
||||
if (!$application) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
$activity = Activity::where('properties->deployment_uuid', '=', $deployment_uuid)->first();
|
||||
|
||||
return view('project.applications.deployment', [
|
||||
'application' => $application,
|
||||
'activity' => $activity,
|
||||
'deployment_uuid' => $deployment_uuid,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ class ProjectController extends Controller
|
||||
return view('project.resources', ['project' => $project, 'environment' => $environment]);
|
||||
}
|
||||
|
||||
public function application()
|
||||
public function application_configuration()
|
||||
{
|
||||
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||
if (!$project) {
|
||||
@@ -43,10 +43,26 @@ class ProjectController extends Controller
|
||||
if (!$application) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
return view('project.application', ['application' => $application, 'deployments' => $application->deployments()]);
|
||||
return view('project.applications.configuration', ['application' => $application]);
|
||||
}
|
||||
public function application_deployments()
|
||||
{
|
||||
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||
if (!$project) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
||||
if (!$environment) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
|
||||
if (!$application) {
|
||||
return redirect()->route('home');
|
||||
}
|
||||
return view('project.applications.deployments', ['application' => $application, 'deployments' => $application->deployments()]);
|
||||
}
|
||||
|
||||
public function deployment()
|
||||
public function application_deployment()
|
||||
{
|
||||
$deployment_uuid = request()->route('deployment_uuid');
|
||||
|
||||
@@ -64,7 +80,8 @@ class ProjectController extends Controller
|
||||
}
|
||||
$activity = Activity::where('properties->deployment_uuid', '=', $deployment_uuid)->first();
|
||||
|
||||
return view('project.deployment', [
|
||||
return view('project.applications.deployment', [
|
||||
'application' => $application,
|
||||
'activity' => $activity,
|
||||
'deployment_uuid' => $deployment_uuid,
|
||||
]);
|
||||
|
||||
10
app/Http/Livewire/Application/Destination.php
Normal file
10
app/Http/Livewire/Application/Destination.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Application;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class Destination extends Component
|
||||
{
|
||||
public $destination;
|
||||
}
|
||||
42
app/Http/Livewire/Application/General.php
Normal file
42
app/Http/Livewire/Application/General.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Application;
|
||||
|
||||
use App\Models\Application;
|
||||
use Livewire\Component;
|
||||
|
||||
class General extends Component
|
||||
{
|
||||
public string $applicationId;
|
||||
|
||||
public Application $application;
|
||||
public string $name;
|
||||
public string|null $fqdn;
|
||||
public string $git_repository;
|
||||
public string $git_branch;
|
||||
public string|null $git_commit_sha;
|
||||
public string $build_pack;
|
||||
|
||||
protected $rules = [
|
||||
'application.name' => 'required|min:6',
|
||||
'application.fqdn' => 'nullable',
|
||||
'application.git_repository' => 'required',
|
||||
'application.git_branch' => 'required',
|
||||
'application.git_commit_sha' => 'nullable',
|
||||
'application.build_pack' => 'required',
|
||||
'application.base_directory' => 'required',
|
||||
'application.publish_directory' => 'nullable',
|
||||
'application.environment.name' => 'required',
|
||||
'application.destination.network' => 'required',
|
||||
];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->application = Application::find($this->applicationId)->with('destination')->first();
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
$this->validate();
|
||||
$this->application->save();
|
||||
}
|
||||
}
|
||||
13
app/Http/Livewire/Application/Secrets.php
Normal file
13
app/Http/Livewire/Application/Secrets.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Application;
|
||||
|
||||
use Livewire\Component;
|
||||
|
||||
class Secrets extends Component
|
||||
{
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.application.secrets');
|
||||
}
|
||||
}
|
||||
22
app/Http/Livewire/Application/Source.php
Normal file
22
app/Http/Livewire/Application/Source.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire\Application;
|
||||
|
||||
use App\Models\Application;
|
||||
use Livewire\Component;
|
||||
|
||||
class Source extends Component
|
||||
{
|
||||
public $applicationId;
|
||||
public Application $application;
|
||||
|
||||
protected $rules = [
|
||||
'application.git_repository' => 'required',
|
||||
'application.git_branch' => 'required',
|
||||
'application.git_commit_sha' => 'nullable',
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
$this->application = Application::find($this->applicationId)->first();
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use App\Models\Application;
|
||||
use Livewire\Component;
|
||||
|
||||
class ApplicationForm extends Component
|
||||
{
|
||||
protected Application $application;
|
||||
public string $applicationId;
|
||||
public string $name;
|
||||
public string|null $fqdn;
|
||||
public string $git_repository;
|
||||
public string $git_branch;
|
||||
public string|null $git_commit_sha;
|
||||
|
||||
protected $rules = [
|
||||
'name' => 'required|min:6'
|
||||
];
|
||||
public function mount()
|
||||
{
|
||||
$this->application = Application::find($this->applicationId);
|
||||
$this->fill([
|
||||
'name' => $this->application->name,
|
||||
'fqdn' => $this->application->fqdn,
|
||||
'git_repository' => $this->application->git_repository,
|
||||
'git_branch' => $this->application->git_branch,
|
||||
'git_commit_sha' => $this->application->git_commit_sha,
|
||||
]);
|
||||
}
|
||||
public function submit()
|
||||
{
|
||||
$this->validate();
|
||||
dd($this->name);
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,4 @@ class CheckUpdate extends Component
|
||||
$this->currentVersion = config('coolify.version');
|
||||
version_compare($this->currentVersion, $this->latestVersion, '<') ? $this->updateAvailable = true : $this->updateAvailable = false;
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.check-update');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Livewire;
|
||||
|
||||
use App\Jobs\DeployApplicationJob;
|
||||
use App\Models\Application;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Livewire\Component;
|
||||
use Visus\Cuid2\Cuid2;
|
||||
|
||||
@@ -14,36 +15,31 @@ class DeployApplication extends Component
|
||||
public $status;
|
||||
public Application $application;
|
||||
public $destination;
|
||||
public array $parameters;
|
||||
|
||||
protected string $deployment_uuid;
|
||||
protected array $command = [];
|
||||
protected $source;
|
||||
|
||||
public function mount($applicationId)
|
||||
public function mount()
|
||||
{
|
||||
$this->application = Application::find($applicationId)->first();
|
||||
$this->parameters = Route::current()->parameters();
|
||||
$this->application = Application::find($this->applicationId)->first();
|
||||
$this->destination = $this->application->destination->getMorphClass()::where('id', $this->application->destination->id)->first();
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.deploy-application');
|
||||
}
|
||||
|
||||
|
||||
public function start()
|
||||
{
|
||||
// Create Deployment ID
|
||||
$this->deployment_uuid = new Cuid2(7);
|
||||
$this->parameters['deployment_uuid'] = $this->deployment_uuid;
|
||||
|
||||
dispatch(new DeployApplicationJob(
|
||||
deployment_uuid: $this->deployment_uuid,
|
||||
application_uuid: $this->application->uuid,
|
||||
));
|
||||
|
||||
$currentUrl = url()->previous();
|
||||
$deploymentUrl = "$currentUrl/deployment/$this->deployment_uuid";
|
||||
return redirect($deploymentUrl);
|
||||
return redirect()->route('project.applications.deployment', $this->parameters);
|
||||
}
|
||||
|
||||
public function stop()
|
||||
|
||||
@@ -24,9 +24,4 @@ class PollActivity extends Component
|
||||
$this->isKeepAliveOn = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.poll-activity');
|
||||
}
|
||||
}
|
||||
|
||||
19
app/Http/Livewire/PollDeployment.php
Normal file
19
app/Http/Livewire/PollDeployment.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Livewire;
|
||||
|
||||
use Livewire\Component;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class PollDeployment extends Component
|
||||
{
|
||||
public string $deployment_uuid;
|
||||
public string $created_at;
|
||||
public string $status;
|
||||
public function polling()
|
||||
{
|
||||
$activity = Activity::where('properties->deployment_uuid', '=', $this->deployment_uuid)->first();
|
||||
$this->created_at = $activity->created_at;
|
||||
$this->status = data_get($activity, 'properties.status');
|
||||
}
|
||||
}
|
||||
@@ -27,10 +27,6 @@ class RunCommand extends Component
|
||||
$this->servers = Server::all();
|
||||
$this->server = $this->servers[0]->uuid;
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.run-command');
|
||||
}
|
||||
|
||||
public function runCommand()
|
||||
{
|
||||
|
||||
@@ -19,8 +19,4 @@ class SwitchTeam extends Component
|
||||
session(['currentTeam' => $team_to_switch_to]);
|
||||
return redirect(request()->header('Referer'));
|
||||
}
|
||||
public function render()
|
||||
{
|
||||
return view('livewire.switch-team');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user