feat(Display hostings for members)
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Models\Member;
|
|||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\DatePicker;
|
use Filament\Forms\Components\DatePicker;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\ViewField;
|
||||||
use Filament\Schemas\Components\Tabs;
|
use Filament\Schemas\Components\Tabs;
|
||||||
use Filament\Schemas\Components\Tabs\Tab;
|
use Filament\Schemas\Components\Tabs\Tab;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
@@ -158,7 +159,7 @@ class MemberForm
|
|||||||
/*
|
/*
|
||||||
| Hébergements web ISPConfig
|
| Hébergements web ISPConfig
|
||||||
*/
|
*/
|
||||||
Section::make('Hébergements Web')
|
/*Section::make('Hébergements Web')
|
||||||
->collapsible()
|
->collapsible()
|
||||||
->schema([
|
->schema([
|
||||||
RepeatableEntry::make('ispconfigs_web')
|
RepeatableEntry::make('ispconfigs_web')
|
||||||
@@ -166,24 +167,38 @@ class MemberForm
|
|||||||
->state(fn(?Member $record) => $record?->ispconfigs()
|
->state(fn(?Member $record) => $record?->ispconfigs()
|
||||||
->where('type', IspconfigType::WEB)
|
->where('type', IspconfigType::WEB)
|
||||||
->get()
|
->get()
|
||||||
|
->map(fn ($ispconfig) => $ispconfig->toArray())
|
||||||
|
->all()
|
||||||
)
|
)
|
||||||
->schema([
|
->schema([
|
||||||
TextEntry::make('data.web_domain.domain')
|
TextEntry::make('data.domain_id')
|
||||||
|
->label('ID Domaine'),
|
||||||
|
TextEntry::make('data.domain')
|
||||||
->label('Domaine'),
|
->label('Domaine'),
|
||||||
|
TextEntry::make('data.active')
|
||||||
TextEntry::make('data.web_domain.ip_address')
|
->label('État')
|
||||||
->label('Adresse IP'),
|
->formatStateUsing(fn($state) => $state == 'o' ? "Activé" : 'Désactivé'
|
||||||
|
|
||||||
TextEntry::make('data.web_domain.disk_quota')
|
|
||||||
->label('Quota disque')
|
|
||||||
->formatStateUsing(fn($state) => $state ? "{$state} Mo" : '—'
|
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
->columns(3),
|
->columns(2),
|
||||||
])
|
])
|
||||||
->visible(fn(?Member $record) => $record?->ispconfigs()
|
->visible(fn(?Member $record) => $record?->ispconfigs()
|
||||||
->where('type', IspconfigType::WEB)
|
->where('type', IspconfigType::WEB)
|
||||||
->exists()
|
->exists()
|
||||||
|
),*/
|
||||||
|
Section::make('Hébergements Web')
|
||||||
|
->collapsible()
|
||||||
|
->schema([
|
||||||
|
ViewField::make('ispconfig_web_hostings')
|
||||||
|
->view('filament.components.members.web-hostings')
|
||||||
|
->viewData(fn (?Member $record) => [
|
||||||
|
'member' => $record,
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
->visible(fn (?Member $record) =>
|
||||||
|
$record?->ispconfigs()
|
||||||
|
->where('type', IspconfigType::WEB)
|
||||||
|
->exists()
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
|
|||||||
25
app/Livewire/Ispconfig/WebHostingList.php
Normal file
25
app/Livewire/Ispconfig/WebHostingList.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire\Ispconfig;
|
||||||
|
|
||||||
|
use App\Enums\IspconfigType;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
use App\Models\Member;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class WebHostingList extends Component
|
||||||
|
{
|
||||||
|
public Member $member;
|
||||||
|
|
||||||
|
public function render(): View
|
||||||
|
{
|
||||||
|
$websites = $this->member
|
||||||
|
->ispconfigs()
|
||||||
|
->where('type', IspconfigType::WEB)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return view('livewire.ispconfig.web-hosting-list', [
|
||||||
|
'websites' => $websites,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
@livewire('ispconfig.web-hosting-list', ['member' => $member], key('web-hostings-'.$member->id))
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<div class="space-y-4">
|
||||||
|
@forelse ($websites as $hosting)
|
||||||
|
@php
|
||||||
|
$data = $hosting->data ?? [];
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<div class="border rounded-lg p-4">
|
||||||
|
<div class="grid grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<strong>Domaine</strong><br>
|
||||||
|
{{ $data['domain'] ?? '—' }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<strong>État</strong><br>
|
||||||
|
{{ ($data['active'] ?? 'n') === 'o' ? 'Activé' : 'Désactivé' }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-span-2">
|
||||||
|
<strong>Document root</strong><br>
|
||||||
|
{{ $data['document_root'] ?? '—' }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Bases de données --}}
|
||||||
|
@if (!empty($data['databases']))
|
||||||
|
<details class="mt-4">
|
||||||
|
<summary class="cursor-pointer font-medium">
|
||||||
|
Bases de données ({{ count($data['databases']) }})
|
||||||
|
</summary>
|
||||||
|
|
||||||
|
<ul class="list-disc ml-6 mt-2">
|
||||||
|
@foreach ($data['databases'] as $db)
|
||||||
|
<li>
|
||||||
|
{{ $db['database_name'] ?? '—' }}
|
||||||
|
({{ $db['database_type'] ?? '—' }})
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
{{-- Accès shell --}}
|
||||||
|
@if (!empty($data['shell_users']))
|
||||||
|
<details class="mt-4">
|
||||||
|
<summary class="cursor-pointer font-medium">
|
||||||
|
Accès shell ({{ count($data['shell_users']) }})
|
||||||
|
</summary>
|
||||||
|
|
||||||
|
<ul class="list-disc ml-6 mt-2">
|
||||||
|
@foreach ($data['shell_users'] as $user)
|
||||||
|
<li>
|
||||||
|
{{ $user['username'] ?? '—' }}
|
||||||
|
({{ $user['shell'] ?? '—' }})
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
{{-- DNS --}}
|
||||||
|
@if (!empty($data['dns_zones']))
|
||||||
|
<details class="mt-4">
|
||||||
|
<summary class="cursor-pointer font-medium">
|
||||||
|
Zones DNS ({{ count($data['dns_zones']) }})
|
||||||
|
</summary>
|
||||||
|
|
||||||
|
<ul class="list-disc ml-6 mt-2">
|
||||||
|
@foreach ($data['dns_zones'] as $zone)
|
||||||
|
<li>
|
||||||
|
{{ $zone['origin'] ?? '—' }}
|
||||||
|
– {{ $zone['ns'] ?? '—' }}
|
||||||
|
</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@empty
|
||||||
|
<p class="text-sm text-gray-500">
|
||||||
|
Aucun hébergement web.
|
||||||
|
</p>
|
||||||
|
@endforelse
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user