Skip to content

Commit

Permalink
Merge pull request #292 from P3D-Legacy/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dsbilling authored Aug 8, 2023
2 parents 33e19b4 + 7dd25f2 commit a26f80d
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 134 deletions.
2 changes: 1 addition & 1 deletion app/Http/Livewire/Server/ServerCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
30 changes: 22 additions & 8 deletions app/Http/Livewire/Server/ServerCardList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
17 changes: 12 additions & 5 deletions resources/views/livewire/server/server-card-list.blade.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<div class="flex flex-col">
<div class="-my-2 sm:-mx-6 lg:-mx-8">
<p class="pt-4 pb-1 text-center text-gray-300 dark:text-gray-600">{{ __('All server statuses are updated every hour.') }}</p>
<div class="grid grid-cols-1 gap-4 sm:p-10 sm:grid-cols-2 md:grid-cols-3 auto-rows-auto grid-flow-rows">
@foreach ($this->servers as $server)
<p class="pt-4 pb-1 text-center text-gray-300 dark:text-gray-600">{{ __('All server statuses are updated every hour.') }}</p>
@if($this->my_servers->count() > 0)
<h1 class="text-xl text-gray-600 dark:text-gray-300">{{ __('Your servers') }}:</h1>
<div class="grid grid-cols-1 gap-4 sm:p-5 sm:grid-cols-2 md:grid-cols-3 auto-rows-auto grid-flow-rows">
@foreach($this->my_servers as $server)
@livewire('server.server-card', ['server' => $server])
@endforeach
</div>
<div class="border-t my-8 border-dotted border-gray-300 dark:border-gray-600"></div>
@endif
<div class="grid grid-cols-1 gap-4 sm:p-5 sm:grid-cols-2 md:grid-cols-3 auto-rows-auto grid-flow-rows">
@foreach($this->servers as $server)
@livewire('server.server-card', ['server' => $server])
@endforeach
</div>
</div>
</div>
Loading

0 comments on commit a26f80d

Please sign in to comment.