Show packet contents for nodes

This commit is contained in:
Deon George 2023-07-16 00:41:36 +10:00
parent a3302b4012
commit a8f76aec31
5 changed files with 142 additions and 4 deletions

View File

@ -31,6 +31,34 @@ class HomeController extends Controller
->with('o',$o); ->with('o',$o);
} }
public function packet_contents(string $packet)
{
$nm = Netmail::select('netmails.*')
->distinct()
->leftJoin('netmail_path',['netmail_path.netmail_id'=>'netmails.id'])
->where(function($query) use ($packet) {
return $query
->where('sent_pkt',$packet)
->orWhere('netmail_path.recv_pkt',$packet);
})
->get();
$em = Echomail::select('echomails.*')
->distinct()
->leftJoin('echomail_seenby',['echomail_seenby.echomail_id'=>'echomails.id'])
->leftJoin('echomail_path',['echomail_path.echomail_id'=>'echomails.id'])
->where(function($query) use ($packet) {
return $query
->where('sent_pkt',$packet)
->orWhere('recv_pkt',$packet);
})
->get();
return view('packet')
->with('nm',$nm)
->with('em',$em);
}
/** /**
* Render a view that summarises the users permissions * Render a view that summarises the users permissions
*/ */

View File

@ -0,0 +1,51 @@
@if($nm->count())
<table class="table monotable">
<thead>
<tr>
<th colspan="4">Netmails</th>
</tr>
<tr>
<th>From</th>
<th>To</th>
<th>MSGID</th>
<th>Date</th>
</tr>
</thead>
<tbody>
@foreach ($nm as $oo)
<tr>
<td>{{ $oo->fftn->ftn }}</td>
<td>{{ $oo->tftn->ftn }}</td>
<td>{{ $oo->msgid }}</td>
<td>{{ $oo->datetime }}</td>
</tr>
@endforeach
</tbody>
</table>
@endif
@if($em->count())
<table class="table monotable">
<thead>
<tr>
<th colspan="4">Echomails</th>
</tr>
<tr>
<th>From</th>
<th>MSGID</th>
<th>Date</th>
</tr>
</thead>
<tbody>
@foreach ($em as $oo)
<tr>
<td>{{ $oo->fftn->ftn }}</td>
<td>{{ $oo->msgid }}</td>
<td>{{ $oo->datetime }}</td>
</tr>
@endforeach
</tbody>
</table>
@endif

View File

@ -435,7 +435,7 @@
<tbody> <tbody>
@foreach ($x->groupBy('sent_pkt') as $oo) @foreach ($x->groupBy('sent_pkt') as $oo)
<tr> <tr>
<td>{{ $oo->first()->sent_pkt }}</td> <td class="packet">{{ $oo->first()->sent_pkt }}</td>
<td>{{ $oo->count() }}</td> <td>{{ $oo->count() }}</td>
<td>{{ $oo->first()->sent_at }}</td> <td>{{ $oo->first()->sent_at }}</td>
</tr> </tr>
@ -470,7 +470,7 @@
<tbody> <tbody>
@foreach ($x->groupBy('sent_pkt') as $oo) @foreach ($x->groupBy('sent_pkt') as $oo)
<tr> <tr>
<td>{{ $oo->first()->sent_pkt }}</td> <td class="packet">{{ $oo->first()->sent_pkt }}</td>
<td>{{ $oo->count() }}</td> <td>{{ $oo->count() }}</td>
<td>{{ $oo->first()->sent_at }}</td> <td>{{ $oo->first()->sent_at }}</td>
</tr> </tr>
@ -505,7 +505,7 @@
<tbody> <tbody>
@foreach ($x->groupBy('recv_pkt') as $oo) @foreach ($x->groupBy('recv_pkt') as $oo)
<tr> <tr>
<td>{{ $oo->first()->recv_pkt }}</td> <td class="packet">{{ $oo->first()->recv_pkt }}</td>
<td>{{ $oo->count() }}</td> <td>{{ $oo->count() }}</td>
<td>{{ $oo->first()->created_at }}</td> <td>{{ $oo->first()->created_at }}</td>
</tr> </tr>
@ -540,7 +540,7 @@
<tbody> <tbody>
@foreach ($x->groupBy('recv_pkt') as $oo) @foreach ($x->groupBy('recv_pkt') as $oo)
<tr> <tr>
<td>{{ $oo->first()->recv_pkt }}</td> <td class="packet">{{ $oo->first()->recv_pkt }}</td>
<td>{{ $oo->count() }}</td> <td>{{ $oo->count() }}</td>
<td>{{ $oo->first()->created_at }}</td> <td>{{ $oo->first()->created_at }}</td>
</tr> </tr>
@ -561,6 +561,7 @@
@endif @endif
</div> </div>
@include('widgets.modal_packet')
@include('widgets.modal_purge') @include('widgets.modal_purge')
@endsection @endsection

View File

@ -0,0 +1,56 @@
<div class="modal fade" id="packet-contents" tabindex="-1">
<div class="modal-dialog modal-lg modal-dialog-scrollable">
<div class="modal-content bg-dark">
<div class="modal-header bg-success">
<h5 class="modal-title text-light">Summary Packet Contents for <span id="packet"></span></h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<i id="spinner" class="spinner-grow spinner-grow-sm d-none"></i>
<div id="modal-content"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
@section('page-scripts')
<script>
var packet = new bootstrap.Modal(document.getElementById('packet-contents'), {});
$(document).ready(function() {
$('.packet').click(function(e) {
var item = this;
var icon = $('#spinner');
$('span#packet').html(e.target.innerText);
packet.show();
$.ajax({
type: 'POST',
data: {packet: e.target.innerText,_token: '{{csrf_token()}}'},
beforeSend: function() {
icon.toggleClass('d-none');
},
success: function(data) {
icon.toggleClass('d-none');
$('div#modal-content').html(data);
},
error: function(e) {
icon.toggleClass('d-none');
alert('That didnt work? Please try again....');
},
url: '{{ url('packet/contents') }}/'+e.target.innerText,
cache: false
})
return false;
});
});
</script>
@append

View File

@ -106,6 +106,8 @@ Route::middleware(['auth','verified','activeuser'])->group(function () {
Route::get('hubs/{o}/{host}',[DomainController::class,'api_hubs']) Route::get('hubs/{o}/{host}',[DomainController::class,'api_hubs'])
->where('o','[0-9]+'); ->where('o','[0-9]+');
Route::match(['get','post'],'link',[UserController::class,'link']); Route::match(['get','post'],'link',[UserController::class,'link']);
Route::post('packet/contents/{o}',[HomeController::class,'packet_contents'])
->where('o','[0-9a-f]+');
Route::get('permissions',[HomeController::class,'permissions']); Route::get('permissions',[HomeController::class,'permissions']);
Route::get('regions/{o}',[DomainController::class,'api_regions']) Route::get('regions/{o}',[DomainController::class,'api_regions'])
->where('o','[0-9]+'); ->where('o','[0-9]+');