Show Client running out of Credits in Admin overview

This commit is contained in:
WBLKLeipe 2021-11-08 11:52:09 +01:00
parent 3fac4f87c0
commit 88944235f2
4 changed files with 30 additions and 2 deletions

View file

@ -251,7 +251,7 @@ class UserController extends Controller
return '<i class="fas fa-coins mr-2"></i> ' . $user->credits();
})
->addColumn('usage', function (User $user) {
return '<i class="fas fa-coins mr-2"></i> ' . $user->creditUsage();
return '<i class="fas fa-coins mr-2"></i> ' . $user->creditUsage(). ' ('.$user->outOfCredits().')';
})
->addColumn('verified', function (User $user) {
return $user->getVerifiedStatus();

View file

@ -242,6 +242,20 @@ class User extends Authenticatable implements MustVerifyEmail
return number_format($usage, 2, '.', '');
}
public function outOfCredits()
{
$usage = $this->creditUsage();
$credits = $this->credits;
$timeLeft = number_format(($credits*30)/$usage);
$unit = "days";
if($timeLeft < 1){
$timeLeft = number_format(($credits*30)/$usage*24,2);
$unit = "hours";
}
return $timeLeft." ".$unit;
}
/**
* @return array|string|string[]
*/

View file

@ -46,7 +46,7 @@
<th>Role</th>
<th>Email</th>
<th>{{CREDITS_DISPLAY_NAME}}</th>
<th>Usage</th>
<th>Usage (Out of Credits in..)</th>
<th>Servers</th>
<th>Verified</th>
<th>Last seen</th>

View file

@ -184,6 +184,7 @@
</div>
</div>
<div class="col-lg-6">
<div class="row">
<div class="col-lg-4">
@ -197,6 +198,19 @@
</div>
</div>
<div class="col-lg-6">
<div class="row">
<div class="col-lg-4">
<label>Out of Credits in</label>
</div>
<div class="col-lg-8">
<span style="max-width: 250px;" class="d-inline-block text-truncate">
<i class="fas fa-clock mr-2"></i>{{$user->OutOfCredits()}}
</span>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="row">
<div class="col-lg-4">