First work on a status page showing nodes with uncollected mail

This commit is contained in:
Deon George 2023-11-24 21:49:38 +11:00
parent bed5bf8acc
commit 4c91ed54c0
4 changed files with 138 additions and 0 deletions

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
@ -242,4 +243,51 @@ class HomeController extends Controller
return view('setup')
->with('o',$o);
}
public function status()
{
$date = Carbon::now()->yesterday()->endOfday();
// Nodes with uncollected mail
$e = Address::select(['addresses.id',DB::raw('count(*) as e'),DB::raw('0 as n'),DB::raw('0 as f')])
->join('echomail_seenby',['echomail_seenby.address_id'=>'addresses.id'])
->join('echomails',['echomails.id'=>'echomail_seenby.echomail_id'])
->whereNotNull('export_at')
->whereNull('sent_at')
->where('datetime','<',$date)
->groupBy('addresses.id');
$n = Address::select(['addresses.id',DB::raw('0 as e'),DB::raw('count(*) as n'),DB::raw('0 as f')])
->join('netmails',['netmails.tftn_id'=>'addresses.id'])
->whereNull('sent_at')
->where('datetime','<',$date)
->groupBy('addresses.id');
$f = Address::select(['addresses.id',DB::raw('0 as e'),DB::raw('0 as n'),DB::raw('count(*) as f')])
->join('file_seenby',['file_seenby.address_id'=>'addresses.id'])
->join('files',['files.id'=>'file_seenby.file_id'])
->whereNotNull('export_at')
->whereNull('sent_at')
->where('datetime','<',$date)
->groupBy('addresses.id');
$r = Address::select([
'a.id',
'system_id',
'zone_id',
'host_id',
'node_id',
DB::raw('sum(a.e) as e'),
DB::raw('sum(a.n) as n'),
DB::raw('sum(a.f) as f')
])
->from($e->union($n)->union($f),'a')
->join('addresses',['addresses.id'=>'a.id'])
->groupBy('system_id','a.id','zone_id','host_id','node_id')
->with(['system','zone.domain']);
return view('status')
->with('date',$date)
->with('uncollected',$r->get());
}
}

View File

@ -6,6 +6,7 @@
<li><a href="{{ url('about') }}" class="@if(preg_match('#^about#',request()->path()))thispage disabled @endif"><span>About</span></a></li>
<li><a href="{{ url('domain/list') }}" class="@if(preg_match('#^domain/list#',request()->path()))thispage disabled @endif"><span>FTN List</span></a></li>
<li><a href="{{ url('system/list') }}" class="@if(preg_match('#^system/list#',request()->path()))thispage disabled @endif"><span>BBS List</span></a></li>
<li><a href="{{ url('status') }}" class="@if(preg_match('#^status#',request()->path()))thispage disabled @endif"><span>Status</span></a></li>
{{--
<li><a href="{{ url('help') }}" class="@if(preg_match('#^help#',request()->path()))thispage @endif disabled"><span>Help</span></a></li>
--}}

View File

@ -0,0 +1,88 @@
@extends('layouts.app')
@section('htmlheader_title')
Stats
@endsection
@section('content')
<div class="row">
<div class="col-12">
<h2>Network Status</h2>
</div>
</div>
<div class="row">
<div class="col-12">
<p>Nodes with uncollected mail as at <strong class="highlight">{{ $date }}</strong>:</p>
<table class="table monotable w-100" id="mailfiles">
<thead>
<tr>
<th>Network</th>
<th>System</th>
<th>Address</th>
<th class="text-right">Echomails</th>
<th class="text-right">Netmails</th>
<th class="text-right">Files</th>
<th>Last Session</th>
<th>Poll Mode</th>
<th>Auto Hold</th>
</tr>
</thead>
<tbody>
@foreach($uncollected as $o)
<tr>
<td>{{ $o->zone->domain->name }}</td>
<td><a href="{{ url('system/addedit',$o->system_id) }}">{{ $o->system->name }}</a></td>
<td>{{ $o->ftn4d }}</td>
<td class="text-right">{{ number_format($o->e ?? 0) }}</td>
<td class="text-right">{{ number_format($o->n ?? 0) }}</td>
<td class="text-right">{{ number_format($o->f ?? 0) }}</td>
<td>{{ $o->system->last_session?->format('Y-m-d H:i') }}</td>
<td>{{ is_null($o->system->pollmode) ? 'HOLD' : ($o->system->pollmode ? 'CRASH' : 'DAILY') }}</td>
<td>{{ $o->system->autohold ? 'YES' : 'NO' }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@endsection
@section('page-css')
@css('datatables')
@append
@section('page-scripts')
@js('datatables')
<script type="text/javascript">
$(document).ready(function() {
$('#mailfiles').DataTable({
paging: true,
pageLength: 25,
searching: true,
orderFixed: [0,'asc'],
order: [[1,'asc']],
conditionalPaging: {
style: 'fade',
speed: 500
},
rowGroup: {
dataSrc: [0],
},
columnDefs: [
{
targets: [0],
visible: false,
},
],
language: {
paginate: {
previous: '&lt;&lt;',
next: '&gt;&gt;'
}
}
});
});
</script>
@append

View File

@ -45,6 +45,7 @@ Route::view('domain/list','domain.list');
Route::get('domain/view/{o}',[DomainController::class,'view'])
->where('o','[0-9]+');
Route::match(['get','post'],'pkt',[HomeController::class,'pkt']);
Route::get('/status',[HomeController::class,'status']);
Route::view('system/list','system.list');
Route::get('system/view/{o}',[SystemController::class,'view'])
->where('o','[0-9]+');