Optimise queries for rendering the users dashboard page
This commit is contained in:
parent
d6e23b9a90
commit
bac41969a5
@ -36,15 +36,6 @@ class UserController extends Controller
|
||||
->with('o',$o);
|
||||
}
|
||||
|
||||
public function dashboard()
|
||||
{
|
||||
$user = Auth::user();
|
||||
$user->load('systems.addresses.zone.domain.echoareas');
|
||||
|
||||
return view('dashboard')
|
||||
->with('user',$user);
|
||||
}
|
||||
|
||||
public function link(Request $request)
|
||||
{
|
||||
if ($request->post()) {
|
||||
|
@ -71,6 +71,7 @@ class System extends Model
|
||||
->where('addresses.active',TRUE)
|
||||
->where('zones.active',TRUE)
|
||||
->where('domains.active',TRUE)
|
||||
->orderBy('domains.name')
|
||||
->FTNorder()
|
||||
->orderBy('role','ASC');
|
||||
}
|
||||
|
@ -102,7 +102,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
||||
*/
|
||||
public function isZC(): bool
|
||||
{
|
||||
$this->load(['systems.addresses']);
|
||||
return $this->zc()->count() > 0;
|
||||
}
|
||||
|
||||
|
@ -3,28 +3,38 @@
|
||||
Dashboard
|
||||
@endsection
|
||||
|
||||
@php($user->load(['systems.akas.zone.domain.echoareas','systems.akas.echoareas']))
|
||||
|
||||
@section('content')
|
||||
<h1>{{ $user->name }}</h1>
|
||||
|
||||
<div class="row">
|
||||
@if($user->systems->count())
|
||||
<div class="col-8">
|
||||
<div class="row">
|
||||
<div class="col-7">
|
||||
<div id="network_messages"></div>
|
||||
</div>
|
||||
|
||||
<!-- System Addresses -->
|
||||
<div class="col-4">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="col-5">
|
||||
<table class="table monotable">
|
||||
<thead>
|
||||
<tr><th colspan="2">System Addresses</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($user->systems as $o)
|
||||
|
||||
@foreach ($user->systems->sortBy('name') as $o)
|
||||
<tr>
|
||||
<th><a href="{{ url('system/addedit',[$o->id]) }}">{{ $o->name }}</a></th>
|
||||
<th class="text-end">{!! $o->akas->pluck('ftn')->join('<br>') !!}</th>
|
||||
<th class="text-end">
|
||||
<small><small><strong>{{ $o->akas->count() }}</strong> AKAs configured</small></small><br><br>
|
||||
@if ($o->akas->count())
|
||||
@foreach ($o->akas as $ao)
|
||||
{{ $ao->ftn }} <small>({{ $ao->security ?: '-' }})</small><br>
|
||||
@endforeach
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</th>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
@ -34,26 +44,36 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h3>Active and Available Echos</h3>
|
||||
<table class="table monotable">
|
||||
<thead>
|
||||
<tr><th colspan="2">Available Echos</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($user->systems as $o)
|
||||
@foreach (($dl=$user
|
||||
->systems
|
||||
->pluck('akas')->flatten()
|
||||
->pluck('zone.domain')
|
||||
->unique()
|
||||
->filter(function($item) { return $item->active && $item->public && $item->isManaged(); })
|
||||
->sortBy('name')) as $o)
|
||||
<tr>
|
||||
<th><a href="{{ url('system/addedit',[$o->id]) }}">{{ $o->name }}</a></th>
|
||||
<th class="text-end">{!! $o->addresses->pluck('zone.domain.echoareas')->flatten()->pluck('name')->unique()->sort()->join(', ') !!}</th>
|
||||
<th class="nowrap">
|
||||
<a href="{{ url('domain/view',[$o->id]) }}">{{ $o->name }}</a> <small>({{ $sec=$user->systems->pluck('akas')->flatten()->filter(function($item) use ($o) { return $item->zone->domain_id === $o->id; })->max('security') ?? '-' }})</small><br><br>
|
||||
{{ ($sub=$user->systems->pluck('akas')->flatten()->pluck('echoareas')->flatten()->filter(function($item) use ($o) { return $item->domain_id === $o->id; }))->count() }} <small>Subscribed</small>
|
||||
</th>
|
||||
<td>
|
||||
@foreach ($o->echoareas->sortBy('name') as $eo)
|
||||
<span style="@if (($sec < $eo->sec_read) || ($sec < $eo->sec_write) || ! $eo->active) color: red; @elseif($sub->where('name',$eo->name)->count()) color: green; @endif">{{ $eo->name }}</span>
|
||||
@endforeach
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@else
|
||||
<p>You are not linked to any BBS systems. Start <a href="{{ url('user/system/register') }}">here</a> to link to your first.</p>
|
||||
@endif
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('page-css')
|
||||
@ -162,7 +182,7 @@
|
||||
name: 'Networks',
|
||||
colorByPoint: true,
|
||||
data: [
|
||||
@foreach(($xx=$user->systems->pluck('addresses')->flatten()->pluck('zone.domain')->unique(function($item) { return $item->name; })->sortBy('name')) as $do)
|
||||
@foreach($dl as $do)
|
||||
{
|
||||
name: '{{ $do->name }}',
|
||||
y: {{ $do->daily_area_stats()->sum('y') }},
|
||||
@ -176,7 +196,7 @@
|
||||
colorByPoint: true,
|
||||
pointPlacement: 0.1,
|
||||
data: [
|
||||
@foreach($xx as $do)
|
||||
@foreach($dl as $do)
|
||||
{
|
||||
name: '{{ $do->name }}',
|
||||
y: {{ $do->daily_area_stats(FALSE,$user->systems)->sum('y') }},
|
||||
@ -195,7 +215,7 @@
|
||||
}
|
||||
},
|
||||
series: [
|
||||
@foreach($xx as $do)
|
||||
@foreach($dl as $do)
|
||||
{
|
||||
name: '{{ $do->name }}',
|
||||
id: 'n-{{ $do->name }}',
|
||||
@ -203,7 +223,7 @@
|
||||
},
|
||||
@endforeach
|
||||
|
||||
@foreach($xx as $do)
|
||||
@foreach($dl as $do)
|
||||
{
|
||||
name: '{{ $do->name }}',
|
||||
id: 'ny-{{ $do->name }}',
|
||||
|
@ -52,7 +52,7 @@ Route::get('system/view/{o}',[SystemController::class,'view'])
|
||||
Route::get('search',[HomeController::class,'search']);
|
||||
|
||||
Route::middleware(['auth','verified','activeuser'])->group(function () {
|
||||
Route::get('dashboard',[UserController::class,'dashboard']);
|
||||
Route::view('dashboard','dashboard');
|
||||
|
||||
/* DOMAIN PATHS */
|
||||
Route::view('domain','domain.home');
|
||||
|
Loading…
Reference in New Issue
Block a user