pixelfed/resources/views/admin/reports/home.blade.php

223 lines
8.7 KiB
PHP
Raw Normal View History

2019-01-31 21:24:20 +00:00
@extends('admin.partial.template-full')
2018-08-24 00:58:41 +00:00
@section('section')
2019-01-31 21:24:20 +00:00
<div class="title">
<h3 class="font-weight-bold d-inline-block">Reports</h3>
<span class="float-right">
<a class="btn btn-{{request()->input('layout')!=='list'?'primary':'light'}} btn-sm" href="{{route('admin.reports')}}">
<i class="fas fa-th"></i>
</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])}}">
<i class="fas fa-list"></i>
</a>
<div class="dropdown d-inline-block">
<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">
<i class="fas fa-filter"></i>
</button>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="filterDropdown" style="width: 300px;">
2019-02-11 00:12:02 +00:00
{{-- <div class="dropdown-item">
2019-01-31 21:24:20 +00:00
<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">
2019-02-11 00:12:02 +00:00
<input class="form-control" name="search" placeholder="Filter by username" autocomplete="off"></input>
2019-01-31 21:24:20 +00:00
<div class="input-group-append">
<button class="btn btn-outline-primary" type="submit">Filter</button>
</div>
</div>
</form>
</div>
<div class="dropdown-divider"></div>
2019-02-11 00:12:02 +00:00
<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>
2019-01-31 21:24:20 +00:00
<div class="dropdown-divider"></div>
<a class="dropdown-item font-weight-light" href="?layout={{request()->input('layout')}}">Show all</a>
</div>
</div>
</span>
</div>
2018-08-24 00:58:41 +00:00
<hr>
2018-09-02 03:50:54 +00:00
<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>
</span>
</div>
</div>
2019-02-11 00:12:02 +00:00
@if(request()->input('layout') == 'list')
<table class="table w-100">
2018-09-02 03:50:54 +00:00
<thead class="bg-light">
2018-08-24 00:58:41 +00:00
<tr>
2018-09-02 03:50:54 +00:00
<th scope="col">
<div class="">
<div class="custom-control custom-checkbox table-check">
2019-02-11 00:12:02 +00:00
<input type="checkbox" class="custom-control-input row-check-item" id="row-check-all">
2018-09-02 03:50:54 +00:00
<label class="custom-control-label" for="row-check-all"></label>
</div>
</div>
</th>
2018-08-24 00:58:41 +00:00
<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)
<tr>
2019-01-31 21:24:20 +00:00
<td class="">
2018-09-02 03:50:54 +00:00
<div class="custom-control custom-checkbox">
2019-02-11 00:12:02 +00:00
<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}}">
2018-09-02 03:50:54 +00:00
<label class="custom-control-label" for="row-check-{{$report->id}}"></label>
</div>
</td>
<td>
2018-09-01 02:26:56 +00:00
<a href="{{$report->url()}}" class="btn btn-sm btn-outline-primary">
2018-08-24 00:58:41 +00:00
{{$report->id}}
</a>
2018-09-02 03:50:54 +00:00
</td>
2018-08-24 00:58:41 +00:00
<td class="font-weight-bold"><a href="{{$report->reporter->url()}}">{{$report->reporter->username}}</a></td>
<td class="font-weight-bold">{{$report->type}}</td>
2019-02-11 00:12:02 +00:00
<td class="font-weight-bold"><a href="{{$report->reported()->url()}}" title="{{$report->reported()->url()}}">{{str_limit($report->reported()->url(), 25)}}</a></td>
2018-08-24 00:58:41 +00:00
@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
<td class="font-weight-bold">{{$report->created_at->diffForHumans(null, true, true, true)}}</td>
</tr>
@endforeach
</tbody>
</table>
2019-02-11 00:12:02 +00:00
@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 class="card-footer py-1 d-flex align-items-center justify-content-between">
<div class="badge badge-light">local report</div>
@if($report->admin_seen)
<div class="badge badge-light">closed</div>
@else
<div class="badge badge-danger">open</div>
@endif
</div>
</div>
</div>
@endforeach
</div>
@endif
2018-08-24 00:58:41 +00:00
<div class="d-flex justify-content-center mt-5 small">
2019-02-11 00:12:02 +00:00
{{$reports->appends(['layout'=>request()->layout, 'filter' => request()->filter])->links()}}
2018-08-24 00:58:41 +00:00
</div>
@endsection
2018-09-02 03:50:54 +00:00
@push('styles')
<style type="text/css">
.custom-control-label:after, .custom-control-label:before {
top: auto;
bottom: auto;
}
</style>
@endpush
2018-08-24 00:58:41 +00:00
@push('scripts')
<script type="text/javascript">
$(document).ready(function() {
2018-09-02 03:50:54 +00:00
$(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);
}
2019-02-11 00:12:02 +00:00
let len = $('.row-check-item:checked').length;
2018-09-02 03:50:54 +00:00
$('.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');
2019-02-11 00:12:02 +00:00
console.log(el.checked);
2018-09-02 03:50:54 +00:00
if(el.checked == true) {
2019-02-11 00:12:02 +00:00
$('.bulk-actions').removeClass('d-none');
2018-09-02 03:50:54 +00:00
len++;
$('.bulk-count').text(len).attr('data-count', len);
} else {
2019-02-11 00:12:02 +00:00
if(len == 0) {
$('.bulk-actions').addClass('d-none');
} else {
len--;
$('.bulk-count').text(len).attr('data-count', len);
}
2018-09-02 03:50:54 +00:00
}
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');
});
});
2018-08-24 00:58:41 +00:00
$('.human-size').each(function(d,a) {
let el = $(a);
let size = el.data('bytes');
el.text(filesize(size, {round: 0}));
});
});
</script>
@endpush