mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 21:43:17 +00:00
Update admin dashboard
This commit is contained in:
parent
8e7f4000b6
commit
6751aa4ea6
2 changed files with 7 additions and 131 deletions
|
@ -105,10 +105,9 @@ class AdminController extends Controller
|
|||
{
|
||||
$col = $request->query('col') ?? 'id';
|
||||
$dir = $request->query('dir') ?? 'desc';
|
||||
$stats = $this->collectUserStats($request);
|
||||
$users = User::withCount('statuses')->orderBy($col, $dir)->simplePaginate(10);
|
||||
$users = User::select('id', 'username', 'status')->withCount('statuses')->orderBy($col, $dir)->simplePaginate(10);
|
||||
|
||||
return view('admin.users.home', compact('users', 'stats'));
|
||||
return view('admin.users.home', compact('users'));
|
||||
}
|
||||
|
||||
public function editUser(Request $request, $id)
|
||||
|
@ -158,34 +157,6 @@ class AdminController extends Controller
|
|||
return view('admin.reports.show', compact('report'));
|
||||
}
|
||||
|
||||
protected function collectUserStats($request)
|
||||
{
|
||||
$total_duration = $request->query('total_duration') ?? '30';
|
||||
$new_duration = $request->query('new_duration') ?? '7';
|
||||
$stats = [];
|
||||
$stats['total'] = [
|
||||
'count' => User::where('created_at', '>', Carbon::now()->subDays($total_duration))->count(),
|
||||
'points' => 0//User::selectRaw(''.$day.'created_at) day, count(*) as count')->where('created_at','>', Carbon::now()->subDays($total_duration))->groupBy('day')->pluck('count')
|
||||
];
|
||||
$stats['new'] = [
|
||||
'count' => User::where('created_at', '>', Carbon::now()->subDays($new_duration))->count(),
|
||||
'points' => 0//User::selectRaw(''.$day.'created_at) day, count(*) as count')->where('created_at','>', Carbon::now()->subDays($new_duration))->groupBy('day')->pluck('count')
|
||||
];
|
||||
$stats['active'] = [
|
||||
'count' => Status::groupBy('profile_id')->count()
|
||||
];
|
||||
$stats['profile'] = [
|
||||
'local' => Profile::whereNull('remote_url')->count(),
|
||||
'remote' => Profile::whereNotNull('remote_url')->count()
|
||||
];
|
||||
$stats['avg'] = [
|
||||
'likes' => floor(Like::average('profile_id')),
|
||||
'posts' => floor(Status::avg('profile_id'))
|
||||
];
|
||||
return $stats;
|
||||
|
||||
}
|
||||
|
||||
public function profiles(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
|
|
|
@ -13,98 +13,6 @@
|
|||
<h3 class="font-weight-bold">Users</h3>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row mb-3">
|
||||
{{-- <div class="col-12 col-md-6 mb-2">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<span class="font-weight-bold text-muted">Total Users</span>
|
||||
<span>
|
||||
<select class="feature-filter form-control form-control-sm bg-light border-0" data-id="total" data-duration="{{request()->query('total_duration') ?? 30}}">
|
||||
<option data-duration="1">1 Day</option>
|
||||
<option data-duration="14">2 Weeks</option>
|
||||
<option data-duration="30" selected="">1 Month</option>
|
||||
<option data-duration="365">1 Year</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<p class="h3 font-weight-bold mb-0">{{$stats['total']['count']}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="totalUsers pb-2"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 mb-2">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<span class="font-weight-bold text-muted">New Users</span>
|
||||
<span>
|
||||
<select class="form-control form-control-sm bg-light border-0">
|
||||
<option>1 Day</option>
|
||||
<option>2 Weeks</option>
|
||||
<option selected="">1 Month</option>
|
||||
<option>1 Year</option>
|
||||
</select>
|
||||
</span>
|
||||
</div>
|
||||
<div>
|
||||
<p class="h3 font-weight-bold mb-0">{{$stats['new']['count']}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="newUsers pb-2"></div>
|
||||
</div>
|
||||
</div> --}}
|
||||
<div class="col-12 col-md-3 mb-2">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<span class="font-weight-bold text-muted">Local</span>
|
||||
</div>
|
||||
<div>
|
||||
<p class="h3 font-weight-bold mb-0">{{$stats['profile']['local']}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-3 mb-2">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<span class="font-weight-bold text-muted">Remote</span>
|
||||
</div>
|
||||
<div>
|
||||
<p class="h3 font-weight-bold mb-0">{{$stats['profile']['remote']}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-3 mb-2">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<span class="font-weight-bold text-muted">Avg Likes</span>
|
||||
</div>
|
||||
<div>
|
||||
<p class="h3 font-weight-bold mb-0">{{$stats['avg']['likes']}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-3 mb-2">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between">
|
||||
<span class="font-weight-bold text-muted">Avg Posts</span>
|
||||
</div>
|
||||
<div>
|
||||
<p class="h3 font-weight-bold mb-0">{{$stats['avg']['posts']}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead class="bg-light">
|
||||
|
@ -128,27 +36,24 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
@foreach($users as $user)
|
||||
@if($user->status == 'deleted')
|
||||
@continue
|
||||
@endif
|
||||
<tr class="font-weight-bold text-center user-row">
|
||||
<th scope="row">
|
||||
{{$user->id}}
|
||||
<span class="{{$user->status == 'deleted' ? 'text-danger':''}}">{{$user->id}}</span>
|
||||
</th>
|
||||
<td class="text-left">
|
||||
<img src="{{$user->profile->avatarUrl()}}" width="28px" class="rounded-circle mr-2" style="border:1px solid #ccc">
|
||||
<img src="{{$user->profile ? $user->profile->avatarUrl() : '/storage/avatars/default.png?v=1'}}" width="28px" class="rounded-circle mr-2" style="border:1px solid #ccc">
|
||||
<span title="{{$user->username}}" data-toggle="tooltip" data-placement="bottom">
|
||||
{{$user->username}}
|
||||
<span class="{{$user->status == 'deleted' ? 'text-danger':''}}">{{$user->username}}</span>
|
||||
@if($user->is_admin)
|
||||
<i class="text-danger fas fa-certificate" title="Admin"></i>
|
||||
@endif
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{{$user->profile->statusCount()}}
|
||||
<span class="{{$user->status == 'deleted' ? 'text-danger':''}}">{{$user->profile ? $user->profile->statusCount() : 0}}</span>
|
||||
</td>
|
||||
<td>
|
||||
<p class="human-size mb-0" data-bytes="{{App\Media::whereUserId($user->id)->sum('size')}}"></p>
|
||||
<span class="{{$user->status == 'deleted' ? 'text-danger':''}}"><p class="human-size mb-0" data-bytes="{{App\Media::whereUserId($user->id)->sum('size')}}"></p></span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="action-row font-weight-lighter">
|
||||
|
|
Loading…
Reference in a new issue