mirror of
https://github.com/tiennm99/coolify.git
synced 2026-08-20 04:23:34 +00:00
Add project icon storage and serving with local/S3 support, prevent deletion of compose-managed volumes, and optimize volume backups. Refine project and backup UI components with consistent styling and coverage.
77 lines
2.8 KiB
PHP
77 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Project;
|
|
|
|
use App\Models\Project;
|
|
use Illuminate\Contracts\View\View;
|
|
use Livewire\Component;
|
|
|
|
class Index extends Component
|
|
{
|
|
public $projects;
|
|
|
|
public function mount(): void
|
|
{
|
|
// Only load what the page renders. Servers/private keys were previously
|
|
// hydrated into public Livewire state but never used by the view.
|
|
$this->projects = Project::ownedByCurrentTeam()
|
|
->with(['environments:id,uuid,name,project_id'])
|
|
->withCount([
|
|
'applications',
|
|
'services',
|
|
'postgresqls',
|
|
'redis',
|
|
'keydbs',
|
|
'dragonflies',
|
|
'clickhouses',
|
|
'mongodbs',
|
|
'mysqls',
|
|
'mariadbs',
|
|
])
|
|
->get();
|
|
}
|
|
|
|
public function render(): View
|
|
{
|
|
return view('livewire.project.index', [
|
|
'projectsJs' => $this->projects->map(function (Project $project): array {
|
|
$firstEnvironment = $project->environments->first();
|
|
$resourceCount = collect([
|
|
$project->applications_count,
|
|
$project->services_count,
|
|
$project->postgresqls_count,
|
|
$project->redis_count,
|
|
$project->keydbs_count,
|
|
$project->dragonflies_count,
|
|
$project->clickhouses_count,
|
|
$project->mongodbs_count,
|
|
$project->mysqls_count,
|
|
$project->mariadbs_count,
|
|
])->sum();
|
|
|
|
return [
|
|
'uuid' => $project->uuid,
|
|
'name' => $project->name,
|
|
'description' => $project->description,
|
|
'iconUrl' => $project->icon_path ? route('project.icon', [
|
|
'project_uuid' => $project->uuid,
|
|
'v' => $project->updated_at->timestamp,
|
|
]) : null,
|
|
'href' => $project->navigateTo(),
|
|
'environmentCount' => $project->environments->count(),
|
|
'resourceCount' => $resourceCount,
|
|
'settingsHref' => auth()->user()->can('update', $project)
|
|
? route('project.edit', ['project_uuid' => $project->uuid])
|
|
: null,
|
|
'addResourceHref' => $firstEnvironment && auth()->user()->can('createAnyResource')
|
|
? route('project.resource.create', [
|
|
'project_uuid' => $project->uuid,
|
|
'environment_uuid' => $firstEnvironment->uuid,
|
|
])
|
|
: null,
|
|
];
|
|
})->values()->toArray(),
|
|
]);
|
|
}
|
|
}
|