Add admin report views

This commit is contained in:
Daniel Supernault 2018-08-31 20:26:56 -06:00
parent 84ba7f4a9c
commit 89ced5bdde
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
6 changed files with 47 additions and 16 deletions

View file

@ -3,12 +3,18 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Media; use App\Media;
use App\Report;
use App\Status; use App\Status;
use App\User; use App\User;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Controllers\Admin\{
AdminReportController
};
class AdminController extends Controller class AdminController extends Controller
{ {
use AdminReportController;
public function __construct() public function __construct()
{ {
return $this->middleware('admin'); return $this->middleware('admin');
@ -46,4 +52,16 @@ class AdminController extends Controller
return view('admin.media.home', compact('media')); return view('admin.media.home', compact('media'));
} }
public function reports(Request $request)
{
$reports = Report::orderBy('created_at','desc')->paginate(12);
return view('admin.reports.home', compact('reports'));
}
public function showReport(Request $request, $id)
{
$report = Report::findOrFail($id);
return view('admin.reports.show', compact('report'));
}
} }

View file

@ -1,37 +1,37 @@
<div class="col-12 col-md-3 py-3" style="border-right:1px solid #ccc;"> <div class="col-12 col-md-3 py-3" style="border-right:1px solid #ccc;">
<ul class="nav flex-column settings-nav"> <ul class="nav flex-column settings-nav">
<li class="nav-item pl-3 {{request()->is('dashboard')?'active':''}}"> <li class="nav-item pl-3 {{request()->is('dashboard')?'active':''}}">
<a class="nav-link lead text-muted" href="{{route('admin.home')}}">Dashboard</a> <a class="nav-link font-weight-bold text-muted" href="{{route('admin.home')}}">Dashboard</a>
</li> </li>
<li class="nav-item pl-3 {{request()->is('alerts*')?'active':''}}"> <li class="nav-item pl-3 {{request()->is('alerts*')?'active':''}}">
<a class="nav-link lead text-muted" href="#">Alerts</a> <a class="nav-link font-weight-bold text-muted" href="#">Alerts</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<hr> <hr>
</li> </li>
<li class="nav-item pl-3 {{request()->is('instances*')?'active':''}}"> <li class="nav-item pl-3 {{request()->is('instances*')?'active':''}}">
<a class="nav-link lead text-muted" href="#">Instances</a> <a class="nav-link font-weight-bold text-muted" href="#">Instances</a>
</li> </li>
<li class="nav-item pl-3 {{request()->is('media*')?'active':''}}"> <li class="nav-item pl-3 {{request()->is('media*')?'active':''}}">
<a class="nav-link lead text-muted" href="{{route('admin.media')}}">Media</a> <a class="nav-link font-weight-bold text-muted" href="{{route('admin.media')}}">Media</a>
</li> </li>
<li class="nav-item pl-3 {{request()->is('reports*')?'active':''}}"> <li class="nav-item pl-3 {{request()->is('reports*')?'active':''}}">
<a class="nav-link lead text-muted" href="#">Reports</a> <a class="nav-link font-weight-bold text-muted" href="{{route('admin.reports')}}">Reports</a>
</li> </li>
<li class="nav-item pl-3 {{request()->is('statuses*')?'active':''}}"> <li class="nav-item pl-3 {{request()->is('statuses*')?'active':''}}">
<a class="nav-link lead text-muted" href="{{route('admin.statuses')}}">Statuses</a> <a class="nav-link font-weight-bold text-muted" href="{{route('admin.statuses')}}">Statuses</a>
</li> </li>
<li class="nav-item pl-3 {{request()->is('users*')?'active':''}}"> <li class="nav-item pl-3 {{request()->is('users*')?'active':''}}">
<a class="nav-link lead text-muted" href="{{route('admin.users')}}">Users</a> <a class="nav-link font-weight-bold text-muted" href="{{route('admin.users')}}">Users</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<hr> <hr>
</li> </li>
<li class="nav-item pl-3"> <li class="nav-item pl-3">
<a class="nav-link lead text-muted" href="/horizon">Redis Queue</a> <a class="nav-link font-weight-bold text-muted" href="/horizon">Redis Queue</a>
</li> </li>
<li class="nav-item pl-3 {{request()->is('settings*')?'active':''}}"> <li class="nav-item pl-3 {{request()->is('settings*')?'active':''}}">
<a class="nav-link lead text-muted" href="#">Settings</a> <a class="nav-link font-weight-bold text-muted" href="#">Settings</a>
</li> </li>
</ul> </ul>
</div> </div>

