Skip to content

Commit

Permalink
Redesigned Admin Dashboard Reports/Moderation
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup committed Apr 24, 2023
1 parent ae6dd4e commit c6cc632
Show file tree
Hide file tree
Showing 8 changed files with 1,651 additions and 94 deletions.
598 changes: 598 additions & 0 deletions app/Http/Controllers/Admin/AdminReportController.php

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions app/Http/Resources/AdminReport.php
@@ -0,0 +1,38 @@
<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Services\AccountService;
use App\Services\StatusService;

class AdminReport extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$res = [
'id' => $this->id,
'reporter' => AccountService::get($this->profile_id, true),
'type' => $this->type,
'object_id' => (string) $this->object_id,
'object_type' => $this->object_type,
'reported' => AccountService::get($this->reported_profile_id, true),
'status' => null,
'reporter_message' => $this->message,
'admin_seen_at' => $this->admin_seen,
'created_at' => $this->created_at,
];

if($this->object_id && $this->object_type === 'App\Status') {
$res['status'] = StatusService::get($this->object_id, false);
}

return $res;
}
}
33 changes: 33 additions & 0 deletions app/Http/Resources/AdminSpamReport.php
@@ -0,0 +1,33 @@
<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use App\Services\AccountService;
use App\Services\StatusService;

class AdminSpamReport extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
$res = [
'id' => $this->id,
'type' => $this->type,
'status' => null,
'read_at' => $this->read_at,
'created_at' => $this->created_at,
];

if($this->item_id && $this->item_type === 'App\Status') {
$res['status'] = StatusService::get($this->item_id, false);
}

return $res;
}
}
937 changes: 937 additions & 0 deletions resources/assets/components/admin/AdminReports.vue

Large diffs are not rendered by default.

97 changes: 8 additions & 89 deletions resources/views/admin/reports/home.blade.php
@@ -1,93 +1,12 @@
@extends('admin.partial.template-full')

@section('section')
<div class="title mb-3 d-flex justify-content-between align-items-center">
<h3 class="font-weight-bold d-inline-block">Reports</h3>
<div class="float-right">
@if(request()->has('filter') && request()->filter == 'closed')
<a class="mr-3 font-weight-light small text-muted" href="{{route('admin.reports')}}">
View Open Reports
</a>
@else
<a class="mr-3 font-weight-light small text-muted" href="{{route('admin.reports',['filter'=>'closed'])}}">
View Closed Reports
</a>
@endif
</div>
</div>

<div class="col-12 col-md-8 offset-md-2">
<div class="mb-4">
<a class="btn btn-outline-primary px-5 py-3 mr-3" href="/i/admin/reports/email-verifications">
<p class="font-weight-bold h4 mb-0">{{$mailVerifications}}</p>
Email Verify {{$mailVerifications == 1 ? 'Request' : 'Requests'}}
</a>
<a class="btn btn-outline-primary px-5 py-3 mr-3" href="/i/admin/reports/appeals">
<p class="font-weight-bold h4 mb-0">{{$ai}}</p>
Appeal {{$ai == 1 ? 'Request' : 'Requests'}}
</a>
<a class="btn btn-outline-primary px-5 py-3" href="/i/admin/reports/autospam">
<p class="font-weight-bold h4 mb-0">{{$spam}}</p>
Flagged {{$ai == 1 ? 'Post' : 'Posts'}}
</a>
</div>
</div>
@if($reports->count())
<div class="col-12 col-md-8 offset-md-2">
<div class="card shadow-none border">
<div class="list-group list-group-flush">
@foreach($reports as $report)
<div class="list-group-item p-1 {{$report->admin_seen ? 'bg-light' : 'bg-white'}}">
<div class="p-0">
<div class="media d-flex align-items-center">
<a class="text-decoration-none" href="{{$report->url()}}">
<img src="{{$report->status->media && $report->status->media->count() ? $report->status->thumb(true) : '/storage/no-preview.png'}}" width="64" height="64" class="rounded border shadow mr-3" style="object-fit: cover">
</a>
<div class="media-body">
<p class="mb-1 small"><span class="font-weight-bold text-uppercase text-danger">{{$report->type}}</span></p>
@if($report->reporter && $report->status)
<p class="mb-0"><a class="font-weight-bold text-dark" href="{{$report->reporter->url()}}">{{$report->reporter->username}}</a> reported this <a href="{{$report->status->url()}}" class="font-weight-bold text-dark">post</a></p>
@else
<p class="mb-0 lead">
@if(!$report->reporter)
<span class="font-weight-bold text-dark">Deleted user</span>
@else
<a class="font-weight-bold text-dark" href="{{$report->reporter->url()}}">{{$report->reporter->username}}</a>
@endif
reported this
@if(!$report->status)
<span class="font-weight-bold text-muted">deleted post</span>
@else
<a href="{{$report->status->url()}}" class="font-weight-bold text-dark">post</a>
@endif

