Added Zones, authorisation on edits, validation enhancements

This commit is contained in:
Deon George
2021-06-18 23:01:41 +10:00
parent 491d3d55c3
commit 416e79164e
14 changed files with 511 additions and 107 deletions

View File

@@ -25,7 +25,7 @@
<table class="table table-sm">
<thead>
<tr>
<th>Domain</th>
<th class="w-75">Domain</th>
<th>Result</th>
</tr>
</thead>
@@ -41,6 +41,52 @@
</table>
</td>
</tr>
<tr>
<td>System</td>
<td>
<table class="table table-sm">
<thead>
<tr>
<th class="w-75">System</th>
<th>Result</th>
</tr>
</thead>
<tbody>
@foreach (\App\Models\System::orderBy('name')->get() as $o)
<tr>
<td>{{ $o->name }}</td>
<td>@can('admin',$o)YES @else NO @endcan</td>
</tr>
@endforeach
</tbody>
</table>
</td>
</tr>
<tr>
<td>Zone</td>
<td>
<table class="table table-sm">
<thead>
<tr>
<th class="w-75">Zone</th>
<th>Result</th>
</tr>
</thead>
<tbody>
@foreach (\App\Models\Zone::orderBy('zone_id')->get() as $o)
<tr>
<td>{{ $o->zone_id }}</td>
<td>@can('admin',$o)YES @else NO @endcan</td>
</tr>
@endforeach
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
@endsection

View File

@@ -18,7 +18,7 @@
<label for="name" class="form-label">Name</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-tag-fill"></i></span>
<input type="text" class="form-control @error('name') is-invalid @enderror" id="name" placeholder="Name" name="name" value="{{ old('name',$o->name) }}" required autocomplete="name" autofocus>
<input type="text" class="form-control @error('name') is-invalid @enderror" id="name" placeholder="Name" name="name" value="{{ old('name',$o->name) }}" required @cannot('admin',$o)disabled @endcannot autofocus>
@error('name')
<span class="invalid-feedback" role="alert">
{{ $message }}
@@ -33,12 +33,12 @@
<div class="col-4">
<label for="active" class="form-label">Active</label>
<div class="input-group has-validation">
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="active" id="active_yes" value="1" required @if(old('active',$o->active))checked @endif>
<input type="radio" class="btn-check" name="active" id="active_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('active',$o->active))checked @endif>
<label class="btn btn-outline-success" for="active_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="active" id="active_no" value="0" required @if(! old('active',$o->active))checked @endif>
<input type="radio" class="btn-check btn-danger" name="active" id="active_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('active',$o->active))checked @endif>
<label class="btn btn-outline-danger" for="active_no">No</label>
</div>
</div>
@@ -50,23 +50,23 @@
<label for="dnsdomain" class="form-label">DNS Domain</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-globe"></i></span>
<input type="text" class="form-control @error('dnsdomain') is-invalid @enderror" id="dnsdomain" placeholder="DNS Domain (if applicable)" name="dnsdomain" value="{{ old('dnsdomain',$o->dnsdomain) }}">
@error('dnsdomain')
<span class="invalid-feedback" role="alert">
<input type="text" class="form-control @error('dnsdomain') is-invalid @enderror" id="dnsdomain" placeholder="DNS Domain (if applicable)" name="dnsdomain" value="{{ old('dnsdomain',$o->dnsdomain) }}" @cannot('admin',$o)disabled @endcannot>
<span class="invalid-feedback" role="alert">
@error('dnsdomain')
{{ $message }}
</span>
@enderror
@enderror
</span>
</div>
</div>
<div class="col-4">
<label for="public" class="form-label">Public</label>
<div class="input-group has-validation">
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="public" id="public_yes" value="1" required @if(old('public',$o->public))checked @endif>
<input type="radio" class="btn-check" name="public" id="public_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('public',$o->public))checked @endif>
<label class="btn btn-outline-success" for="public_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="public" id="public_no" value="0" required @if(! old('public',$o->public))checked @endif>
<input type="radio" class="btn-check btn-danger" name="public" id="public_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('public',$o->public))checked @endif>
<label class="btn btn-outline-danger" for="public_no">No</label>
</div>
</div>
@@ -76,7 +76,7 @@
<div class="row">
<div class="col-12">
<label for="notes" class="form-label">Notes</label>
<textarea class="form-control" rows=3 cols=68 name="notes" placeholder="Notes...">{{ old('notes',$o->notes) }}</textarea>
<textarea class="form-control" rows=3 name="notes" placeholder="Notes..." @cannot('admin',$o)disabled @endcannot>{{ old('notes',$o->notes) }}</textarea>
</div>
</div>
</div>
@@ -92,7 +92,7 @@
<div class="col-12" >
<label for="homepage" class="form-label">Home Page Text</label>
<div style="background-color: #fff;color: #000;">
<textarea class="form-control" rows=5 cols=68 id="homepage" name="homepage" placeholder="Home Page...">{{ old('homepage',$o->homepage) }}</textarea>
<textarea class="form-control" rows=5 id="homepage" name="homepage" placeholder="Home Page..." @cannot('admin',$o)disabled @endcannot>{{ old('homepage',$o->homepage) }}</textarea>
</div>
</div>
</div>
@@ -101,7 +101,9 @@
<div class="row">
<div class="col-12">
<a href="{{ url('ftn/domain') }}" class="btn btn-danger">Cancel</a>
<button type="submit" name="submit" class="btn btn-success mr-0 float-end">@if ($o->exists)Save @else Add @endif</button>
@can('admin',$o)
<button type="submit" name="submit" class="btn btn-success mr-0 float-end">@if ($o->exists)Save @else Add @endif</button>
@endcan
</div>
</div>
</div>
@@ -110,10 +112,12 @@
@endsection
@section('page-scripts')
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
@can('admin',$o)
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
<script>
var simplemde = new SimpleMDE({ element: $("#homepage")[0] });
</script>
<script>
var simplemde = new SimpleMDE({ element: $("#homepage")[0] });
</script>
@endcan
@append

