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

@ -19,11 +19,13 @@ class DomainController extends Controller
public function add_edit(Request $request,Domain $o)
{
if ($request->post()) {
$this->authorize('admin',$o);
$request->validate([
'name' => 'required|max:8|unique:domains,name,'.($o->exists ? $o->id : 0),
'dnsdomain' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i|unique:domains,dnsdomain,'.($o->exists ? $o->id : NULL),
'active' => 'required',
'public' => 'required',
'active' => 'required|boolean',
'public' => 'required|boolean',
]);
foreach (['name','dnsdomain','active','public','homepage','notes'] as $key)

View File

@ -19,12 +19,15 @@ class SystemController extends Controller
public function add_edit(Request $request,System $o)
{
if ($request->post()) {
$this->authorize('admin',$o);
$request->validate([
'name' => 'required|min:3|unique:systems,name,'.($o->exists ? $o->id : 0),
'location' => 'required|min:3',
'sysop' => 'required|min:3',
'address' => 'nullable|regex:/^(?!:\/\/)(?=.{1,255}$)((.{1,63}\.){1,127}(?![0-9]*$)[a-z0-9-]+\.?)$/i',
'port' => 'nullable|digits_between:2,5',
'active' => 'required|boolean',
]);
foreach (['name','location','sysop','address','port','active','method','notes'] as $key)

View File

@ -19,6 +19,8 @@ class UserController extends Controller
public function add_edit(Request $request,User $o)
{
if ($request->post()) {
$this->authorize('admin',$o);
$request->validate([
'email' => 'required|email|unique:users,email,'.($o ? $o->id : NULL),
]);

View File

@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use App\Models\Zone;
@ -19,10 +20,28 @@ class ZoneController extends Controller
public function add_edit(Request $request,Zone $o)
{
if ($request->post()) {
foreach (['zone_id','name','active','description','notes','domain_id'] as $key)
$this->authorize('admin',$o);
$request->validate([
'domain_id' => 'required|exists:domains,id',
'zone_id' => [
'required',
'digits_between:1,5',
Rule::unique('zones')->where(function ($query) use ($request,$o) {
return $query->where('domain_id',$request->post('domain_id'))
->when($o->exists,function($query) use ($o) {
return $query->where('id','<>',$o->id);
});
})
],
'system_id' => 'required|exists:systems,id',
'ztid' => 'nullable|size:10|regex:/^([A-Fa-f0-9]){10}$/',
'active' => 'required|boolean',
]);
foreach (['zone_id','domain_id','system_id','active','notes','ztid'] as $key)
$o->{$key} = $request->post($key);
$o->active = TRUE;
$o->save();
return redirect()->action([self::class,'home']);

View File

@ -0,0 +1,51 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateZones extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
DB::statement('ALTER TABLE zones ALTER COLUMN domain_id SET NOT NULL');
Schema::table('zones', function (Blueprint $table) {
$table->dropColumn(['name','description','ipv4','ipv4_mask','ipv6','ipv6_mask','zt_id']);
$table->string('ztid')->nullable();
$table->dropUnique(['domain_id']);
$table->integer('system_id');
$table->foreign('system_id')->references('id')->on('systems');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
DB::statement('ALTER TABLE zones ALTER COLUMN domain_id DROP NOT NULL');
Schema::table('zones', function (Blueprint $table) {
$table->dropForeign(['system_id']);
$table->dropColumn(['system_id','ztid']);
$table->unique('domain_id');
$table->string('name');
$table->string('description');
$table->ipAddress('ipv4')->nullable();
$table->integer('ipv4_mask')->nullable();
$table->ipAddress('ipv6')->nullable();
$table->integer('ipv6_mask')->nullable();
$table->binary('zt_id')->nullable()->unique();
});
}
}

View File

@ -49,6 +49,13 @@ a.disabled {
text-transform:uppercase
}
.input-helper {
display: block;
margin-top: .25rem;
font-size: .875em;
width: 100%;
}
strong.highlight {
color: #eee;
}
@ -234,9 +241,6 @@ ul#navlist-desktop {
box-sizing:border-box;
overflow:hidden
}
#content * {
vertical-align:top
}
#content a.anchor {
display:block;
position:relative;

View File

@ -0,0 +1,35 @@
table.dataTable {
border-collapse: collapse !important;
}
div.dataTables_wrapper div.dataTables_filter {
text-align: right;
color: #eeeeee;
padding-bottom: 20px;
}
div.dataTables_wrapper div.dataTables_filter input {
margin-left: 0.5em;
display: inline;
background-color: #000;
color: #eeeeee;
}
div.dataTables_wrapper div.dataTables_info {
padding-top: 0.85em;
white-space: nowrap;
font-size: 75%;
color: #eeeeee;
}
table.dataTable thead .sorting:before,
table.dataTable thead .sorting_asc:before,
table.dataTable thead .sorting_desc:before,
table.dataTable thead .sorting_asc_disabled:before,
table.dataTable thead .sorting_desc_disabled:before,
table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:after,
table.dataTable thead .sorting_asc_disabled:after,
table.dataTable thead .sorting_desc_disabled:after {
color: #eeeeee;
}

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')
<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
</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>
@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')
@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>
@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>
<form method="POST">
{{ csrf_field() }}
@section('content')
<form class="row g-0 needs-validation" method="post" novalidate>
@csrf
<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 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-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="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">
<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($o->domain_id==$oo->id)selected @endif>{{ $oo->name }}</option>
<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">
<label class="col-3" for="description">Description:</label>
<input class="col-9" type="text" name="description" value="{{ $o->description }}">
<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="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="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>
<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>
<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 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="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 m-3">
<div class="row">
<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>
<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>
</div>
</form>
</div>
@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">
<p>This system is aware of the following zones in each domain:</p>
@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>
<th>ID</th>
<th>Active</th>
<th>Zone</th>
<th>Domain</th>
<th>Zone</th>
<th>Active</th>
<th>Systems</th>
</tr>
</thead>
<tbody>
@foreach (\App\Models\Zone::with(['domain'])->cursor() as $oo)
<tr>
<td colspan="4"><a href="{{ url('ftn/zone/addedit') }}">Add New Zone</a></td>
</tr>
@foreach (\App\Models\Zone::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>{{ $oo->name }}</td>
<td>{{ $oo->domain->name }}</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