add new resource
This commit is contained in:
@@ -19,6 +19,18 @@ class ProjectController extends Controller
|
|||||||
return view('project.environments', ['project' => $project]);
|
return view('project.environments', ['project' => $project]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function resources_new()
|
||||||
|
{
|
||||||
|
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||||
|
if (!$project) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first();
|
||||||
|
if (!$environment) {
|
||||||
|
return redirect()->route('dashboard');
|
||||||
|
}
|
||||||
|
return view('project.new', ['project' => $project, 'environment' => $environment, 'type' => 'resource']);
|
||||||
|
}
|
||||||
public function resources()
|
public function resources()
|
||||||
{
|
{
|
||||||
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
$project = session('currentTeam')->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
||||||
|
@@ -2,15 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Http\Livewire\Project\New;
|
namespace App\Http\Livewire\Project\New;
|
||||||
|
|
||||||
use App\Http\Livewire\Application\Destination;
|
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use App\Models\Git;
|
|
||||||
use App\Models\GithubApp;
|
use App\Models\GithubApp;
|
||||||
use App\Models\GitlabApp;
|
use App\Models\GitlabApp;
|
||||||
use App\Models\Project;
|
use App\Models\Project;
|
||||||
use App\Models\Server;
|
|
||||||
use App\Models\StandaloneDocker;
|
use App\Models\StandaloneDocker;
|
||||||
use App\Models\SwarmDocker;
|
use App\Models\SwarmDocker;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Spatie\Url\Url;
|
use Spatie\Url\Url;
|
||||||
|
|
||||||
@@ -18,6 +16,8 @@ class PublicGitRepository extends Component
|
|||||||
{
|
{
|
||||||
public string $public_repository_url;
|
public string $public_repository_url;
|
||||||
public int $port;
|
public int $port;
|
||||||
|
public string $type;
|
||||||
|
public $parameters;
|
||||||
|
|
||||||
public $servers;
|
public $servers;
|
||||||
public $standalone_docker;
|
public $standalone_docker;
|
||||||
@@ -42,6 +42,7 @@ class PublicGitRepository extends Component
|
|||||||
$this->public_repository_url = 'https://github.com/coollabsio/coolify-examples/tree/nodejs-fastify';
|
$this->public_repository_url = 'https://github.com/coollabsio/coolify-examples/tree/nodejs-fastify';
|
||||||
$this->port = 3000;
|
$this->port = 3000;
|
||||||
}
|
}
|
||||||
|
$this->parameters = Route::current()->parameters();
|
||||||
$this->servers = session('currentTeam')->load(['servers'])->servers;
|
$this->servers = session('currentTeam')->load(['servers'])->servers;
|
||||||
}
|
}
|
||||||
public function chooseServer($server_id)
|
public function chooseServer($server_id)
|
||||||
@@ -76,12 +77,17 @@ class PublicGitRepository extends Component
|
|||||||
$git_repository = $url->getSegment(1) . '/' . $url->getSegment(2);
|
$git_repository = $url->getSegment(1) . '/' . $url->getSegment(2);
|
||||||
$git_branch = $url->getSegment(4) ?? 'main';
|
$git_branch = $url->getSegment(4) ?? 'main';
|
||||||
|
|
||||||
$project = Project::create([
|
if ($this->type === 'project') {
|
||||||
'name' => fake()->company(),
|
$project = Project::create([
|
||||||
'description' => fake()->sentence(),
|
'name' => fake()->company(),
|
||||||
'team_id' => session('currentTeam')->id,
|
'description' => fake()->sentence(),
|
||||||
]);
|
'team_id' => session('currentTeam')->id,
|
||||||
$environment = $project->environments->first();
|
]);
|
||||||
|
$environment = $project->environments->first();
|
||||||
|
} else {
|
||||||
|
$project = Project::where('uuid', $this->parameters['project_uuid'])->firstOrFail();
|
||||||
|
$environment = $project->environments->where('name', $this->parameters['environment_name'])->firstOrFail();
|
||||||
|
}
|
||||||
$application_init = [
|
$application_init = [
|
||||||
'name' => fake()->words(2, true),
|
'name' => fake()->words(2, true),
|
||||||
'git_repository' => $git_repository,
|
'git_repository' => $git_repository,
|
||||||
|
@@ -1,17 +1,23 @@
|
|||||||
<x-layout>
|
<x-layout>
|
||||||
<h1>New Project</h1>
|
@if ($type === 'project')
|
||||||
|
<h1>New Project</h1>
|
||||||
|
@elseif ($type === 'resource')
|
||||||
|
<h1>New Resource</h1>
|
||||||
|
@endif
|
||||||
<div x-data="{ tab: window.location.hash ? window.location.hash.substring(1) : 'choose' }">
|
<div x-data="{ tab: window.location.hash ? window.location.hash.substring(1) : 'choose' }">
|
||||||
<div class="flex flex-col w-64 gap-2 mb-10">
|
<div class="flex flex-col w-64 gap-2 mb-10">
|
||||||
<button @click.prevent="tab = 'public-repo'; window.location.hash = 'public-repo'">Public Repository
|
<button @click.prevent="tab = 'public-repo'; window.location.hash = 'public-repo'">Public Repository
|
||||||
</button>
|
</button>
|
||||||
<button @click.prevent="tab = 'github-private-repo'; window.location.hash = 'github-private-repo'">Private
|
<button @click.prevent="tab = 'github-private-repo'; window.location.hash = 'github-private-repo'">Private
|
||||||
Repository (GitHub App)</button>
|
Repository (GitHub App)</button>
|
||||||
<button @click.prevent="tab = 'empty-project'; window.location.hash = 'empty-project'">Empty
|
@if ($type === 'project')
|
||||||
Project</button>
|
<button @click.prevent="tab = 'empty-project'; window.location.hash = 'empty-project'">Empty
|
||||||
|
Project</button>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div x-cloak x-show="tab === 'public-repo'">
|
<div x-cloak x-show="tab === 'public-repo'">
|
||||||
<livewire:project.new.public-git-repository />
|
<livewire:project.new.public-git-repository :type="$type" />
|
||||||
</div>
|
</div>
|
||||||
<div x-cloak x-show="tab === 'github-private-repo'">
|
<div x-cloak x-show="tab === 'github-private-repo'">
|
||||||
github-private-repo
|
github-private-repo
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
<x-layout>
|
<x-layout>
|
||||||
<h1>Resources</h1>
|
<h1>Resources <a href="{{ route('project.resources.new', Route::current()->parameters()) }}"><button>New</button></a>
|
||||||
|
</h1>
|
||||||
<div>
|
<div>
|
||||||
@foreach ($environment->applications as $application)
|
@foreach ($environment->applications as $application)
|
||||||
<p>
|
<p>
|
||||||
<a href="{{ route('project.application.configuration', [$project->uuid, $environment->name, $application->uuid]) }}">
|
<a
|
||||||
|
href="{{ route('project.application.configuration', [$project->uuid, $environment->name, $application->uuid]) }}">
|
||||||
{{ $application->name }}
|
{{ $application->name }}
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
@@ -67,12 +67,17 @@ Route::middleware(['auth'])->group(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Route::middleware(['auth'])->group(function () {
|
Route::middleware(['auth'])->group(function () {
|
||||||
Route::get('/project/new', fn () => view('project.new'))->name('project.new');
|
Route::get('/project/new', fn () => view('project.new', ['type' => 'project']))->name('project.new');
|
||||||
Route::get(
|
Route::get(
|
||||||
'/project/{project_uuid}',
|
'/project/{project_uuid}',
|
||||||
[ProjectController::class, 'environments']
|
[ProjectController::class, 'environments']
|
||||||
)->name('project.environments');
|
)->name('project.environments');
|
||||||
|
|
||||||
|
Route::get(
|
||||||
|
'/project/{project_uuid}/{environment_name}/new',
|
||||||
|
[ProjectController::class, 'resources_new']
|
||||||
|
)->name('project.resources.new');
|
||||||
|
|
||||||
Route::get(
|
Route::get(
|
||||||
'/project/{project_uuid}/{environment_name}',
|
'/project/{project_uuid}/{environment_name}',
|
||||||
[ProjectController::class, 'resources']
|
[ProjectController::class, 'resources']
|
||||||
|
Reference in New Issue
Block a user