Added system polling

This commit is contained in:
2023-07-26 19:44:07 +10:00
parent c23b5ebfc2
commit 4e44e2e266
19 changed files with 733 additions and 88 deletions

View File

@@ -272,8 +272,8 @@
<table class="table monotable">
<thead>
<tr>
<th>Zone</th>
<th>System</th>
<th>AKA</th>
<th>Uplink</th>
</tr>
</thead>
@@ -286,7 +286,7 @@
@if ($x=$oo->parent())
{{ $x->ftn4d }}
@else
No destination for mail.
None
@endif
</td>
</tr>
@@ -305,8 +305,8 @@
<table class="table monotable">
<thead>
<tr>
<th>Zone</th>
<th>System</th>
<th>AKA</th>
<th>Downlink</th>
</tr>
</thead>

View File

@@ -1,3 +1,4 @@
<!-- $o = System::class -->
@php
use App\Models\Setup;
@endphp
@@ -21,8 +22,22 @@
</div>
</div>
<!-- ZeroTier ID -->
<div class="col-3">
<label for="zt_id" class="form-label">ZeroTier ID</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-shield-lock-fill"></i></span>
<input type="text" class="form-control @error('zt_id') is-invalid @enderror" id="zt_id" placeholder="ZeroTier" name="zt_id" value="{{ old('zt_id',$o->zt_id) }}" @cannot($action,$o)readonly @endcannot>
<span class="invalid-feedback" role="alert">
@error('zt_id')
{{ $message }}
@enderror
</span>
</div>
</div>
<!-- Active -->
<div class="col-2">
<div class="offset-2 col-2">
@can('update',$o)
<label for="active" class="form-label">Active</label>
<div class="input-group">
@@ -36,36 +51,6 @@
</div>
@endcan
</div>
<!-- Hold -->
<div class="col-2">
@can('update',$o)
<label for="hold" class="form-label">Hold Mail</label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="hold" id="hold_yes" value="1" required @if(old('hold',$o->hold))checked @endif>
<label class="btn btn-outline-success" for="hold_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="hold" id="hold_no" value="0" required @if(! old('hold',$o->hold))checked @endif>
<label class="btn btn-outline-danger" for="hold_no">No</label>
</div>
</div>
@endcan
</div>
<!-- ZeroTier ID -->
<div class="offset-1 col-3">
<label for="zt_id" class="form-label">ZeroTier ID</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-shield-lock-fill"></i></span>
<input type="text" class="form-control @error('zt_id') is-invalid @enderror" id="zt_id" placeholder="ZeroTier" name="zt_id" value="{{ old('zt_id',$o->zt_id) }}" @cannot($action,$o)readonly @endcannot>
<span class="invalid-feedback" role="alert">
@error('zt_id')
{{ $message }}
@enderror
</span>
</div>
</div>
</div>
<div class="row">
@@ -86,7 +71,7 @@
</div>
<!-- Location -->
<div class="col-8">
<div class="col-4">
<label for="location" class="form-label">Location</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-globe"></i></span>
@@ -100,10 +85,41 @@
</span>
</div>
</div>
<!-- Hold -->
<div class="offset-1 col-2">
@can('update',$o)
<label for="hold" class="form-label">Hold Mail <i class="bi bi-info-circle" title="Dont give the node any mail regardless of poll mode"></i></label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="hold" id="hold_yes" value="1" required @if(old('hold',$o->hold))checked @endif>
<label class="btn btn-outline-warning" for="hold_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="hold" id="hold_no" value="0" required @if(! old('hold',$o->hold))checked @endif>
<label class="btn btn-outline-success" for="hold_no">No</label>
</div>
</div>
@endcan
</div>
</div>
<div class="row">
<div class="col-4">
<!-- Address -->
<div class="col-5">
<label for="address" class="form-label">Internet Address</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-globe"></i></span>
<input type="text" class="w-75 form-control @error('address') is-invalid @enderror" id="address" placeholder="FQDN" name="address" value="{{ old('address',$o->address) }}" @cannot($action,$o)readonly @endcannot>
<span class="invalid-feedback" role="alert">
@error('address')
{{ $message }}
@enderror
</span>
</div>
</div>
<!-- Phone -->
<div class="col-3">
<label for="phone" class="form-label">Phone</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-telephone-fill"></i></span>
@@ -116,18 +132,28 @@
</div>
</div>
<!-- Address -->
<div class="col-8">
<label for="address" class="form-label">Internet Address</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-globe"></i></span>
<input type="text" class="w-75 form-control @error('address') is-invalid @enderror" id="address" placeholder="FQDN" name="address" value="{{ old('address',$o->address) }}" @cannot($action,$o)readonly @endcannot>
<span class="invalid-feedback" role="alert">
@error('address')
{{ $message }}
@enderror
</span>
</div>
<!-- Poll Mode -->
<div class="offset-1 col-3">
@can('update',$o)
<label for="pollmode" class="form-label">Poll Mode <i class="bi bi-info-circle" title="Poll node when mail available, poll on a schedule or hold mail for collection"></i></label>
<div class="input-group has-validation">
<div class="btn-group @error('pollmode') is-invalid @enderror" role="group">
<input type="radio" class="btn-check" name="pollmode" id="poll_crash" value="2" @if((int)old('pollmode',($o->pollmode === TRUE) ? 2 : 0) === 2)checked @endif>
<label class="btn btn-outline-success" for="poll_crash">Crash</label>
<input type="radio" class="btn-check btn-danger" name="pollmode" id="poll_normal" value="1" @if((int)old('pollmode',($o->pollmode === FALSE) ? 1 : 0) === 1)checked @endif>
<label class="btn btn-outline-secondary" for="poll_normal">Normal</label>
<input type="radio" class="btn-check btn-danger" name="pollmode" id="poll_hold" value="0" @if((int)old('pollmode',is_null($o->pollmode) ? 0 : 1) === 0)checked @endif>
<label class="btn btn-outline-warning" for="poll_hold">Hold</label>
</div>
<span class="invalid-feedback" role="alert">
@error('pollmode')
{{ $message }}
@enderror
</span>
</div>
@endcan
</div>
</div>
@@ -136,6 +162,7 @@
<div class="col-12">
<h4 class="pt-4 mb-0 pb-2">Mailer Details</h4>
<!-- Mailer Ports -->
<div class="pt-0 row">
<div class="col-3">
@foreach (\App\Models\Mailer::all() as $mo)
@@ -160,6 +187,7 @@
@endforeach
</div>
<!-- Mail Packet -->
<div class="col-2">
<label for="pkt_type" class="form-label">Mail Packet</label>
<div class="input-group">
@@ -177,6 +205,55 @@
</div>
</div>
@if (! is_null($o->pollmode))
<div class="offset-3 col-4">
<table class="table monotable m-0 p-0 small noborder">
<tbody style="border-style:dotted;">
@if($job = $o->poll())
<tr>
<td class="cap text-end">@if($job->attempts)Last Attempt @else Scheduled @endif:</td>
<td>{{ $job->created_at }} </td>
</tr>
<tr>
<td class="cap text-end">Attempts :</td>
<td>{{ $job->attempts ?: 0 }}</td>
</tr>
@if ($job->attempts)
<tr>
<td class="cap text-end">Next Attempt :</td>
<td>{{ $job->available_at->diffForHumans(now(),$job->available_at->isFuture() ? \Carbon\CarbonInterface::DIFF_ABSOLUTE : \Carbon\CarbonInterface::DIFF_RELATIVE_TO_NOW) }}</td>
</tr>
@endif
@else
<tr>
<td class="cap text-end">Last Poll :</td>
<td>{{ ($x=$o->logs->where('originate',TRUE)->last())?->created_at ?: 'Never' }}</td>
</tr>
<tr>
<td class="cap text-end">Method :</td>
<td>{{ $x?->sessiontype ?: '-' }}</td>
</tr>
@endif
<tr>
<td class="cap text-end">Status :</td>
<td>
@if ($job) Queued
@elseif ($o->autohold)Auto Hold
@else
@switch($o->pollmode)
@case(TRUE) Crash @break;
@case(FALSE) Normal @break;
@default Hold
@endswitch
@endif
</td>
</tr>
</tbody>
</table>
</div>
@endif
</div>
</div>
</div>