</p>

@endif
</div>
<div class="float-right">
@if($report->status)
<a class="text-lighter p-2 text-decoration-none" href="{{$report->url()}}">
View <i class="fas fa-chevron-right ml-2"></i>
</a>
@endif
</div>
</div>
</div>
</div>
@endforeach
</div>
</div>
</div>
@else
<div class="card shadow-none border">
<div class="card-body">
<p class="mb-0 p-5 text-center font-weight-bold lead">No reports found</p>
</div>
</div>
@endif

<div class="d-flex justify-content-center mt-5 small">
{{$reports->appends(['layout'=>request()->layout, 'filter' => request()->filter])->links()}}
</div>
</div>
<admin-reports />
@endsection

@push('scripts')
<script type="text/javascript">
new Vue({ el: '#panel'});
</script>
@endpush
16 changes: 13 additions & 3 deletions resources/views/admin/reports/show.blade.php
@@ -1,6 +1,14 @@
@extends('admin.partial.template-full')

@section('section')
<div class="bg-primary px-4 py-3 mb-5 rounded d-flex align-items-center justify-content-between">
<div style="max-width: 70%;">
<p class="lead text-white my-0 font-weight-bold">Try the new Report UI</p>
<p class="text-white small mb-0">We are deprecating this Report UI in the next major version release. The updated Report UI is easier, faster and provides more options to handle reports and spam.</p>
</div>
<a href="/i/admin/reports?tab=report&id={{$report->id}}" class="btn btn-outline-white">View in new Report UI</a>
</div>

<div class="d-flex justify-content-between title mb-3">
<div>
<p class="font-weight-bold h3">
Expand All @@ -16,16 +24,17 @@
<div class="row">
<div class="col-12 col-md-8 mt-3">
<div class="card shadow-none border">
@if($report->status->media()->count())
@if($report->status && $report->status->media()->count())
<img class="card-img-top border-bottom" src="{{$report->status->thumb(true)}}">
@endif
<div class="card-body">
<div class="mt-2 p-3">
@if($report->status->caption)
@if($report->status && $report->status->caption)
<p class="text-break">
{{$report->status->media()->count() ? 'Caption' : 'Comment'}}: <span class="font-weight-bold">{{$report->status->caption}}</span>
</p>
@endif
@if($report->status)
<p class="mb-0">
Like Count: <span class="font-weight-bold">{{$report->status->likes_count}}</span>
</p>
Expand All @@ -41,7 +50,8 @@
<p class="" style="word-break: break-all !important;">
Local URL: <span class="font-weight-bold text-primary"><a href="/i/web/post/{{$report->status->id}}">{{url('/i/web/post/' . $report->status->id)}}</a></span>
</p>
@if($report->status->in_reply_to_id)
@endif
@if($report->status && $report->status->in_reply_to_id)
<p class="mt-n3" style="word-break: break-all !important;">
Parent Post: <span class="font-weight-bold text-primary"><a href="/i/web/post/{{$report->status->in_reply_to_id}}">{{url('/i/web/post/' . $report->status->in_reply_to_id)}}</a></span>
</p>
Expand Down
19 changes: 17 additions & 2 deletions resources/views/admin/reports/show_spam.blade.php
@@ -1,6 +1,13 @@
@extends('admin.partial.template-full')

