FEATURE #2389 @20m: add deleting all data from profiler
This commit is contained in:
@@ -4,6 +4,7 @@ use App\Http\Controllers\Admin\Controller;
|
|||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Support\Facades\Input;
|
use Illuminate\Support\Facades\Input;
|
||||||
use Modules\Profiler\Entities\HttpLog;
|
use Modules\Profiler\Entities\HttpLog;
|
||||||
|
use Modules\Profiler\Entities\QueryLog;
|
||||||
|
|
||||||
class ProfilerController extends Controller
|
class ProfilerController extends Controller
|
||||||
{
|
{
|
||||||
@@ -29,6 +30,7 @@ class ProfilerController extends Controller
|
|||||||
|
|
||||||
if (Input::get('url')) {
|
if (Input::get('url')) {
|
||||||
$httpLog = $httpLog->where('url', Input::get('url'))
|
$httpLog = $httpLog->where('url', Input::get('url'))
|
||||||
|
->orderBy('created_at', 'DESC')
|
||||||
->with('queries');
|
->with('queries');
|
||||||
} else {
|
} else {
|
||||||
$displayGrouped = true;
|
$displayGrouped = true;
|
||||||
@@ -42,4 +44,24 @@ class ProfilerController extends Controller
|
|||||||
$filter = Input::all();
|
$filter = Input::all();
|
||||||
return view('profiler::index', compact('httpLog', 'displayGrouped', 'filter', 'pastDays'));
|
return view('profiler::index', compact('httpLog', 'displayGrouped', 'filter', 'pastDays'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function destroy()
|
||||||
|
{
|
||||||
|
$older = Input::get('olderThan');
|
||||||
|
|
||||||
|
if (is_null($older)) {
|
||||||
|
\DB::statement("SET foreign_key_checks=0");
|
||||||
|
QueryLog::truncate();
|
||||||
|
HttpLog::truncate();
|
||||||
|
\DB::statement("SET foreign_key_checks=1");
|
||||||
|
} else {
|
||||||
|
HttpLog::where('created_at', '<=', Carbon::now()
|
||||||
|
->subDays($older))
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()
|
||||||
|
->back()
|
||||||
|
->with('success', trans('profiler::module.succesfullyDeleted'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Modules\Profiler\Http\Controllers;
|
namespace Modules\Profiler\Http\Controllers;
|
||||||
|
|
||||||
use App\Http\Controllers\Admin\Controller;
|
use App\Http\Controllers\Admin\Controller;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Input;
|
||||||
use Modules\Profiler\Entities\HttpLog;
|
use Modules\Profiler\Entities\HttpLog;
|
||||||
|
|
||||||
class RequestController extends Controller
|
class RequestController extends Controller
|
||||||
@@ -9,8 +12,17 @@ class RequestController extends Controller
|
|||||||
public function detail(HttpLog $httpLog)
|
public function detail(HttpLog $httpLog)
|
||||||
{
|
{
|
||||||
$sameRequests = HttpLog::where('url', $httpLog->url)
|
$sameRequests = HttpLog::where('url', $httpLog->url)
|
||||||
->where('method', $httpLog->method)
|
->where('method', $httpLog->method);
|
||||||
->get();
|
|
||||||
|
$pastDays = Input::get('pastDays', session('profilerPastDays', 0));
|
||||||
|
if (is_numeric($pastDays) && $pastDays >= 0) {
|
||||||
|
$sameRequests = $sameRequests->where('created_at', '>=', Carbon::today()
|
||||||
|
->subDays($pastDays));
|
||||||
|
}
|
||||||
|
|
||||||
|
session(['profilerPastDays' => $pastDays]);
|
||||||
|
|
||||||
|
$sameRequests = $sameRequests->get();
|
||||||
|
|
||||||
$times = [
|
$times = [
|
||||||
'avg' => $sameRequests->avg('time'),
|
'avg' => $sameRequests->avg('time'),
|
||||||
@@ -18,6 +30,8 @@ class RequestController extends Controller
|
|||||||
'max' => $sameRequests->max('time')
|
'max' => $sameRequests->max('time')
|
||||||
];
|
];
|
||||||
|
|
||||||
return view('profiler::request.detail', compact('httpLog', 'sameRequests', 'times'));
|
$filter = Input::all();
|
||||||
|
|
||||||
|
return view('profiler::request.detail', compact('httpLog', 'sameRequests', 'times', 'pastDays', 'filter'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,5 +16,8 @@ Route::group([
|
|||||||
|
|
||||||
Route::get('{httpLog}/queries', 'QueryController@index')
|
Route::get('{httpLog}/queries', 'QueryController@index')
|
||||||
->name('queries.index');
|
->name('queries.index');
|
||||||
|
|
||||||
|
Route::get('delete/all', 'ProfilerController@destroy')
|
||||||
|
->name('profiler.deleteAll');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
return [
|
return [
|
||||||
'name' => 'Profiler',
|
'name' => 'Profiler',
|
||||||
'index' => [
|
'index' => [
|
||||||
'createdAt' => 'Datum',
|
'createdAt' => 'Datum',
|
||||||
'httpMethod' => 'HTTP metoda',
|
'httpMethod' => 'HTTP metoda',
|
||||||
'url' => 'URL',
|
'url' => 'URL',
|
||||||
@@ -11,31 +11,34 @@ return [
|
|||||||
'timeMax' => 'Maximální čas',
|
'timeMax' => 'Maximální čas',
|
||||||
'systemLoad' => 'Load serveru',
|
'systemLoad' => 'Load serveru',
|
||||||
'calledTotal' => 'Volání',
|
'calledTotal' => 'Volání',
|
||||||
'pastDays' => [
|
'pastDays' => [
|
||||||
'today' => 'Dnes',
|
'today' => 'Dnes',
|
||||||
'overall' => 'Vše',
|
'overall' => 'Vše',
|
||||||
'days' => '1 den|:count dny|:count dní'
|
'days' => '1 den|:count dny|:count dní'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'settings' => [
|
'settings' => [
|
||||||
'useProfilerInVisitorArea' => 'Zapnout měření ve veřejné části?',
|
'useProfilerInVisitorArea' => 'Zapnout měření ve veřejné části?',
|
||||||
'useProfilerInAdmin' => 'Zapnout měření v administraci?'
|
'useProfilerInAdmin' => 'Zapnout měření v administraci?'
|
||||||
],
|
],
|
||||||
'request' => [
|
'request' => [
|
||||||
'info' => 'Detaily requestu',
|
'info' => 'Detaily requestu',
|
||||||
'sql' => 'SQL dotazy',
|
'sql' => 'SQL dotazy',
|
||||||
'detail' => 'Detail požadavku',
|
'detail' => 'Detail požadavku',
|
||||||
'sameRequests' => 'Ostatní volání'
|
'sameRequests' => 'Ostatní volání'
|
||||||
],
|
],
|
||||||
'graphs' => [
|
'graphs' => [
|
||||||
'responseTime' => 'Doba odezvy'
|
'responseTime' => 'Doba odezvy'
|
||||||
],
|
],
|
||||||
'queries' => [
|
'queries' => [
|
||||||
'sql' => 'SQL dotaz',
|
'sql' => 'SQL dotaz',
|
||||||
'time' => 'Čas dotazu'
|
'time' => 'Čas dotazu'
|
||||||
],
|
],
|
||||||
'listDescription' => 'Seznam HTTP požadavků na tuto aplikaci.',
|
'listDescription' => 'Seznam HTTP požadavků na tuto aplikaci.',
|
||||||
'groupedListDescription' => 'Seznam HTTP požadavků na tuto aplikaci.',
|
'groupedListDescription' => 'Seznam HTTP požadavků na tuto aplikaci.',
|
||||||
'requestDetail' => 'Detail HTTP požadavku'
|
'requestDetail' => 'Detail HTTP požadavku',
|
||||||
|
'deleteAllData' => 'Smazat všechna data',
|
||||||
|
'deleteOld' => 'Smazat data starší než 30 dní',
|
||||||
|
'succesfullyDeleted' => 'Úspěšně vymazána data z profileru.',
|
||||||
|
|
||||||
];
|
];
|
||||||
@@ -1,27 +1,31 @@
|
|||||||
<table class="item-list content-overview full-width table striped">
|
@if(count($requests) > 0)
|
||||||
<thead>
|
<table class="item-list content-overview full-width table striped">
|
||||||
<tr>
|
<thead>
|
||||||
<td>@lang('profiler::module.index.calledTotal')</td>
|
|
||||||
<td>@lang('profiler::module.index.httpMethod')</td>
|
|
||||||
<td>@lang('profiler::module.index.url')</td>
|
|
||||||
<td>@lang('profiler::module.index.timeAvg')</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach($requests as $request)
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{$request->total}}</td>
|
<td>@lang('profiler::module.index.calledTotal')</td>
|
||||||
<td><a href="{{route('profiler.index', ['method' => $request->method])}}">{{$request->method}}</a></td>
|
<td>@lang('profiler::module.index.httpMethod')</td>
|
||||||
<td><a href="{{route('profiler.index', ['url' => $request->url])}}">{{$request->url}}</a></td>
|
<td>@lang('profiler::module.index.url')</td>
|
||||||
<td>{{number_format($request->time_avg, 2)}} ms</td>
|
<td>@lang('profiler::module.index.timeAvg')</td>
|
||||||
<td>
|
<td></td>
|
||||||
<a href="{{route('request.detail', ['httpLog' => $request])}}" data-toggle="tooltip"
|
|
||||||
title="@lang('profiler::module.request.info')">
|
|
||||||
<i class="fa fa-info"></i>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
</thead>
|
||||||
</tbody>
|
<tbody>
|
||||||
</table>
|
@foreach($requests as $request)
|
||||||
|
<tr>
|
||||||
|
<td>{{$request->total}}</td>
|
||||||
|
<td><a href="{{route('profiler.index', ['method' => $request->method])}}">{{$request->method}}</a></td>
|
||||||
|
<td><a href="{{route('profiler.index', ['url' => $request->url])}}">{{$request->url}}</a></td>
|
||||||
|
<td>{{number_format($request->time_avg, 2)}} ms</td>
|
||||||
|
<td>
|
||||||
|
<a href="{{route('request.detail', ['httpLog' => $request])}}" data-toggle="tooltip"
|
||||||
|
title="@lang('profiler::module.request.info')">
|
||||||
|
<i class="fa fa-info"></i>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
@else
|
||||||
|
@lang('admin/common.empty')
|
||||||
|
@endif
|
||||||
@@ -1,55 +1,60 @@
|
|||||||
<table class="item-list content-overview full-width table striped">
|
@if(count($requests) > 0)
|
||||||
<thead>
|
<table class="item-list content-overview full-width table striped">
|
||||||
<tr>
|
<thead>
|
||||||
<td>@lang('profiler::module.index.createdAt')</td>
|
|
||||||
<td>@lang('profiler::module.index.httpMethod')</td>
|
|
||||||
<td>@lang('profiler::module.index.url')</td>
|
|
||||||
<td>@lang('profiler::module.index.time')</td>
|
|
||||||
<td>@lang('profiler::module.index.systemLoad')</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
|
|
||||||
|
|
||||||
@foreach($requests as $request)
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{$request->created_at->format('d.m.Y G:i')}}</td>
|
<td>@lang('profiler::module.index.createdAt')</td>
|
||||||
<td><a href="{{route('profiler.index', ['method' => $request->method])}}">{{$request->method}}</a></td>
|
<td>@lang('profiler::module.index.httpMethod')</td>
|
||||||
<td><a href="{{route('profiler.index', ['url' => $request->url])}}">{{$request->url}}</a></td>
|
<td>@lang('profiler::module.index.url')</td>
|
||||||
<td>{{number_format($request->time, 3)}} ms</td>
|
<td>@lang('profiler::module.index.time')</td>
|
||||||
<td>{{$request->load_1}}, {{$request->load_5}}, {{$request->load_15}}</td>
|
<td>@lang('profiler::module.index.systemLoad')</td>
|
||||||
<td>
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
<div class="item-actions-dropdown">
|
|
||||||
<a class="item-actions-toggle-btn">
|
@foreach($requests as $request)
|
||||||
|
<tr>
|
||||||
|
<td>{{$request->created_at->format('d.m.Y G:i')}}</td>
|
||||||
|
<td><a href="{{route('profiler.index', ['method' => $request->method])}}">{{$request->method}}</a></td>
|
||||||
|
<td><a href="{{route('profiler.index', ['url' => $request->url])}}">{{$request->url}}</a></td>
|
||||||
|
<td>{{number_format($request->time, 3)}} ms</td>
|
||||||
|
<td>{{$request->load_1}}, {{$request->load_5}}, {{$request->load_15}}</td>
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<div class="item-actions-dropdown">
|
||||||
|
<a class="item-actions-toggle-btn">
|
||||||
<span class="inactive">
|
<span class="inactive">
|
||||||
<i class="fa fa-cog"></i>
|
<i class="fa fa-cog"></i>
|
||||||
</span>
|
</span>
|
||||||
<span class="active">
|
<span class="active">
|
||||||
<i class="fa fa-chevron-circle-right"></i>
|
<i class="fa fa-chevron-circle-right"></i>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<div class="item-actions-block">
|
<div class="item-actions-block">
|
||||||
<ul class="item-actions-list">
|
<ul class="item-actions-list">
|
||||||
<li>
|
<li>
|
||||||
<a href="{{route('request.detail', ['httpLog' => $request])}}" data-toggle="tooltip"
|
<a href="{{route('request.detail', ['httpLog' => $request])}}" data-toggle="tooltip"
|
||||||
title="@lang('profiler::module.request.info')">
|
title="@lang('profiler::module.request.info')">
|
||||||
<i class="fa fa-info"></i>
|
<i class="fa fa-info"></i>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{route('queries.index', ['httpLog' => $request])}}" data-toggle="tooltip"
|
<a href="{{route('queries.index', ['httpLog' => $request])}}" data-toggle="tooltip"
|
||||||
title="@lang('profiler::module.request.sql')">
|
title="@lang('profiler::module.request.sql')">
|
||||||
<i class="fa fa-database"></i></a>
|
<i class="fa fa-database"></i></a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
@else
|
||||||
|
@lang('admin/common.empty')
|
||||||
|
@endif
|
||||||
@@ -3,7 +3,16 @@
|
|||||||
@section('pageHeading', trans('profiler::module.requestDetail'))
|
@section('pageHeading', trans('profiler::module.requestDetail'))
|
||||||
|
|
||||||
@section('headerButtons')
|
@section('headerButtons')
|
||||||
<a class="btn btn-sm rounded btn-primary" href="{{route('profiler.index')}}"><i class="fa fa-list"></i></a>
|
<a class="btn btn-sm rounded btn-primary" href="{{route('profiler.index')}}"><i class="fa fa-list"></i></a>
|
||||||
|
<div class="pull-right">
|
||||||
|
@foreach(['0' => 'today', '7' => 'days', '30' => 'days', 'inf' => 'overall'] as $pastDay => $name)
|
||||||
|
@php $filter['httpLog'] = $httpLog ;$filter['pastDays'] = $pastDay; @endphp
|
||||||
|
|
||||||
|
<a class="btn btn-sm rounded @if($pastDays === (string)$pastDay) btn-primary @else btn-secondary @endif"
|
||||||
|
href="{{route('request.detail', $filter)}}">{{trans_choice('profiler::module.index.pastDays.'.$name, $pastDay)}}</a>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row text-center">
|
||||||
|
<a href="{{route('profiler.deleteAll')}}" class="btn btn-danger remove confirm">
|
||||||
|
<i class="fa fa-trash-o"></i> @lang('profiler::module.deleteAllData')
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="{{route('profiler.deleteAll', ['olderThan' => 30])}}" class="btn btn-danger remove confirm">
|
||||||
|
<i class="fa fa-trash-o"></i> @lang('profiler::module.deleteOld')
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ return [
|
|||||||
"logoutSuccessfull" => "Odhlášení proběhlo úspěšně",
|
"logoutSuccessfull" => "Odhlášení proběhlo úspěšně",
|
||||||
"no" => "Ne",
|
"no" => "Ne",
|
||||||
"yes" => "Ano",
|
"yes" => "Ano",
|
||||||
|
'empty' => 'Žádná data nebyla nalezena.'
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user