diff --git a/app/Http/Livewire/Server/ServerCard.php b/app/Http/Livewire/Server/ServerCard.php index 582b92c30..d159e60f8 100644 --- a/app/Http/Livewire/Server/ServerCard.php +++ b/app/Http/Livewire/Server/ServerCard.php @@ -17,7 +17,7 @@ public function mount(Server $server) public function reactivate() { - Artisan::call('ping:server '.$this->server->uuid.' true'); + Artisan::call('server:ping '.$this->server->uuid.' true'); $this->server->active = true; $this->server->save(); $this->emit('serverUpdated'); diff --git a/app/Http/Livewire/Server/ServerCardList.php b/app/Http/Livewire/Server/ServerCardList.php index b2a01e934..2d95feceb 100644 --- a/app/Http/Livewire/Server/ServerCardList.php +++ b/app/Http/Livewire/Server/ServerCardList.php @@ -9,28 +9,42 @@ class ServerCardList extends Component { public $servers; + public $my_servers; + + public $user; + protected $listeners = [ 'serverUpdated' => 'update', ]; public function mount() { - $this->servers = Server::orderBy('official', 'desc') - ->orderBy('last_online_at', 'desc') - ->orderBy('ping', 'asc') - ->get(); + $this->loadData(); } public function update() { - $this->servers = Server::orderBy('official', 'desc') - ->orderBy('last_online_at', 'desc') - ->orderBy('ping', 'asc') - ->get(); + $this->loadData(); } public function render() { return view('livewire.server.server-card-list'); } + + private function loadData(): void + { + $this->user = auth()->user() ?? null; + $this->servers = isset($this->user) ? Server::where('user_id', '!=', $this->user->id) + ->where('active', true) + ->orderBy('official', 'desc') + ->orderBy('last_online_at', 'desc') + ->orderBy('ping', 'asc') + ->get() : Server::orderBy('official', 'desc') + ->where('active', true) + ->orderBy('last_online_at', 'desc') + ->orderBy('ping', 'asc') + ->get(); + $this->my_servers = isset($this->user) ? Server::where('user_id', $this->user->id)->get() : collect(); + } } diff --git a/resources/views/livewire/server/server-card-list.blade.php b/resources/views/livewire/server/server-card-list.blade.php index abca12ac9..393998dfc 100644 --- a/resources/views/livewire/server/server-card-list.blade.php +++ b/resources/views/livewire/server/server-card-list.blade.php @@ -1,10 +1,17 @@
-
-

{{ __('All server statuses are updated every hour.') }}

-
- @foreach ($this->servers as $server) +

{{ __('All server statuses are updated every hour.') }}

+ @if($this->my_servers->count() > 0) +

{{ __('Your servers') }}:

+
+ @foreach($this->my_servers as $server) @livewire('server.server-card', ['server' => $server]) @endforeach
+
+ @endif +
+ @foreach($this->servers as $server) + @livewire('server.server-card', ['server' => $server]) + @endforeach
-
\ No newline at end of file +
diff --git a/resources/views/livewire/server/server-card.blade.php b/resources/views/livewire/server/server-card.blade.php index 3ee5a4354..c41028e25 100644 --- a/resources/views/livewire/server/server-card.blade.php +++ b/resources/views/livewire/server/server-card.blade.php @@ -1,91 +1,104 @@
- @if($this->server->active) -
-
- @auth - @if(auth()->user()->id == $this->server->user_id) -
- -
- @if(!$this->server->active) - - @endif - - - - - @lang('Edit') - - +
+ @if(!$this->server->active) + -
+ @endif + + + + + @lang('Edit') + +
- @endif - @endauth -
+
+ @endif + @endauth +
-

{{ $this->server->name }}

- @if($this->server->official) -
- Official -
-
- {{ __('This means that the server is maintained by the P3D team') }} -
- - - +

{{ $this->server->name }}

+ @if($this->server->official) +
+ {{ __('Official') }} +
+
+ {{ __('This means that the server is maintained by the P3D team') }}
+ + +
- @endif - @if($this->server->created_at > now()->subDays(7)) -
- New -
-
- {{ __('This server was added in the last seven days') }} -
- - - +
+ @endif + @if($this->server->created_at > now()->subDays(7)) +
+ {{ __('New') }} +
+
+ {{ __('This server was added in the last seven days') }}
+ + +
- @endif - @if($this->server->ping) -
- {{ $this->server->ping }} -
-
- {{ __('The ping relative to the server from this website') }} -
- - - +
+ @endif + @if($this->server->ping) +
+ {{ $this->server->ping }} +
+
+ {{ __('The ping relative to the server from this website') }}
+ + +
- @endif - @if(!$this->server->ping && $this->server->last_check_at) +
+ @endif + @if(!$this->server->ping && $this->server->last_check_at) +
+ {{ __('Offline') }} +
+
+ {{ __('Last checked: :time', ['time'=>$this->server->last_check_at->diffForHumans()]) }} +
+ + + +
+
+ @endif + @auth + @if($this->server->user_id == auth()->user()->id && !$this->server->active)
- Offline + {{ __('Deactivated') }}
- {{ __('Last checked: :time', ['time'=>$this->server->last_check_at->diffForHumans()]) }} + {{ __('Deactivated because of downtime for the past 24 hours') }}
@@ -93,61 +106,46 @@
@endif - @auth - @if(!$this->server->active && $this->server->user_id == auth()->user()->id) -
- Deactivated -
-
- {{ __('Deactivated because of downtime for the past 24 hours') }} -
- - - -
-
- @endif - @endauth -
-

{{ $this->server->description }}

-

{{ $this->server->host }}:{{ $this->server->port }}

- @auth - @if (!$this->server->active && $this->server->user_id == auth()->user()->id) - - @endif @endauth - @if($this->server->official) -
+
+

{{ $this->server->description }}

+

{{ $this->server->host }}:{{ $this->server->port }}

+ @auth + @if ($this->server->user_id == auth()->user()->id && !$this->server->active) + + @endif + @endauth + @if($this->server->official) +
+
+ profil +
+
+

+ {{ __('The P3D Team') }} +

+
+
+ @else + - @else - - @endif -
+ +
+ @endif
- @endif +