mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 13:33:18 +00:00
Merge pull request #1957 from pixelfed/staging
Update admin reports, fix 404 bug
This commit is contained in:
commit
7123f9b148
3 changed files with 72 additions and 202 deletions
|
@ -16,6 +16,7 @@
|
||||||
- Updated Story model, hide json attribute by default ([de89403c](https://github.com/pixelfed/pixelfed/commit/de89403c))
|
- Updated Story model, hide json attribute by default ([de89403c](https://github.com/pixelfed/pixelfed/commit/de89403c))
|
||||||
- Updated compose view, add deprecation notice for v3 ([57e155b9](https://github.com/pixelfed/pixelfed/commit/57e155b9))
|
- Updated compose view, add deprecation notice for v3 ([57e155b9](https://github.com/pixelfed/pixelfed/commit/57e155b9))
|
||||||
- Updated StoryController, orientate story media and strip exif ([07a13fcf](https://github.com/pixelfed/pixelfed/commit/07a13fcf))
|
- Updated StoryController, orientate story media and strip exif ([07a13fcf](https://github.com/pixelfed/pixelfed/commit/07a13fcf))
|
||||||
|
- Updated admin reports, fixed 404 bug ([dbd5c4cf](https://github.com/pixelfed/pixelfed/commit/dbd5c4cf))
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -142,21 +142,17 @@ class AdminController extends Controller
|
||||||
|
|
||||||
public function reports(Request $request)
|
public function reports(Request $request)
|
||||||
{
|
{
|
||||||
|
$this->validate($request, [
|
||||||
|
'filter' => 'nullable|string|in:all,open,closed'
|
||||||
|
]);
|
||||||
$filter = $request->input('filter');
|
$filter = $request->input('filter');
|
||||||
if(in_array($filter, ['open', 'closed'])) {
|
|
||||||
if($filter == 'open') {
|
|
||||||
$reports = Report::orderBy('created_at','desc')
|
$reports = Report::orderBy('created_at','desc')
|
||||||
->whereNotNull('admin_seen')
|
->when($filter, function($q, $filter) {
|
||||||
->paginate(10);
|
return $filter == 'open' ?
|
||||||
} else {
|
$q->whereNull('admin_seen') :
|
||||||
$reports = Report::orderBy('created_at','desc')
|
$q->whereNotNull('admin_seen');
|
||||||
->whereNull('admin_seen')
|
})
|
||||||
->paginate(10);
|
->paginate(4);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$reports = Report::orderBy('created_at','desc')
|
|
||||||
->paginate(10);
|
|
||||||
}
|
|
||||||
return view('admin.reports.home', compact('reports'));
|
return view('admin.reports.home', compact('reports'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,134 +1,75 @@
|
||||||
@extends('admin.partial.template-full')
|
@extends('admin.partial.template-full')
|
||||||
|
|
||||||
@section('section')
|
@section('section')
|
||||||
<div class="title">
|
<div class="title mb-3">
|
||||||
<h3 class="font-weight-bold d-inline-block">Reports</h3>
|
<h3 class="font-weight-bold d-inline-block">Reports</h3>
|
||||||
<span class="float-right">
|
<span class="float-right">
|
||||||
<a class="btn btn-{{request()->input('layout')!=='list'?'primary':'light'}} btn-sm" href="{{route('admin.reports')}}">
|
<a class="btn btn-{{request()->input('filter')=='all'||request()->input('filter')==null?'primary':'light'}} btn-sm font-weight-bold" href="{{route('admin.reports')}}">
|
||||||
<i class="fas fa-th"></i>
|
ALL
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-{{request()->input('layout')=='list'?'primary':'light'}} btn-sm mr-3" href="{{route('admin.reports',['layout'=>'list', 'page' => request()->input('page') ?? 1])}}">
|
<a class="btn btn-{{request()->input('filter')=='open'?'primary':'light'}} btn-sm font-weight-bold" href="{{route('admin.reports',['filter'=>'open', 'page' => request()->input('page') ?? 1])}}">
|
||||||
<i class="fas fa-list"></i>
|
OPEN
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown d-inline-block">
|
<a class="btn btn-{{request()->input('filter')=='closed'?'primary':'light'}} btn-sm mr-3 font-weight-bold" href="{{route('admin.reports',['filter'=>'closed', 'page' => request()->input('page') ?? 1])}}">
|
||||||
<button class="btn btn-light btn-sm dropdown-toggle font-weight-bold" type="button" id="filterDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
CLOSED
|
||||||
<i class="fas fa-filter"></i>
|
|
||||||
</button>
|
|
||||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="filterDropdown" style="width: 300px;">
|
|
||||||
{{-- <div class="dropdown-item">
|
|
||||||
<form>
|
|
||||||
<input type="hidden" name="layout" value="{{request()->input('layout')}}"></input>
|
|
||||||
<input type="hidden" name="page" value="{{request()->input('page')}}"></input>
|
|
||||||
<div class="input-group input-group-sm">
|
|
||||||
<input class="form-control" name="search" placeholder="Filter by username" autocomplete="off"></input>
|
|
||||||
<div class="input-group-append">
|
|
||||||
<button class="btn btn-outline-primary" type="submit">Filter</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div class="dropdown-divider"></div>
|
|
||||||
<div class="dropdown-divider"></div> --}}
|
|
||||||
<a class="dropdown-item font-weight-light {{request()->filter=='open'?'active':''}}" href="?filter=open&layout={{request()->input('layout')}}">Open Reports Only</a>
|
|
||||||
<a class="dropdown-item font-weight-light {{request()->filter=='closed'?'active':''}}" href="?filter=closed&layout={{request()->layout}}">Closed Reports Only</a>
|
|
||||||
<div class="dropdown-divider"></div>
|
|
||||||
<a class="dropdown-item font-weight-light" href="?layout={{request()->input('layout')}}">Show all</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<div class="mb-3 bulk-actions d-none">
|
|
||||||
<div class="d-flex justify-content-between">
|
|
||||||
<span>
|
|
||||||
<span class="bulk-count font-weight-bold" data-count="0">
|
|
||||||
0
|
|
||||||
</span>
|
|
||||||
<span class="bulk-desc"> items selected</span>
|
|
||||||
</span>
|
|
||||||
<span class="d-inline-flex">
|
|
||||||
<select class="custom-select custom-select-sm font-weight-bold bulk-action">
|
|
||||||
<option selected disabled="">Select Bulk Action</option>
|
|
||||||
<option value="1">Ignore</option>
|
|
||||||
<option value="2">Add C/W</option>
|
|
||||||
<option value="3">Unlist from timelines</option>
|
|
||||||
</select>
|
|
||||||
<a class="btn btn-outline-primary btn-sm ml-3 font-weight-bold apply-bulk" href="#">
|
|
||||||
Apply
|
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@if($reports->count())
|
||||||
@if(request()->input('layout') == 'list')
|
<div class="card shadow-none border">
|
||||||
<table class="table w-100">
|
<div class="list-group list-group-flush">
|
||||||
<thead class="bg-light">
|
|
||||||
<tr>
|
|
||||||
<th scope="col">
|
|
||||||
<div class="custom-control custom-checkbox table-check">
|
|
||||||
<input type="checkbox" class="custom-control-input row-check-item" id="row-check-all">
|
|
||||||
<label class="custom-control-label" for="row-check-all"></label>
|
|
||||||
</div>
|
|
||||||
</th>
|
|
||||||
<th scope="col">#</th>
|
|
||||||
<th scope="col">Reporter</th>
|
|
||||||
<th scope="col">Type</th>
|
|
||||||
<th scope="col">Reported</th>
|
|
||||||
<th scope="col">Status</th>
|
|
||||||
<th scope="col">Created</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach($reports as $report)
|
@foreach($reports as $report)
|
||||||
<tr>
|
<div class="list-group-item {{$report->admin_seen ? 'bg-light' : 'bg-white'}}">
|
||||||
<td scope="row">
|
<div class="p-4">
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="media d-flex align-items-center">
|
||||||
<input type="checkbox" class="custom-control-input row-check-item" id="row-check-{{$report->id}}" data-resolved="{{$report->admin_seen?'true':'false'}}" data-id="{{$report->id}}">
|
<div class="mr-3 border rounded d-flex justify-content-center align-items-center media-avatar">
|
||||||
<label class="custom-control-label" for="row-check-{{$report->id}}"></label>
|
<span class="text-lighter lead"><i class="fas fa-camera"></i></span>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
<div class="media-body">
|
||||||
<td>
|
<p class="mb-1 small"><span class="font-weight-bold text-uppercase">{{$report->type}}</span></p>
|
||||||
<a href="{{$report->url()}}" class="btn btn-sm btn-outline-primary my-0 py-0">
|
@if($report->reporter && $report->status)
|
||||||
{{$report->id}}
|
<p class="mb-0 lead"><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>
|
||||||
</a>
|
@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>
|
||||||
|
|
||||||
</td>
|
|
||||||
<td class="font-weight-bold"><a href="{{$report->reporter->url()}}">{{$report->reporter->username}}</a></td>
|
|
||||||
<td class="font-weight-bold">{{$report->type}}</td>
|
|
||||||
<td class="font-weight-bold"><a href="{{$report->reported()->url()}}" title="{{$report->reported()->url()}}">{{str_limit($report->reported()->url(), 25)}}</a></td>
|
|
||||||
@if(!$report->admin_seen)
|
|
||||||
<td><span class="text-danger font-weight-bold">Unresolved</span></td>
|
|
||||||
@else
|
|
||||||
<td><span class="text-success font-weight-bold">Resolved</span></td>
|
|
||||||
@endif
|
@endif
|
||||||
<td class="font-weight-bold">{{$report->created_at->diffForHumans(null, true, true, true)}}</td>
|
|
||||||
</tr>
|
|
||||||
@endforeach
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
@else
|
|
||||||
<div class="row">
|
|
||||||
@foreach($reports as $report)
|
|
||||||
<div class="col-md-4 col-12 mb-3">
|
|
||||||
<div class="card bg-light">
|
|
||||||
<div class="card-body py-3">
|
|
||||||
<p class="font-weight-lighter h2">{{$report->type}} <a href="{{$report->url()}}" class="h6 float-right text-primary"># {{$report->id}}</a></p>
|
|
||||||
<p class="small text-truncate mb-0"><a href="{{$report->reported()->url()}}" title="{{$report->reported()->url()}}">{{$report->reported()->url()}}</a></p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer py-1 d-flex align-items-center justify-content-between">
|
<div class="float-right">
|
||||||
<div class="badge badge-light">local report</div>
|
{{-- @if($report->admin_seen == null)
|
||||||
@if($report->admin_seen)
|
<a class="btn btn-outline-primary btn-sm font-weight-bold py-1 px-2 mr-2" href="{{$report->url()}}/action"><i class="fas fa-check"></i></a>
|
||||||
<div class="badge badge-light">closed</div>
|
|
||||||
@else
|
|
||||||
<div class="badge badge-danger">open</div>
|
|
||||||
@endif
|
@endif
|
||||||
|
<a class="btn btn-outline-primary btn-sm font-weight-bold py-1 px-2 mr-2" href="{{$report->url()}}/action"><i class="fas fa-cog"></i></a> --}}
|
||||||
|
@if($report->status)
|
||||||
|
<a class="btn btn-primary btn-sm font-weight-bold py-1 px-3" href="{{$report->url()}}">VIEW</a>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@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
|
@endif
|
||||||
|
|
||||||
<div class="d-flex justify-content-center mt-5 small">
|
<div class="d-flex justify-content-center mt-5 small">
|
||||||
{{$reports->appends(['layout'=>request()->layout, 'filter' => request()->filter])->links()}}
|
{{$reports->appends(['layout'=>request()->layout, 'filter' => request()->filter])->links()}}
|
||||||
</div>
|
</div>
|
||||||
|
@ -140,82 +81,14 @@
|
||||||
top: auto;
|
top: auto;
|
||||||
bottom: auto;
|
bottom: auto;
|
||||||
}
|
}
|
||||||
|
.media-avatar {
|
||||||
|
width:64px;
|
||||||
|
height:64px;
|
||||||
|
background:#e9ecef;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
|
||||||
$(document).ready(function() {
|
|
||||||
|
|
||||||
$(document).on('click', '#row-check-all', function(e) {
|
|
||||||
let el = $(this);
|
|
||||||
let attr = el.attr('checked');
|
|
||||||
|
|
||||||
if (typeof attr !== typeof undefined && attr !== false) {
|
|
||||||
$('.bulk-actions').addClass('d-none');
|
|
||||||
$('.row-check-item[data-resolved=false]').removeAttr('checked').prop('checked', false);
|
|
||||||
el.removeAttr('checked').prop('checked', false);
|
|
||||||
} else {
|
|
||||||
$('.bulk-actions').removeClass('d-none');
|
|
||||||
el.attr('checked', '').prop('checked', true);
|
|
||||||
$('.row-check-item[data-resolved=false]').attr('checked', '').prop('checked', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
let len = $('.row-check-item:checked').length;
|
|
||||||
$('.bulk-count').text(len).attr('data-count', len);
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on('click', '.row-check-item', function(e) {
|
|
||||||
var el = $(this)[0];
|
|
||||||
let len = $('.bulk-count').attr('data-count');
|
|
||||||
console.log(el.checked);
|
|
||||||
if(el.checked == true) {
|
|
||||||
$('.bulk-actions').removeClass('d-none');
|
|
||||||
len++;
|
|
||||||
$('.bulk-count').text(len).attr('data-count', len);
|
|
||||||
} else {
|
|
||||||
if(len == 0) {
|
|
||||||
$('.bulk-actions').addClass('d-none');
|
|
||||||
} else {
|
|
||||||
len--;
|
|
||||||
$('.bulk-count').text(len).attr('data-count', len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(len == 0) {
|
|
||||||
$('.bulk-actions').addClass('d-none');
|
|
||||||
$('#row-check-all').prop('checked', false);
|
|
||||||
} else {
|
|
||||||
$('.bulk-actions').removeClass('d-none');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on('click', '.apply-bulk', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
let ids = $('.row-check-item:checked').map(function(i,k) {
|
|
||||||
return $(this).attr('data-id');
|
|
||||||
}).get();
|
|
||||||
let action = $('.bulk-action option:selected').val();
|
|
||||||
if(action == 'Select Bulk Action') {
|
|
||||||
swal('Error', 'You need to select a bulk action first.', 'error');
|
|
||||||
$('.bulk-action').focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
axios.post('/i/admin/reports/bulk',{
|
|
||||||
'action': action,
|
|
||||||
'ids': ids
|
|
||||||
}).then(function(res) {
|
|
||||||
swal('Success', 'Bulk Update was successful!', 'success');
|
|
||||||
window.location.href = window.location.href;
|
|
||||||
}).catch(function(res) {
|
|
||||||
swal('Ooops!', 'Something went wrong', 'error');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.human-size').each(function(d,a) {
|
|
||||||
let el = $(a);
|
|
||||||
let size = el.data('bytes');
|
|
||||||
el.text(filesize(size, {round: 0}));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@endpush
|
@endpush
|
Loading…
Reference in a new issue