mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-25 12:38:46 -05:00
fix: peer progress bar
This commit is contained in:
@@ -24,7 +24,21 @@ class TorrentPeerController extends Controller
|
||||
public function index(int $id): \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
{
|
||||
$torrent = Torrent::withAnyStatus()->findOrFail($id);
|
||||
$peers = Peer::with(['user'])->where('torrent_id', '=', $id)->latest('seeder')->get();
|
||||
$peers = Peer::query()
|
||||
->with(['user'])
|
||||
->where('torrent_id', '=', $id)
|
||||
->latest('seeder')
|
||||
->get()
|
||||
->map(function ($peer) use ($torrent) {
|
||||
$progress = 100 * (1 - $peer->left / $torrent->size);
|
||||
$peer['progress'] = match (true) {
|
||||
0 < $progress && $progress < 1 => 1,
|
||||
99 < $progress && $progress < 100 => 99,
|
||||
default => round($progress),
|
||||
};
|
||||
|
||||
return $peer;
|
||||
});
|
||||
|
||||
return \view('torrent.peers', ['torrent' => $torrent, 'peers' => $peers]);
|
||||
}
|
||||
|
||||
@@ -83,29 +83,17 @@
|
||||
{{ $p->user->username }}</span></a>
|
||||
</td>
|
||||
@endif
|
||||
@if ($p->seeder == 0)
|
||||
<td>
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped active" role="progressbar"
|
||||
aria-valuenow="{{ ($p->downloaded / $torrent->size) * 100 }}"
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100"
|
||||
style="width: {{ ($p->downloaded / $torrent->size) * 100 }}%;">
|
||||
{{ round(($p->downloaded / $torrent->size) * 100) }}%
|
||||
</div>
|
||||
<td>
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped active" role="progressbar"
|
||||
aria-valuenow="{{ $p->progress }}"
|
||||
aria-valuemin="0"
|
||||
aria-valuemax="100"
|
||||
style="width: {{ $p->progress }}%;">
|
||||
{{ $p->progress }}%
|
||||
</div>
|
||||
</td>
|
||||
@elseif ($p->seeder == 1)
|
||||
<td>
|
||||
<div class="progress">
|
||||
<div class="progress-bar progress-bar-striped active" role="progressbar"
|
||||
aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"
|
||||
style="width: 100%;">
|
||||
100%
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@endif
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span
|
||||
class="badge-extra text-green text-bold">{{ \App\Helpers\StringHelper::formatBytes($p->uploaded, 2) }}</span>
|
||||
|
||||
Reference in New Issue
Block a user