@section('section')
<div class="bg-primary px-4 py-3 mb-5 rounded d-flex align-items-center justify-content-between">
<div style="max-width: 70%;">
<p class="lead text-white my-0 font-weight-bold">Try the new Report UI</p>
<p class="text-white small mb-0">We are deprecating this Report UI in the next major version release. The updated Report UI is easier, faster and provides more options to handle reports and spam.</p>
</div>
<a href="/i/admin/reports?tab=autospam&id={{$appeal->id}}" class="btn btn-outline-white">View in new Report UI</a>
</div>
<div class="d-flex justify-content-between title mb-3">
<div>
<p class="font-weight-bold h3">Autospam</p>
Expand All @@ -15,7 +22,7 @@
<div class="card shadow-none border">
<div class="card-header bg-light h5 font-weight-bold py-4">Unlisted + Content Warning</div>
@if($appeal->has_media)
<img class="card-img-top border-bottom" src="{{$appeal->status->thumb(true)}}" style="max-height: 40vh;object-fit: contain;">
<img class="card-img-top border-bottom" src="{{$appeal->status->thumb(true)}}" style="max-height: 40vh;object-fit: contain;" onerror="this.onerror=null;this.src='/storage/no-preview.png?v=0'">
@endif
<div class="card-body">
<div class="mt-2 p-3">
Expand All @@ -34,7 +41,7 @@
Timestamp: <span class="font-weight-bold">{{now()->parse($meta->created_at)->format('r')}}</span>
</p>
<p class="" style="word-break: break-all !important;">
URL: <span class="font-weight-bold text-primary"><a href="{{$meta->url}}">{{$meta->url}}</a></span>
URL: <span class="font-weight-bold text-primary"><a href="/i/web/post/{{$appeal->item_id}}" target="_blank">{{$meta->url}}</a></span>
</p>
</div>
</div>
Expand All @@ -49,6 +56,8 @@
<hr>
<button type="button" class="btn btn-default border btn-block font-weight-bold mb-3 action-btn" data-action="dismiss-all">Mark all as read</button>
<button type="button" class="btn btn-light border btn-block font-weight-bold mb-3 action-btn" data-action="approve-all">Mark all as not spam</button>
<hr>
<button type="button" class="btn btn-light border btn-block font-weight-bold mb-3 action-btn" data-action="mark-spammer">Mark as spammer</button>
<button type="button" class="btn btn-danger border btn-block font-weight-bold mb-3 action-btn mb-5" data-action="delete-account">Delete Account</button>
@endif
<div class="card shadow-none border">
Expand Down Expand Up @@ -107,6 +116,12 @@
}
break;
case 'mark-spammer':
if(!window.confirm('Are you sure you want to mark this account as a spammer?')) {
return;
}
break;
case 'delete-account':
if(!window.confirm('Are you sure you want to delete this account?')) {
return;
Expand Down
7 changes: 7 additions & 0 deletions routes/web.php
Expand Up @@ -122,6 +122,13 @@
Route::post('instances/refresh-stats', 'AdminController@postInstanceRefreshStatsApi');
Route::get('instances/download-backup', 'AdminController@downloadBackup');
Route::post('instances/import-data', 'AdminController@importBackup');
Route::get('reports/stats', 'AdminController@reportsStats');
Route::get('reports/all', 'AdminController@reportsApiAll');
Route::get('reports/get/{id}', 'AdminController@reportsApiGet');
Route::post('reports/handle', 'AdminController@reportsApiHandle');
Route::get('reports/spam/all', 'AdminController@reportsApiSpamAll');
Route::get('reports/spam/get/{id}', 'AdminController@reportsApiSpamGet');
Route::post('reports/spam/handle', 'AdminController@reportsApiSpamHandle');
});
});

Expand Down

0 comments on commit c6cc632

Please sign in to comment.