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