View File

@@ -7,7 +7,7 @@
<div class="row">
<div class="col-12">
<h2>About FTN Domains</h2>
<p>In FTN network addresses, a domain is the 5th dimension and used when a system supports 5D addressing, ie: zone:hub/host@<strong class="highlight">domain</strong>.</p>
<p>In FTN network addresses, a domain is the 5th dimension and used when a system supports 5D addressing, ie: zone:hub/host.point@<strong class="highlight">domain</strong>.</p>
<p>Domains are used with zones to uniquely identify a FTN network.</p>
<p><small>Some legacy Fidonet software is not 5D aware and may behave unexpectedly when a domain is used</small></p>
</div>
@@ -36,7 +36,7 @@
</thead>
<tbody>
@can('admin',(new \App\Models\Domain()))
@can('admin',(new \App\Models\Domain))
<tr>
<td colspan="5"><a href="{{ url('ftn/domain/addedit') }}">Add New Domain</a></td>
</tr>

View File

@@ -0,0 +1,139 @@
@extends('layouts.app')
@section('htmlheader_title')
@if($o->exists) Update @else Add @endif System
@endsection
@section('content')
<form class="row g-0 needs-validation" method="post" novalidate>
@csrf
<div class="row">
<div class="col-12">
<div class="greyframe titledbox shadow0xb0">
<h2 class="cap">@if($o->exists) Update @else Add @endif System</h2>
<div class="row">
<div class="col-4">
<label for="name" class="form-label">Name</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-tag-fill"></i></span>
<input type="text" class="form-control @error('name') is-invalid @enderror" id="name" placeholder="Name" name="name" value="{{ old('name',$o->name) }}" required @cannot('admin',$o)disabled @endcannot autofocus>
@error('name')
<span class="invalid-feedback" role="alert">
{{ $message }}
</span>
@else
<span class="invalid-feedback">
A name is required.
</span>
@enderror
</div>
</div>
<div class="col-4">
<label for="active" class="form-label">Active</label>
<div class="input-group">
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="active" id="active_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('active',$o->active))checked @endif>
<label class="btn btn-outline-success" for="active_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="active" id="active_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('active',$o->active))checked @endif>
<label class="btn btn-outline-danger" for="active_no">No</label>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-4">
<label for="sysop" class="form-label">Sysop</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-globe"></i></span>
<input type="text" class="form-control @error('sysop') is-invalid @enderror" id="sysop" placeholder="Sysop" name="sysop" value="{{ old('sysop',$o->sysop) }}" required @cannot('admin',$o)disabled @endcannot autocomplete="name">
@error('sysop')
<span class="invalid-feedback" role="alert">
{{ $message }}
</span>
@else
<span class="invalid-feedback">
A Sysop's name is required.
</span>
@enderror
</div>
</div>
<div class="col-8">
<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>
<input type="text" class="form-control @error('location') is-invalid @enderror" id="location" placeholder="Location" name="location" value="{{ old('location',$o->location) }}" required @cannot('admin',$o)disabled @endcannot>
@error('location')
<span class="invalid-feedback" role="alert">
{{ $message }}
</span>
@else
<span class="invalid-feedback">
System location is required.
</span>
@enderror
</div>
</div>
</div>
<div class="row">
<div class="col-4">
<label for="method" class="form-label">Connection Method</label>
<div class="input-group">
<span class="input-group-text"><i class="bi bi-wifi"></i></span>
<select class="form-select @error('method') is-invalid @enderror" id="method" name="method" @cannot('admin',$o)disabled @endcannot>
<option></option>
<option value="23" @if(old('method',$o->method) == 23)selected @endif)}}>Telnet</option>
<option value="22" @if(old('method',$o->method) == 22)selected @endif)}}>SSH</option>
<option value="519" @if(old('method',$o->method) == 519)selected @endif)}}>Rlogin</option>
</select>
</div>
</div>
<div class="col-8">
<label for="address" class="form-label">Address</label>
<div class="input-group">
<span class="input-group-text"><i class="bi bi-globe"></i></span>
<input type="text" class="form-control @error('address') is-invalid @enderror" id="address" placeholder="FQDN" name="address" value="{{ old('address',$o->address) }}" @cannot('admin',$o)disabled @endcannot>
<span class="m-0 p-0 input-group-text" style="background-color: #ffffff;">
<input type="text" class="form-control @error('port') is-invalid @enderror" id="port" placeholder="port" name="port" value="{{ old('port',$o->port) }}" @cannot('admin',$o)disabled @endcannot>
</span>
@error('address')
<span class="invalid-feedback" role="alert">
{{ $message }}
</span>
@enderror
@error('port')
<span class="invalid-feedback" role="alert">
{{ $message }}
</span>
@enderror
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<label for="notes" class="form-label">Notes</label>
<textarea class="form-control" rows=3 name="notes" placeholder="Notes..." @cannot('admin',$o)disabled @endcannot>{{ old('notes',$o->notes) }}</textarea>
</div>
</div>
<div class="row">
<div class="col-12">
<a href="{{ url('ftn/system') }}" class="btn btn-danger">Cancel</a>
@can('admin',$o)
<button type="submit" name="submit" class="btn btn-success mr-0 float-end">@if ($o->exists)Save @else Add @endif</button>
@endcan
</div>
</div>
</div>
</div>
</div>
</form>
@endsection

