diff --git a/app/Http/Controllers/ApplicationController.php b/app/Http/Controllers/ApplicationController.php new file mode 100644 index 000000000..ca7c4b659 --- /dev/null +++ b/app/Http/Controllers/ApplicationController.php @@ -0,0 +1,67 @@ +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, + ]); + } +} diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 1bcb848f7..17cbdf8e3 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -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, ]); diff --git a/app/Http/Livewire/Application/Destination.php b/app/Http/Livewire/Application/Destination.php new file mode 100644 index 000000000..a630941cc --- /dev/null +++ b/app/Http/Livewire/Application/Destination.php @@ -0,0 +1,10 @@ + '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(); + } +} diff --git a/app/Http/Livewire/Application/Secrets.php b/app/Http/Livewire/Application/Secrets.php new file mode 100644 index 000000000..c94e0e4a4 --- /dev/null +++ b/app/Http/Livewire/Application/Secrets.php @@ -0,0 +1,13 @@ + 'required', + 'application.git_branch' => 'required', + 'application.git_commit_sha' => 'nullable', + ]; + public function mount() + { + $this->application = Application::find($this->applicationId)->first(); + } +} diff --git a/app/Http/Livewire/ApplicationForm.php b/app/Http/Livewire/ApplicationForm.php deleted file mode 100644 index dc1d2d572..000000000 --- a/app/Http/Livewire/ApplicationForm.php +++ /dev/null @@ -1,37 +0,0 @@ - '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); - } -} diff --git a/app/Http/Livewire/CheckUpdate.php b/app/Http/Livewire/CheckUpdate.php index 17b83387e..964c360f0 100644 --- a/app/Http/Livewire/CheckUpdate.php +++ b/app/Http/Livewire/CheckUpdate.php @@ -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'); - } } diff --git a/app/Http/Livewire/DeployApplication.php b/app/Http/Livewire/DeployApplication.php index 8531ed7db..c1adcbcee 100644 --- a/app/Http/Livewire/DeployApplication.php +++ b/app/Http/Livewire/DeployApplication.php @@ -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() diff --git a/app/Http/Livewire/PollActivity.php b/app/Http/Livewire/PollActivity.php index da8ed5252..b10fc8da6 100644 --- a/app/Http/Livewire/PollActivity.php +++ b/app/Http/Livewire/PollActivity.php @@ -24,9 +24,4 @@ class PollActivity extends Component $this->isKeepAliveOn = false; } } - - public function render() - { - return view('livewire.poll-activity'); - } } diff --git a/app/Http/Livewire/PollDeployment.php b/app/Http/Livewire/PollDeployment.php new file mode 100644 index 000000000..d58cf4f24 --- /dev/null +++ b/app/Http/Livewire/PollDeployment.php @@ -0,0 +1,19 @@ +deployment_uuid', '=', $this->deployment_uuid)->first(); + $this->created_at = $activity->created_at; + $this->status = data_get($activity, 'properties.status'); + } +} diff --git a/app/Http/Livewire/RunCommand.php b/app/Http/Livewire/RunCommand.php index 5bb84a56f..9eaa2bbd1 100755 --- a/app/Http/Livewire/RunCommand.php +++ b/app/Http/Livewire/RunCommand.php @@ -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() { diff --git a/app/Http/Livewire/SwitchTeam.php b/app/Http/Livewire/SwitchTeam.php index edb68852a..089ccf76b 100644 --- a/app/Http/Livewire/SwitchTeam.php +++ b/app/Http/Livewire/SwitchTeam.php @@ -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'); - } } diff --git a/app/Jobs/DeployApplicationJob.php b/app/Jobs/DeployApplicationJob.php index f9a6e1a07..ff06a92ea 100644 --- a/app/Jobs/DeployApplicationJob.php +++ b/app/Jobs/DeployApplicationJob.php @@ -124,7 +124,7 @@ class DeployApplicationJob implements ShouldQueue $image = explode(':', str_replace('"', '', $image))[1]; if ($image == $this->git_commit) { $this->executeNow([ - "echo 'Application found locally with the same Git Commit SHA. Starting it...'" + "echo -n 'Application found locally with the same Git Commit SHA. Starting it... '" ]); $this->executeNow([ "docker start {$this->application->uuid}" diff --git a/app/View/Components/Input.php b/app/View/Components/Input.php index e907fd024..16897aef1 100644 --- a/app/View/Components/Input.php +++ b/app/View/Components/Input.php @@ -11,8 +11,12 @@ class Input extends Component /** * Create a new component instance. */ - public function __construct(public string $name, public bool $required = false) - { + public function __construct( + public string $name, + public bool $required = false, + public bool $readonly = false, + public string|null $label = null, + ) { // } diff --git a/resources/js/app.js b/resources/js/app.js index e59d6a0ad..401533aec 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -1 +1,2 @@ import './bootstrap'; + diff --git a/resources/views/components/applications/layout.blade.php b/resources/views/components/applications/layout.blade.php new file mode 100644 index 000000000..abc1bbd99 --- /dev/null +++ b/resources/views/components/applications/layout.blade.php @@ -0,0 +1,7 @@ + +

{{ $title ?? 'NOT SET' }}

+ +
+ {{ $slot }} +
+
diff --git a/resources/views/components/applications/navbar.blade.php b/resources/views/components/applications/navbar.blade.php new file mode 100644 index 000000000..84112940d --- /dev/null +++ b/resources/views/components/applications/navbar.blade.php @@ -0,0 +1,5 @@ + diff --git a/resources/views/components/input.blade.php b/resources/views/components/input.blade.php index d1fcbf57c..5abd7953d 100644 --- a/resources/views/components/input.blade.php +++ b/resources/views/components/input.blade.php @@ -1,6 +1,16 @@ - - + + @error($name) {{ $message }} @enderror diff --git a/resources/views/components/layout.blade.php b/resources/views/components/layout.blade.php index 33431c531..60e6a41a3 100644 --- a/resources/views/components/layout.blade.php +++ b/resources/views/components/layout.blade.php @@ -7,6 +7,8 @@ {{ $title ?? 'Coolify' }} @vite(['resources/js/app.js', 'resources/css/app.css']) + + @livewireStyles diff --git a/resources/views/components/navbar.blade.php b/resources/views/components/navbar.blade.php index 3427f2adc..87d944886 100644 --- a/resources/views/components/navbar.blade.php +++ b/resources/views/components/navbar.blade.php @@ -1,4 +1,4 @@ -