From 36b6bf480e74f916e216e86f26af4336aff38c3f Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 10 Jun 2023 03:40:31 -0600 Subject: [PATCH 1/2] Update admin dashboard, improve users section --- .../Controllers/Admin/AdminUserController.php | 9 ++- resources/views/admin/users/home.blade.php | 78 ++++++++++++++++++- 2 files changed, 82 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Admin/AdminUserController.php b/app/Http/Controllers/Admin/AdminUserController.php index 766299097..441f5b305 100644 --- a/app/Http/Controllers/Admin/AdminUserController.php +++ b/app/Http/Controllers/Admin/AdminUserController.php @@ -11,6 +11,7 @@ use App\Mail\AdminMessage; use Illuminate\Support\Facades\Mail; use App\Services\ModLogService; use App\Jobs\DeletePipeline\DeleteAccountPipeline; +use App\Services\AccountService; trait AdminUserController { @@ -25,7 +26,7 @@ trait AdminUserController 'next' => $offset + 1, 'query' => $search ? '&a=search&q=' . $search : null ]; - $users = User::select('id', 'username', 'status', 'profile_id') + $users = User::select('id', 'username', 'status', 'profile_id', 'is_admin') ->orderBy($col, $dir) ->when($search, function($q, $search) { return $q->where('username', 'like', "%{$search}%"); @@ -34,7 +35,11 @@ trait AdminUserController return $q->offset(($offset * 10)); }) ->limit(10) - ->get(); + ->get() + ->map(function($u) { + $u['account'] = AccountService::get($u->profile_id, true); + return $u; + }); return view('admin.users.home', compact('users', 'pagination')); } diff --git a/resources/views/admin/users/home.blade.php b/resources/views/admin/users/home.blade.php index 973d45367..cd75062a4 100644 --- a/resources/views/admin/users/home.blade.php +++ b/resources/views/admin/users/home.blade.php @@ -20,29 +20,51 @@ + {{-- --}} - + + + - @foreach($users as $user) + @foreach($users as $key => $user) @if($user->status == 'deleted') + {{-- --}} + + + @else + {{-- --}} - + + + @@ -117,5 +174,20 @@ el.text(filesize(size, {round: 0})); }); }); + + function deleteAccount(id) { + event.preventDefault(); + if(!window.confirm('Are you sure you want to delete this account?')) { + return; + } + + axios.post('/i/admin/users/delete/' + id) + .then(res => { + swal('Account Deleted', 'Successfully deleted this account! This page will refresh once you press OK.', 'success') + .then(res => { + window.location.reload(); + }); + }) + } @endpush From 8be4582fc4d9debc4fa70d8d542b96de4ca45ea9 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 10 Jun 2023 03:41:23 -0600 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02ca01467..b3eb5a14d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Update Direct Messages, fix api endpoint ([fe8728c0](https://github.com/pixelfed/pixelfed/commit/fe8728c0)) - Update nginx config ([fbdc6358](https://github.com/pixelfed/pixelfed/commit/fbdc6358)) - Update api routes, add DeprecatedEndpoint middleware. For more info, visit [pixelfed.org/kb/10404](https://pixelfed.org/kb/10404) ([a8453e77](https://github.com/pixelfed/pixelfed/commit/a8453e77)) +- Update admin dashboard, improve users section ([36b6bf48](https://github.com/pixelfed/pixelfed/commit/36b6bf48)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.8 (2023-05-29)](https://github.com/pixelfed/pixelfed/compare/v0.11.7...v0.11.8)
+ ID + Username + Status
Count
+
+ Followers
Count
+
+ Following
Count
+
Actions
+ + {{$user->id}} + + {{$user->username}} 000 Account Deleted @@ -51,10 +73,19 @@
+ + {{$user->id}} + + @if($user->account) + + @endif {{$user->username}} @if($user->is_admin) @@ -62,6 +93,27 @@ @endif + @if($user->account) + {{$user->account['statuses_count']}} + @else + 0 + @endif + + @if($user->account) + {{$user->account['followers_count']}} + @else + 0 + @endif + + @if($user->account) + {{$user->account['following_count']}} + @else + 0 + @endif + @@ -75,6 +127,11 @@ Mod Tools + @if($user->status !== 'deleted' && !$user->is_admin) + + Delete + + @endif