View File

@@ -19,7 +19,7 @@
</thead>
<tbody>
@can('admin',(new \App\Models\Domain()))
@can('admin',(new \App\Models\User))
<tr>
<td colspan="5"><a href="{{ url('user/addedit') }}">Add New User</a></td>
</tr>

View File

@@ -4,70 +4,125 @@
@if($o->exists) Update @else Add @endif Zone
@endsection
@section('main-content')
<div class="pb-3">
<h2>@if($o->exists) Update @else Add @endif Zone</h2>
@section('content')
<form class="row g-0 needs-validation" method="post" novalidate>
@csrf
<form method="POST">
{{ csrf_field() }}
<div class="row">
<div class="col-12">
<div class="greyframe titledbox shadow0xb0">
<h2 class="cap">@if($o->exists) Update @else Add @endif Zone</h2>
<div class="row">
<div class="col-9 m-auto">
<div class="bg-blue">
<div class="row m-3">
<label class="col-3" for="zone_id">Zone:</label>
<input class="col-2" type="text" name="zone_id" value="{{ $o->zone_id }}">
</div>
<div class="row m-3">
<label class="col-3" for="name">Name:</label>
<input class="col-9" type="text" name="name" value="{{ $o->name }}">
</div>
<div class="row m-3">
<label class="col-3" for="domain_id">Domain:</label>
<select class="col-3" name="domain_id">
<option value="">&nbsp;</option>
@foreach (\App\Models\Domain::active()->cursor() as $oo)
<option value="{{ $oo->id }}" @if($o->domain_id==$oo->id)selected @endif>{{ $oo->name }}</option>
@endforeach
</select>
</div>
<div class="row m-3">
<label class="col-3" for="description">Description:</label>
<input class="col-9" type="text" name="description" value="{{ $o->description }}">
</div>
<div class="row m-3">
<label class="col-3" for="active">Active:</label>
<div class="form-group col-3">
<div class="custom-control custom-radio mb-3">
<input type="radio" class="custom-control-input" name="active" id="active_yes" value="1" required @if($o->active)checked @endif>
<label class="custom-control-label" for="active_yes">Yes</label>
</div>
<div class="custom-control custom-radio mb-3">
<input type="radio" class="custom-control-input" name="active" id="active_no" value="0" required @if(! $o->active)checked @endif>
<label class="custom-control-label" for="active_no">No</label>
</div>
<div class="row">
<div class="col-2">
<label for="zone" class="form-label">Zone</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-hash"></i></span>
<input type="text" class="form-control @error('zone_id') is-invalid @enderror" id="zone" placeholder="Zone" name="zone_id" value="{{ old('zone_id',$o->zone_id) }}" required @cannot('admin',$o)disabled @endcannot autofocus>
@error('zone_id')
<span class="invalid-feedback" role="alert">
{{ $message }}
</span>
@else
<span class="invalid-feedback">
A zone number is required.
</span>
@enderror
</div>
</div>
<div class="row m-3">
<label class="col-3" for="notes">Notes:</label>
<textarea class="col-9" rows=3 cols=68 name="notes" placeholder="Notes...">{{ $o->notes }}</textarea>
<div class="col-3">
<label for="domain" class="form-label">Domain</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-tag-fill"></i></span>
<select class="form-select @error('domain_id') is-invalid @enderror" id="domain" name="domain_id" required @cannot('admin',$o)disabled @endcannot>
<option value="">&nbsp;</option>
@foreach (\App\Models\Domain::active()->cursor() as $oo)
<option value="{{ $oo->id }}" @if(old('domain_id',$o->domain_id)==$oo->id)selected @endif>{{ $oo->name }}</option>
@endforeach
</select>
@error('domain_id')
<span class="invalid-feedback" role="alert">
{{ $message }}
</span>
@else
<span class="invalid-feedback">
A domain is required.
</span>
@enderror
<span class="input-helper">Add a <a href="{{ url('ftn/domain/addedit') }}">NEW Domain</a></span>
</div>
</div>
<div class="row m-3">
<div class="col-12">
<button type="submit" name="submit" class="btn btn-lg btn-success mr-0 float-right">@if ($o->exists)Save @else Add @endif</button>
<a href="{{ url('/') }}" class="btn btn-lg btn-primary float-right">Cancel</a>
<div class="col-3">
<label for="system" class="form-label">System</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-laptop-fill"></i></span>
<select class="form-select @error('system_id') is-invalid @enderror" id="system" name="system_id" required @cannot('admin',$o)disabled @endcannot>
<option value="">&nbsp;</option>
@foreach (\App\Models\System::active()->cursor() as $oo)
<option value="{{ $oo->id }}" @if(old('system_id',$o->system_id)==$oo->id)selected @endif>{{ $oo->name }}</option>
@endforeach
</select>
@error('system_id')
<span class="invalid-feedback" role="alert">
{{ $message }}
</span>
@else
<span class="invalid-feedback">
A system is required.
</span>
@enderror
<span class="input-helper">Add a <a href="{{ url('ftn/system/addedit') }}">NEW System</a>. This system is the primary mailer/tosser responsible for managing the zone.</span>
</div>
</div>
<div class="col-4">
<label for="active" class="form-label">Active</label>
<div class="input-group" >
<div class="btn-group" role="group">
<input type="radio" class="btn-check" name="active" id="active_yes" value="1" required @cannot('admin',$o)disabled @endcannot @if(old('active',$o->active))checked @endif>
<label class="btn btn-outline-success" for="active_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="active" id="active_no" value="0" required @cannot('admin',$o)disabled @endcannot @if(! old('active',$o->active))checked @endif>
<label class="btn btn-outline-danger" for="active_no">No</label>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-3">
<label for="ztid" 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('ztid') is-invalid @enderror" id="ztid" placeholder="ZeroTier" name="ztid" value="{{ old('ztid',$o->ztid) }}" @cannot('admin',$o)disabled @endcannot>
<span class="invalid-feedback" role="alert">
@error('ztid')
{{ $message }}
@enderror
</span>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<label for="notes" class="form-label">Notes</label>
<textarea class="form-control" rows=3 name="notes" placeholder="Notes..." @cannot('admin',$o)disabled @endcannot>{{ old('notes',$o->notes) }}</textarea>
</div>
</div>
<div class="row">
<div class="col-12">
<a href="{{ url('ftn/zone') }}" class="btn btn-danger">Cancel</a>
@can('admin',$o)
<button type="submit" name="submit" class="btn btn-success mr-0 float-end">@if ($o->exists)Save @else Add @endif</button>
@endcan
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</form>
@endsection