View file

@ -8,7 +8,7 @@
<div class="card-body p-0"> <div class="card-body p-0">
<div class="row"> <div class="row">
@include('admin.partial.sidebar') @include('admin.partial.sidebar')
<div class="col-12 col-md-9 p-5"> <div class="col-12 col-md-9 p-4">
@if (session('status')) @if (session('status'))
<div class="alert alert-success"> <div class="alert alert-success">
{{ session('status')}} {{ session('status')}}

View file

@ -1,13 +1,23 @@
@extends('admin.partial.template') @extends('admin.partial.template')
@section('section') @section('section')
<div class="title"> <div class="title font-weight-bold">
<h3 class="font-weight-bold">Reports</h3> <h3 class="">Reports</h3>
<p>
<span class="pr-3">
<span>Open:</span>
<span class="text-danger">{{App\Report::whereNull('admin_seen')->count()}}</span>
</span>
<span class="">
<span>Closed:</span>
<span class="text-success">{{App\Report::whereNotNull('admin_seen')->count()}}</span>
</span>
</p>
</div> </div>
<hr> <hr>
<table class="table"> <table class="table table-responsive">
<thead class="thead-dark"> <thead class="thead-dark">
<tr> <tr>
<th scope="col">#</th> <th scope="col">#</th>
@ -22,7 +32,7 @@
@foreach($reports as $report) @foreach($reports as $report)
<tr> <tr>
<th scope="row"> <th scope="row">
<a href="{{$report->url()}}"> <a href="{{$report->url()}}" class="btn btn-sm btn-outline-primary">
{{$report->id}} {{$report->id}}
</a> </a>
</th> </th>

View file

@ -19,9 +19,9 @@
{{-- <a href="#" class="card-link font-weight-bold">Request Mod Feedback</a> --}} {{-- <a href="#" class="card-link font-weight-bold">Request Mod Feedback</a> --}}
<a href="#" class="card-link report-action-btn font-weight-bold" data-action="cw">Add CW</a> <a href="#" class="card-link report-action-btn font-weight-bold" data-action="cw">Add CW</a>
<a href="#" class="card-link report-action-btn font-weight-bold" data-action="unlist">Unlist/Hide</a> <a href="#" class="card-link report-action-btn font-weight-bold" data-action="unlist">Unlist/Hide</a>
<a href="#" class="card-link report-action-btn font-weight-bold text-danger" data-action="delete">Delete</a> {{-- <a href="#" class="card-link report-action-btn font-weight-bold text-danger" data-action="delete">Delete</a>
<a href="#" class="card-link report-action-btn font-weight-bold text-danger" data-action="shadowban">Shadowban User</a> <a href="#" class="card-link report-action-btn font-weight-bold text-danger" data-action="shadowban">Shadowban User</a>
<a href="#" class="card-link report-action-btn font-weight-bold text-danger" data-action="ban">Ban User</a> <a href="#" class="card-link report-action-btn font-weight-bold text-danger" data-action="ban">Ban User</a> --}}
@else @else
<p class="font-weight-bold mb-0">Resolved {{$report->admin_seen->diffForHumans()}}</p> <p class="font-weight-bold mb-0">Resolved {{$report->admin_seen->diffForHumans()}}</p>
@endif @endif

View file

@ -4,6 +4,9 @@ Route::domain(config('pixelfed.domain.admin'))->prefix('i/admin')->group(functio
Route::redirect('/', '/dashboard'); Route::redirect('/', '/dashboard');
Route::redirect('timeline', config('app.url').'/timeline'); Route::redirect('timeline', config('app.url').'/timeline');
Route::get('dashboard', 'AdminController@home')->name('admin.home'); Route::get('dashboard', 'AdminController@home')->name('admin.home');
Route::get('reports', 'AdminController@reports')->name('admin.reports');
Route::get('reports/show/{id}', 'AdminController@showReport');
Route::post('reports/show/{id}', 'AdminController@updateReport');
Route::redirect('statuses', '/statuses/list'); Route::redirect('statuses', '/statuses/list');
Route::get('statuses/list', 'AdminController@statuses')->name('admin.statuses'); Route::get('statuses/list', 'AdminController@statuses')->name('admin.statuses');
Route::get('statuses/show/{id}', 'AdminController@showStatus'); Route::get('statuses/show/{id}', 'AdminController@showStatus');