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);
|
->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)
|
public function link(Request $request)
|
||||||
{
|
{
|
||||||
if ($request->post()) {
|
if ($request->post()) {
|
||||||
|
@ -71,6 +71,7 @@ class System extends Model
|
|||||||
->where('addresses.active',TRUE)
|
->where('addresses.active',TRUE)
|
||||||
->where('zones.active',TRUE)
|
->where('zones.active',TRUE)
|
||||||
->where('domains.active',TRUE)
|
->where('domains.active',TRUE)
|
||||||
|
->orderBy('domains.name')
|
||||||
->FTNorder()
|
->FTNorder()
|
||||||
->orderBy('role','ASC');
|
->orderBy('role','ASC');
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,6 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
*/
|
*/
|
||||||
public function isZC(): bool
|
public function isZC(): bool
|
||||||
{
|
{
|
||||||
$this->load(['systems.addresses']);
|
|
||||||
return $this->zc()->count() > 0;
|
return $this->zc()->count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,28 +3,38 @@
|
|||||||
Dashboard
|
Dashboard
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@php($user->load(['systems.akas.zone.domain.echoareas','systems.akas.echoareas']))
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<h1>{{ $user->name }}</h1>
|
<h1>{{ $user->name }}</h1>
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
@if($user->systems->count())
|
@if($user->systems->count())
|
||||||
<div class="col-8">
|
<div class="row">
|
||||||
|
<div class="col-7">
|
||||||
<div id="network_messages"></div>
|
<div id="network_messages"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- System Addresses -->
|
<!-- System Addresses -->
|
||||||
<div class="col-4">
|
<div class="col-5">
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<table class="table monotable">
|
<table class="table monotable">
|
||||||
<thead>
|
<thead>
|
||||||
<tr><th colspan="2">System Addresses</th></tr>
|
<tr><th colspan="2">System Addresses</th></tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach ($user->systems as $o)
|
|
||||||
|
@foreach ($user->systems->sortBy('name') as $o)
|
||||||
<tr>
|
<tr>
|
||||||
<th><a href="{{ url('system/addedit',[$o->id]) }}">{{ $o->name }}</a></th>
|
<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>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -34,26 +44,36 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
<h3>Active and Available Echos</h3>
|
||||||
<table class="table monotable">
|
<table class="table monotable">
|
||||||
<thead>
|
|
||||||
<tr><th colspan="2">Available Echos</th></tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
<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>
|
<tr>
|
||||||
<th><a href="{{ url('system/addedit',[$o->id]) }}">{{ $o->name }}</a></th>
|
<th class="nowrap">
|
||||||
<th class="text-end">{!! $o->addresses->pluck('zone.domain.echoareas')->flatten()->pluck('name')->unique()->sort()->join(', ') !!}</th>
|
<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>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
@else
|
@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>
|
<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
|
@endif
|
||||||
</div>
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@section('page-css')
|
@section('page-css')
|
||||||
@ -162,7 +182,7 @@
|
|||||||
name: 'Networks',
|
name: 'Networks',
|
||||||
colorByPoint: true,
|
colorByPoint: true,
|
||||||
data: [
|
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 }}',
|
name: '{{ $do->name }}',
|
||||||
y: {{ $do->daily_area_stats()->sum('y') }},
|
y: {{ $do->daily_area_stats()->sum('y') }},
|
||||||
@ -176,7 +196,7 @@
|
|||||||
colorByPoint: true,
|
colorByPoint: true,
|
||||||
pointPlacement: 0.1,
|
pointPlacement: 0.1,
|
||||||
data: [
|
data: [
|
||||||
@foreach($xx as $do)
|
@foreach($dl as $do)
|
||||||
{
|
{
|
||||||
name: '{{ $do->name }}',
|
name: '{{ $do->name }}',
|
||||||
y: {{ $do->daily_area_stats(FALSE,$user->systems)->sum('y') }},
|
y: {{ $do->daily_area_stats(FALSE,$user->systems)->sum('y') }},
|
||||||
@ -195,7 +215,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
series: [
|
series: [
|
||||||
@foreach($xx as $do)
|
@foreach($dl as $do)
|
||||||
{
|
{
|
||||||
name: '{{ $do->name }}',
|
name: '{{ $do->name }}',
|
||||||
id: 'n-{{ $do->name }}',
|
id: 'n-{{ $do->name }}',
|
||||||
@ -203,7 +223,7 @@
|
|||||||
},
|
},
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
@foreach($xx as $do)
|
@foreach($dl as $do)
|
||||||
{
|
{
|
||||||
name: '{{ $do->name }}',
|
name: '{{ $do->name }}',
|
||||||
id: 'ny-{{ $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::get('search',[HomeController::class,'search']);
|
||||||
|
|
||||||
Route::middleware(['auth','verified','activeuser'])->group(function () {
|
Route::middleware(['auth','verified','activeuser'])->group(function () {
|
||||||
Route::get('dashboard',[UserController::class,'dashboard']);
|
Route::view('dashboard','dashboard');
|
||||||
|
|
||||||
/* DOMAIN PATHS */
|
/* DOMAIN PATHS */
|
||||||
Route::view('domain','domain.home');
|
Route::view('domain','domain.home');
|
||||||
|
Loading…
Reference in New Issue
Block a user