View File

@@ -3,38 +3,68 @@
FTN Zones
@endsection
@section('main-content')
@section('content')
<div class="row">
<div class="col-12">
<h2>About FTN Zones</h2>
<p>In FTN network addresses, a zone is the 3rd dimension and used when a system supports 3D (or better) addressing, ie: <strong class="highlight">zone</strong>:hub/host.point@domain.</p>
<p>Zones are used with domains to uniquely identify a FTN network. Within an FTN network there can be multiple zones with the same domain.</p>
<p>It is rare that a domain has multiple zones - unless it grows quite large. Zones can also be used to group systems into a common boundary.</p>
</div>
</div>
<div class="row">
<div class="col-6">
<table class="table table-bordered m-5">
<thead>
<tr>
<th>ID</th>
<th>Active</th>
<th>Zone</th>
<th>Domain</th>
</tr>
</thead>
<p>This system is aware of the following zones in each domain:</p>
<tbody>
<tr>
<td colspan="4"><a href="{{ url('ftn/zone/addedit') }}">Add New Zone</a></td>
</tr>
@foreach (\App\Models\Zone::cursor() as $oo)
@if (\App\Models\Zone::count() == 0)
@can('admin',(new \App\Models\Zone))
<p>There are no zones setup, to <a href="{{ url('ftn/zone/addedit') }}">set up your first</a>.</p>
@else
<p class="pad">There are no zones - you need to ask an admin to create one for you.</p>
@endcan
@else
@can('admin',(new \App\Models\Domain))
<p>You can <a href="{{ url('ftn/zone/addedit') }}">Add New Zone</a>.</p>
@endcan
<table class="table monotable" id="zones">
<thead>
<tr>
<td><a href="{{ url('ftn/zone/addedit',[$oo->id]) }}">{{ $oo->zone_id }}</a></td>
<td>{{ $oo->active ? 'YES' : 'NO' }}</td>
<td>{{ $oo->name }}</td>
<td>{{ $oo->domain->name }}</td>
<th>Domain</th>
<th>Zone</th>
<th>Active</th>
<th>Systems</th>
</tr>
@endforeach
</tbody>
</table>
</thead>
<tbody>
@foreach (\App\Models\Zone::with(['domain'])->cursor() as $oo)
<tr>
<td>{{ $oo->domain->name }}</td>
<td><a href="{{ url('ftn/zone/addedit',[$oo->id]) }}">{{ $oo->zone_id }}</a></td>
<td>{{ $oo->active ? 'YES' : 'NO' }}</td>
<td>-</td>
</tr>
@endforeach
</tbody>
</table>
@endif
</div>
</div>
@endsection
@section('page-scripts')
{{--
<link href="https://cdn.datatables.net/1.10.25/css/jquery.dataTables.min.css" rel="stylesheet" media="screen" type="text/css">
<link href="https://cdn.datatables.net/rowgroup/1.1.2/css/rowGroup.dataTables.min.css" rel="stylesheet" media="screen" type="text/css">
--}}
<link href="https://cdn.datatables.net/1.10.25/css/dataTables.bootstrap5.min.css" rel="stylesheet" media="screen" type="text/css">
<link href="{{ asset('plugin/dataTables/dataTables.bootstrap5.css') }}" rel="stylesheet" media="screen" type="text/css">
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/rowgroup/1.1.2/js/dataTables.rowGroup.min.js"></script>
<script src="https://cdn.datatables.net/1.10.25/js/dataTables.bootstrap5.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('table tr').click(function() {
@@ -43,6 +73,20 @@
window.location = href;
}
});
$('#zones').DataTable({
paging: false,
searching: true,
rowGroup: {
dataSrc: [0],
},
columnDefs: [
{
targets: [0],
visible: false,
},
],
});
});
</script>
@append