More changes to use form.select component. Re-engineered user BBS registration
This commit is contained in:
parent
fd780d1756
commit
e7336a942b
@ -49,6 +49,9 @@ class SystemController extends Controller
|
||||
$o->autohold = FALSE;
|
||||
$o->save();
|
||||
|
||||
if ($o->wasRecentlyCreated)
|
||||
$o->users()->attach(Auth::id());
|
||||
|
||||
$mailers = collect($request->post('mailer_details'))
|
||||
->filter(function($item) { return $item['port']; })
|
||||
->transform(function($item) { $item['active'] = Arr::get($item,'active',FALSE); return $item; });
|
||||
@ -621,39 +624,19 @@ class SystemController extends Controller
|
||||
*/
|
||||
public function register(SystemRegisterRequest $request)
|
||||
{
|
||||
if ($request->action === 'register' && $request->name && is_numeric($request->name))
|
||||
return view('user.system.widget.register_confirm')
|
||||
->with('o',System::findOrFail($request->name));
|
||||
// During the BBS linking process, if the user selected a system will link to confirm it
|
||||
if ($request->action === 'register' && $request->system_id && is_numeric($request->system_id))
|
||||
return redirect()
|
||||
->to(sprintf('user/system/register_confirm/%d',$request->system_id));
|
||||
|
||||
$o = System::findOrNew(is_numeric($request->system_id) ? $request->system_id : NULL);
|
||||
// Re-flash our previously input data, we must be creating a new system
|
||||
session()->flashInput([
|
||||
'name'=>$request->system_id,
|
||||
'sysop'=>Auth::user()->name,
|
||||
]);
|
||||
|
||||
// If the system doesnt exist, we'll create it
|
||||
if (! $o->exist) {
|
||||
$o->sysop = Auth::user()->name;
|
||||
|
||||
foreach (['name','zt_id','location','phone','method','address','port'] as $item)
|
||||
if ($request->{$item})
|
||||
$o->{$item} = $request->{$item};
|
||||
|
||||
$o->active = TRUE;
|
||||
}
|
||||
|
||||
if ($request->post('submit')) {
|
||||
Auth::user()->systems()->save($o);
|
||||
|
||||
// @todo if the system already exists and part of one of our networks, we'll need to send the registration email to confirm the address.
|
||||
// @todo mark the system (or addresses) as "pending" at this stage until it is confirmed
|
||||
return redirect()->to(url('system/addedit',$o->id));
|
||||
}
|
||||
|
||||
// Re-flash our previously input data
|
||||
if ($request->old)
|
||||
session()->flashInput($request->old);
|
||||
|
||||
return view('system.widget.system')
|
||||
->with('action',$request->action)
|
||||
->with('o',$o)
|
||||
->with('errors',new ViewErrorBag);
|
||||
return redirect()
|
||||
->to('system/addedit');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,8 +56,11 @@ class SystemRegisterRequest extends FormRequest
|
||||
return [];
|
||||
|
||||
$so = $this->route('o');
|
||||
|
||||
// When we have selected a system during the register/linking process
|
||||
if ((! $so) && ($request->action === 'register'))
|
||||
return [];
|
||||
// If system ID is not numeric, then its a new system
|
||||
return is_numeric($request->system_id) ? ['system_id'=>'required|exists:systems,id'] : [];
|
||||
|
||||
return array_filter(array_merge([
|
||||
'name' => 'required|min:3',
|
||||
@ -68,14 +71,16 @@ class SystemRegisterRequest extends FormRequest
|
||||
'port' => 'nullable|digits_between:2,5',
|
||||
'method' => 'nullable|numeric',
|
||||
'mailer_details.*' => 'nullable|array',
|
||||
// @todo Port should be present if active is true
|
||||
'mailer_details.*.port' => 'nullable|digits_between:2,5',
|
||||
'mailer_details.*.active' => 'sometimes|boolean',
|
||||
'zt_id' => 'nullable|size:10|regex:/^([A-Fa-f0-9]){10}$/|unique:systems,zt_id,'.($so ? $so->id : 0),
|
||||
'pkt_type' => ['required',Rule::in(array_keys(Packet::PACKET_TYPES))],
|
||||
],($so && $so->exists) ? [
|
||||
'users' => 'nullable|array|min:1|max:2',
|
||||
'active' => 'required|boolean',
|
||||
'hold' => 'sometimes|boolean',
|
||||
'pollmode' => 'required|integer|min:0|max:2',
|
||||
],($so && $so->exists) ? [
|
||||
'users' => 'nullable|array|min:1|max:2',
|
||||
'heartbeat' => [
|
||||
'nullable',
|
||||
'integer',
|
||||
|
@ -25,6 +25,13 @@ class SystemPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
public function admin(User $user, System $system): bool
|
||||
{
|
||||
// Site Admins can always create
|
||||
// If it doesnt exist, then a user can create it.
|
||||
return ($user->isAdmin() || (! $system->exists));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the user can create the model.
|
||||
*
|
||||
@ -70,9 +77,9 @@ class SystemPolicy
|
||||
if ($user->isAdmin())
|
||||
return TRUE;
|
||||
|
||||
// If it doesnt exist, then its a false.
|
||||
// If it doesnt exist, then its a true (they are creating it).
|
||||
if (! $system->exists)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
|
||||
// @todo Permit ZC, RC, NC, HUB user
|
||||
|
||||
|
@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
use App\Events\Echomail as EchomailEvent;
|
||||
@ -18,7 +19,7 @@ use App\Helpers\PageAssets;
|
||||
use App\Listeners\EchomailListener;
|
||||
use App\Listeners\Matrix\MessageListener;
|
||||
use App\Notifications\Channels\{EchomailChannel,MatrixChannel,NetmailChannel};
|
||||
use App\Models\{Echomail,Netmail,User};
|
||||
use App\Models\{Echomail,Netmail,System,User};
|
||||
use App\Traits\Single;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@ -85,5 +86,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
// Custom Aliases
|
||||
$loader = AliasLoader::getInstance();
|
||||
$loader->alias('PageAssets',PageAssets::class);
|
||||
|
||||
Route::model('so',System::class);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<x-form.base {{ $attributes }}>
|
||||
<input type="hidden" id="{{ $name }}_disabled" name="{{ $name }}" value="" disabled>
|
||||
<select style="width: 80%" class="form-select @error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @required(isset($required)) @disabled(isset($disabled))>
|
||||
<select style="width: 80%" class="form-select @error((! empty($old)) ? $old : $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @required(isset($required)) @disabled(isset($disabled) && $disabled)>
|
||||
@if(empty($value) || isset($addnew) || isset($choose))
|
||||
<option value=""></option>
|
||||
@isset($addnew)
|
||||
|
@ -1,8 +1,8 @@
|
||||
<!-- $o = Setup::class -->
|
||||
@php
|
||||
use App\Models\Setup;
|
||||
use App\Classes\Protocol\{Binkp,EMSI,DNS};
|
||||
@endphp
|
||||
@use(App\Classes\Protocol\Binkp)
|
||||
@use(App\Classes\Protocol\EMSI)
|
||||
@use(App\Models\Setup)
|
||||
@use(App\Models\System)
|
||||
|
||||
@extends('layouts.app')
|
||||
@section('htmlheader_title')
|
||||
@ -23,30 +23,12 @@ use App\Classes\Protocol\{Binkp,EMSI,DNS};
|
||||
<div class="row">
|
||||
<!-- System -->
|
||||
<div class="col-4">
|
||||
<label for="system_id" class="form-label">System</label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="bi bi-tag-fill"></i></span>
|
||||
<select style="width: 80%;" class="form-select @error('system_id') is-invalid @enderror" id="system_id" name="system_id" required @cannot('admin',$o)disabled @endcannot>
|
||||
<option value=""> </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>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('system_id')
|
||||
{{ $message }}
|
||||
@else
|
||||
A system is required.
|
||||
@enderror
|
||||
</span>
|
||||
<span class="input-helper">
|
||||
@if(! $o->system_id)
|
||||
Add a <a href="{{ url('system/addedit') }}">NEW System</a>
|
||||
@else
|
||||
<a href="{{ url('system/addedit',[$o->system_id]) }}">Edit</a> System
|
||||
@endif
|
||||
</span>
|
||||
</div>
|
||||
@php
|
||||
$helper = (! $o->system_id)
|
||||
? sprintf('Add a <a href="%s">NEW System"</a>',url('system/addedit'))
|
||||
: sprintf('<a href="%s">Edit</a> System',url('system/addedit',[$o->system_id]));
|
||||
@endphp
|
||||
<x-form.select name="system_id" icon="bi-tag-fill" label="System" feedback="A system is required" placeholder="Select System" :helper="$helper" :required="true" :value="$o->system_id" :options="System::select(['id','name'])->active()->cursor()->map(fn($item,$key)=>['id'=>$item->id,'value'=>$item->name])" />
|
||||
</div>
|
||||
|
||||
<!-- System Addresses -->
|
||||
@ -301,23 +283,9 @@ use App\Classes\Protocol\{Binkp,EMSI,DNS};
|
||||
@endsection
|
||||
|
||||
@section('page-css')
|
||||
@css('select2')
|
||||
|
||||
<style>
|
||||
#content h3 {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
#content ul li:last-child {
|
||||
margin-bottom: inherit;
|
||||
}
|
||||
</style>
|
||||
@append
|
||||
@section('page-scripts')
|
||||
@js('select2')
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#system_id').select2();
|
||||
});
|
||||
</script>
|
||||
@append
|
@ -617,39 +617,47 @@
|
||||
@section('page-scripts')
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
@can('admin')
|
||||
$('.default').click(function () {
|
||||
var item = this;
|
||||
icon = $(item).find('i');
|
||||
if (window.location.hash) {
|
||||
$('#collapse_'+window.location.hash.substring(1)).show();
|
||||
$('#collapse_system').collapse()
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
data: {sid: {{$o->id}}, _token: '{{csrf_token()}}', set: (icon.hasClass('bi-square') ? 1 : 0)},
|
||||
beforeSend: function () {
|
||||
$(item).find('i').addClass('spinner-grow spinner-grow-sm');
|
||||
},
|
||||
success: function () {
|
||||
if (icon.hasClass('bi-square')) {
|
||||
icon.removeClass('bi-square');
|
||||
icon.addClass('bi-check-square');
|
||||
} else {
|
||||
icon.removeClass('bi-check-square');
|
||||
icon.addClass('bi-square');
|
||||
}
|
||||
@if($o->exists)
|
||||
@can('admin')
|
||||
$('.default').click(function () {
|
||||
var item = this;
|
||||
icon = $(item).find('i');
|
||||
|
||||
$(item).find('i').removeClass('spinner-grow spinner-grow-sm');
|
||||
},
|
||||
error: function (e) {
|
||||
$(item).find('i').removeClass('spinner-grow spinner-grow-sm');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
data: {sid: {{$o->id}}, _token: '{{csrf_token()}}', set: (icon.hasClass('bi-square') ? 1 : 0)},
|
||||
beforeSend: function () {
|
||||
$(item).find('i').addClass('spinner-grow spinner-grow-sm');
|
||||
},
|
||||
success: function () {
|
||||
if (icon.hasClass('bi-square')) {
|
||||
icon.removeClass('bi-square');
|
||||
icon.addClass('bi-check-square');
|
||||
} else {
|
||||
icon.removeClass('bi-check-square');
|
||||
icon.addClass('bi-square');
|
||||
}
|
||||
|
||||
$(item).find('i').removeClass('spinner-grow spinner-grow-sm');
|
||||
},
|
||||
error: function (e) {
|
||||
$(item).find('i').removeClass('spinner-grow spinner-grow-sm');
|
||||
|
||||
if (e.status != 412)
|
||||
alert('That didnt work? Please try again....');
|
||||
},
|
||||
url: '{{ url('zone/api/default') }}/' + item.attributes.itemid.nodeValue,
|
||||
cache: false
|
||||
})
|
||||
});
|
||||
@endcan
|
||||
@endif
|
||||
|
||||
if (e.status != 412)
|
||||
alert('That didnt work? Please try again....');
|
||||
},
|
||||
url: '{{ url('zone/api/default') }}/' + item.attributes.itemid.nodeValue,
|
||||
cache: false
|
||||
})
|
||||
});
|
||||
@endcan
|
||||
$('data.validated').on('click',function(item) {
|
||||
that = $(this);
|
||||
var values = item.delegateTarget.value.split(':');
|
||||
|
@ -1,3 +1,5 @@
|
||||
@use(App\Models\Zone)
|
||||
|
||||
<form class="needs-validation" method="post" action="{{ url('system/address/add',$o->id) }}" novalidate>
|
||||
@csrf
|
||||
<input type="hidden" id="action" name="action" value="">
|
||||
@ -8,70 +10,22 @@
|
||||
<div class="row">
|
||||
<!-- Select Zone -->
|
||||
<div class="col-3">
|
||||
<label for="zone_id" class="form-label">Zone</label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="bi bi-hash"></i></span>
|
||||
<select class="form-select @error('zone_id') is-invalid @enderror" id="zone_id" name="zone_id" required>
|
||||
<option></option>
|
||||
@foreach(\App\Models\Zone::active()->domainZoneOrder()->with(['domain'])->get() as $zo)
|
||||
<option value="{{ $zo->id }}">{{ $zo->zone_id }} <small>({{ $zo->domain->name }})</small></option>
|
||||
@endforeach
|
||||
</select>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('zone_id')
|
||||
{{ $message }}
|
||||
@else
|
||||
Please select the Zone for the node's address.
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
<x-form.select name="zone_id" icon="bi-hash" label="Zone" :options="Zone::select(['id','zone_id','domain_id'])->active()->domainZoneOrder()->with(['domain'])->get()->map(fn($item,$key)=>['id'=>$item->id,'value'=>sprintf('%d [%s]',$item->zone_id,$item->domain->name)])" required="true" />
|
||||
</div>
|
||||
|
||||
<!-- Select Region -->
|
||||
<div class="col-3 d-none" id="region-select">
|
||||
<label for="region_id" class="form-label">Region</label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="bi bi-geo"></i></span>
|
||||
<select class="form-select @error('region_id') is-invalid @enderror" id="region_id" name="region_id" required>
|
||||
</select>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('region_id')
|
||||
{{ $message }}
|
||||
@else
|
||||
Please make a choice.
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
<x-form.select name="region_id" icon="bi-geo" label="Region" :required="true" />
|
||||
</div>
|
||||
|
||||
<!-- Select Host -->
|
||||
<div class="col-3 d-none" id="host-select">
|
||||
<label for="host_id" class="form-label">Host</label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="bi bi-diagram-3-fill"></i></span>
|
||||
<select class="form-select @error('host_id') is-invalid @enderror" id="host_id" name="host_id">
|
||||
</select>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('host_id')
|
||||
{{ $message }}
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
<x-form.select name="host_id" icon="bi-diagram-3-fill" label="Host" />
|
||||
</div>
|
||||
|
||||
<!-- Select Hub -->
|
||||
<div class="col-3 d-none" id="hub-select">
|
||||
<label for="hub_id" class="form-label">Hub</label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="bi bi-diagram-2-fill"></i></span>
|
||||
<select class="form-select @error('hub_id') is-invalid @enderror" id="hub_id" name="hub_id">
|
||||
</select>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('hub_id')
|
||||
{{ $message }}
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
<x-form.select name="hub_id" icon="bi-diagram-2-fill" label="Hub" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -81,9 +35,9 @@
|
||||
<label for="node_id" class="form-label">Node/Point Address</label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="bi bi-hash"></i></span>
|
||||
<input type="text" style="width: 35%;" class="form-control text-end @error('node_id') is-invalid @enderror" id="node_id" placeholder="Node" name="node_id" value="{{ old('node_id',$o->node_id) }}" @cannot('admin',$o)disabled @endcannot>
|
||||
<input type="text" style="width: 35%;" class="form-control text-end @error('node_id') is-invalid @enderror" id="node_id" placeholder="Node" name="node_id" value="{{ old('node_id',$o->node_id) }}" @cannot('admin',$o)disabled @endcannot data-1p-ignore>
|
||||
<span class="input-group-text p-0">.</span>
|
||||
<input type="text" class="form-control @error('point_id') is-invalid @enderror" id="point_id" placeholder="0" name="point_id" value="{{ old('point_id',$o->point_id) ?: 0 }}" @cannot('admin',$o)disabled @endcannot style="padding-left: 0;">
|
||||
<input type="text" class="form-control pl-0 @error('point_id') is-invalid @enderror" id="point_id" placeholder="0" name="point_id" value="{{ old('point_id',$o->point_id) ?: 0 }}" @cannot('admin',$o)disabled @endcannot>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('node_id')
|
||||
{{ $message }}
|
||||
@ -100,7 +54,7 @@
|
||||
<label for="region_id_new" class="form-label">Region Address</label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="bi bi-hash"></i></span>
|
||||
<input type="text" style="width: 35%;" class="form-control @error('region_id_new') is-invalid @enderror" id="region_id_new" placeholder="Region #" name="region_id_new" value="{{ old('region_id_new') }}" @cannot('admin',$o)disabled @endcannot>
|
||||
<input type="text" style="width: 35%;" class="form-control @error('region_id_new') is-invalid @enderror" id="region_id_new" placeholder="Region #" name="region_id_new" value="{{ old('region_id_new') }}" @cannot('admin',$o)disabled @endcannot data-1p-ignore>
|
||||
<span class="input-group-text">/0.0</span>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('region_id_new')
|
||||
@ -117,7 +71,7 @@
|
||||
<label for="host_id_new" class="form-label">Host Address</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 text-end @error('host_id_new') is-invalid @enderror" id="host_id_new" placeholder="Host #" name="host_id_new" value="{{ old('host_id_new') }}" @cannot('admin',$o)disabled @endcannot>
|
||||
<input type="text" class="form-control text-end @error('host_id_new') is-invalid @enderror" id="host_id_new" placeholder="Host #" name="host_id_new" value="{{ old('host_id_new') }}" @cannot('admin',$o)disabled @endcannot data-1p-ignore>
|
||||
<span class="input-group-text">/0.0</span>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('host_id_new')
|
||||
@ -246,6 +200,9 @@
|
||||
if (! $('#sec-level').hasClass('d-none'))
|
||||
$('#sec-level').addClass('d-none')
|
||||
|
||||
if (! this.value)
|
||||
return false;
|
||||
|
||||
var icon = $(this).parent().find('i');
|
||||
icon.addClass('spinner-grow spinner-grow-sm');
|
||||
|
||||
|
@ -1,13 +1,15 @@
|
||||
<!-- $o=System::class -->
|
||||
@use(Carbon\Carbon)
|
||||
@use(Carbon\CarbonInterface)
|
||||
@use(Illuminate\Support\Facades\Gate)
|
||||
@use(App\Classes\FTN\Packet)
|
||||
@use(App\Models\Mailer)
|
||||
@use(App\Models\User)
|
||||
<!-- $o=System::class -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-9 col-12">
|
||||
@can('admin',$o)
|
||||
<div class="row pt-0">
|
||||
<div class="row pt-0">
|
||||
@can('admin')
|
||||
<div class="col-12">
|
||||
<h4 class="mb-0 pb-2">System Users</h4>
|
||||
|
||||
@ -19,7 +21,7 @@
|
||||
<span class="input-group-text"><i class="bi bi-people-fill"></i></span>
|
||||
<select style="width: 80%;" class="form-select @error('users') is-invalid @enderror" id="users" name="users[]">
|
||||
<option value=""> </option>
|
||||
@foreach (User::orderBy('name')->active()->get() as $uo)
|
||||
@foreach (User::select(['id','name','email'])->orderBy('name')->active()->get() as $uo)
|
||||
<option value="{{ $uo->id }}" @selected(in_array($uo->id,old('users',$o->users->pluck('id')->toArray())))>{{ $uo->name }} <small>({{ $uo->email }})</small></option>
|
||||
@endforeach
|
||||
</select>
|
||||
@ -33,10 +35,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endcan
|
||||
@endcan
|
||||
</div>
|
||||
|
||||
<div class="row pt-4">
|
||||
<div class="row @can('admin')pt-4 @else pt-0 @endcannot">
|
||||
<div class="col-12">
|
||||
<h4 class="mb-0 pb-2">System Details</h4>
|
||||
|
||||
@ -46,9 +48,7 @@
|
||||
<label for="name" class="form-label">BBS Name</label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="bi bi-pc"></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($action,$o)readonly @endcannot autofocus>
|
||||
<span id="search-icon" style="width: 0;"><i style="border-radius: 50%;" class="spinner-border spinner-border-sm text-dark d-none"></i></span>
|
||||
<div id="system_search_results"></div>
|
||||
<input type="text" class="form-control @error('name') is-invalid @enderror" id="name" placeholder="Name" name="name" value="{{ old('name',$o->name) }}" required @cannot($action,$o)readonly @endcannot autofocus autocomplete="off" data-1p-ignore>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('name')
|
||||
{{ $message }}
|
||||
@ -116,7 +116,7 @@
|
||||
<label for="address" class="form-label">Mailer Internet Hostname</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>
|
||||
<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 data-1p-ignore>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('address')
|
||||
{{ $message }}
|
||||
@ -174,20 +174,7 @@
|
||||
|
||||
<!-- Mail Packet -->
|
||||
<div class="col-4">
|
||||
<label for="pkt_type" class="form-label">Mail Packet</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="bi bi-ui-radios"></i></span>
|
||||
<select class="form-select @error('pkt_type') is-invalid @enderror" id="pkt_type" name="pkt_type" @cannot($action,$o)disabled @endcannot>
|
||||
@foreach (Packet::PACKET_TYPES as $type => $class)
|
||||
<option value="{{ $type }}" @if(old('pkt_type',$o->pkt_type ?: config('fido.packet_default')) === $type)selected @endif>{{ $type }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('pkt_type')
|
||||
{{ $message }}
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
<x-form.select name="pkt_type" icon="bi-ui-radios" label="Mail Packet" feedback="Set a packet type" :value="$o->pkt_type ?: config('fido.packet_default')" :options="collect(Packet::PACKET_TYPES)->map(fn($item,$key)=>['id'=>$key,'value'=>$key])" required="true" :disabled="Gate::denies('update_nn',$o)"/>
|
||||
</div>
|
||||
|
||||
<!-- Packet Msgs -->
|
||||
@ -214,17 +201,9 @@
|
||||
|
||||
<div class="row pt-0">
|
||||
<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($action,$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>
|
||||
<x-form.select name="method" icon="bi-wifi" label="Connection Method" :value="$o->method" :options="collect([['id'=>23,'value'=>'Telnet'],['id'=>22,'value'=>'SSH'],['id'=>519,'value'=>'Rlogin']])" :disabled="Gate::denies('update_nn',$o)"/>
|
||||
</div>
|
||||
|
||||
<div class="col-3">
|
||||
<label for="method" class="form-label">Port</label>
|
||||
<div class="input-group">
|
||||
@ -303,28 +282,30 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="row p-0">
|
||||
@can('update_nn',$o)
|
||||
<div class="col-6">
|
||||
<label for="autohold" class="form-label">Auto Hold</label>
|
||||
<div class="input-group">
|
||||
<button id="autohold" @class(['btn','btn-warning'=>$o->autohold,'btn-outline-success'=>(! $o->autohold)])><i @class(['bi-toggle-on'=>$o->autohold,'bi-toggle-off'=>(! $o->autohold)])></i></button>
|
||||
@if($o->exists)
|
||||
@can('update_nn',$o)
|
||||
<div class="col-6">
|
||||
<label for="autohold" class="form-label">Auto Hold</label>
|
||||
<div class="input-group">
|
||||
<button id="autohold" @class(['btn','btn-warning'=>$o->autohold,'btn-outline-success'=>(! $o->autohold)])><i @class(['bi-toggle-on'=>$o->autohold,'bi-toggle-off'=>(! $o->autohold)])></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- @todo This is only relevant for uplinks, so hide it if this system isnt an uplink -->
|
||||
<div class="col-6 @if((old('pollmode') === "0") || is_null($o->pollmode))d-none @endif" id="heartbeat_option">
|
||||
<label for="heartbeat" class="form-label">Heartbeat <i class="bi bi-info-circle" title="Attempt contact after last seen"></i></label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="bi bi-hourglass-bottom"></i></span>
|
||||
<input type="text" class="form-control text-end @error('heartbeat') is-invalid @enderror" id="heartbeat" placeholder="Hrs" name="heartbeat" value="{{ old('heartbeat',$o->heartbeat) }}">
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('heartbeat')
|
||||
{{ $message }}
|
||||
@enderror
|
||||
</span>
|
||||
<!-- @todo This is only relevant for uplinks, so hide it if this system isnt an uplink -->
|
||||
<div class="col-6 @if((old('pollmode') === "0") || is_null($o->pollmode))d-none @endif" id="heartbeat_option">
|
||||
<label for="heartbeat" class="form-label">Heartbeat <i class="bi bi-info-circle" title="Attempt contact after last seen"></i></label>
|
||||
<div class="input-group has-validation">
|
||||
<span class="input-group-text"><i class="bi bi-hourglass-bottom"></i></span>
|
||||
<input type="text" class="form-control text-end @error('heartbeat') is-invalid @enderror" id="heartbeat" placeholder="Hrs" name="heartbeat" value="{{ old('heartbeat',$o->heartbeat) }}">
|
||||
<span class="invalid-feedback" role="alert">
|
||||
@error('heartbeat')
|
||||
{{ $message }}
|
||||
@enderror
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endcan
|
||||
@endcan
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@if(! is_null($o->pollmode))
|
||||
@ -418,7 +399,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@can('admin',$o)
|
||||
@can('admin')
|
||||
<div class="row">
|
||||
<!-- Notes -->
|
||||
<div class="col-12">
|
||||
@ -444,15 +425,15 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section('page-css')
|
||||
@css('select2')
|
||||
@append
|
||||
@section('page-scripts')
|
||||
@js('select2')
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('#users').select2({
|
||||
theme: 'bootstrap-5',
|
||||
dropdownAutoWidth: true,
|
||||
width: 'style',
|
||||
allowClear: true,
|
||||
placeholder: '',
|
||||
@cannot('admin')disabled: true @endcannot
|
||||
/*multiple: true*/
|
||||
});
|
||||
@ -466,57 +447,59 @@
|
||||
$('#poll_hold').on('click',function() {
|
||||
$('#heartbeat_option').addClass('d-none');
|
||||
})
|
||||
$("#autohold").on('click',function(item) {
|
||||
var that = $(this)
|
||||
var icon = that.find('i');
|
||||
@if($o->exists)
|
||||
$("#autohold").on('click',function(item) {
|
||||
var that = $(this)
|
||||
var icon = that.find('i');
|
||||
|
||||
if (icon.hasClass('bi-toggle-on')) {
|
||||
$.ajax({
|
||||
url: '/system/api/autohold/off',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data : {id: {{ $o->id }}},
|
||||
beforeSend: function() {
|
||||
icon.addClass('spinner-grow spinner-grow-sm')
|
||||
},
|
||||
complete: function() {
|
||||
icon.removeClass('spinner-grow spinner-grow-sm')
|
||||
},
|
||||
success: function(data) {
|
||||
icon.removeClass('bi-toggle-on')
|
||||
.addClass('bi-toggle-off')
|
||||
if (icon.hasClass('bi-toggle-on')) {
|
||||
$.ajax({
|
||||
url: '/system/api/autohold/off',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data : {id: {{ $o->id }}},
|
||||
beforeSend: function() {
|
||||
icon.addClass('spinner-grow spinner-grow-sm')
|
||||
},
|
||||
complete: function() {
|
||||
icon.removeClass('spinner-grow spinner-grow-sm')
|
||||
},
|
||||
success: function(data) {
|
||||
icon.removeClass('bi-toggle-on')
|
||||
.addClass('bi-toggle-off')
|
||||
|
||||
that.removeClass('btn-warning')
|
||||
.addClass('btn-outline-success')
|
||||
},
|
||||
cache: false
|
||||
});
|
||||
that.removeClass('btn-warning')
|
||||
.addClass('btn-outline-success')
|
||||
},
|
||||
cache: false
|
||||
});
|
||||
|
||||
} else {
|
||||
$.ajax({
|
||||
url: '/system/api/autohold/on',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data : {id: {{ $o->id }}},
|
||||
beforeSend: function() {
|
||||
icon.addClass('spinner-grow spinner-grow-sm')
|
||||
},
|
||||
complete: function() {
|
||||
icon.removeClass('spinner-grow spinner-grow-sm')
|
||||
},
|
||||
success: function(data) {
|
||||
icon.removeClass('bi-toggle-off')
|
||||
.addClass('bi-toggle-on');
|
||||
} else {
|
||||
$.ajax({
|
||||
url: '/system/api/autohold/on',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data : {id: {{ $o->id }}},
|
||||
beforeSend: function() {
|
||||
icon.addClass('spinner-grow spinner-grow-sm')
|
||||
},
|
||||
complete: function() {
|
||||
icon.removeClass('spinner-grow spinner-grow-sm')
|
||||
},
|
||||
success: function(data) {
|
||||
icon.removeClass('bi-toggle-off')
|
||||
.addClass('bi-toggle-on');
|
||||
|
||||
that.removeClass('btn-outline-success')
|
||||
.addClass('btn-warning')
|
||||
},
|
||||
cache: false
|
||||
});
|
||||
}
|
||||
that.removeClass('btn-outline-success')
|
||||
.addClass('btn-warning')
|
||||
},
|
||||
cache: false
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
return false;
|
||||
})
|
||||
@endif
|
||||
})
|
||||
</script>
|
||||
@append
|
@ -1,16 +1,15 @@
|
||||
@use(App\Models\System)
|
||||
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('htmlheader_title')
|
||||
Register System
|
||||
@endsection
|
||||
|
||||
@php
|
||||
use App\Models\System;
|
||||
@endphp
|
||||
|
||||
@section('content')
|
||||
<form class="needs-validation" method="post" autocomplete="off" novalidate>
|
||||
<form method="POST" autocomplete="off">
|
||||
@csrf
|
||||
<input type="hidden" name="action" value="register">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@ -27,13 +26,13 @@ use App\Models\System;
|
||||
->whereRaw('id NOT IN (SELECT system_id FROM "system_user")')
|
||||
->cursor())
|
||||
|
||||
<x-form.select id="system" name="id" icon="bi-laptop-fill" label="BBS Name" placeholder="See if your BBS exists, otherwise add it" feedback="BBS Name is required" helper="Enter your BBS name and press NEXT" :addvalues="true" :options="$options->map(fn($item,$key)=>['id'=>$item->id,'value'=>$item->name])" />
|
||||
<x-form.select name="system_id" icon="bi-laptop-fill" label="BBS Name" placeholder="See if your BBS exists, otherwise add it" feedback="BBS Name is required" helper="Enter your BBS name and press NEXT" :addvalues="true" :options="$options->map(fn($item,$key)=>['id'=>$item->id,'value'=>$item->name])" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 pb-2">
|
||||
<button type="button" name="submit" class="btn btn-success">Next</button><span id="next" class="m-2"><i class="spinner-border spinner-border-sm text-light d-none"></i></span>
|
||||
<button type="submit" class="btn btn-success">Next</button><span id="next" class="m-2"><i class="spinner-border spinner-border-sm text-light d-none"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -41,104 +40,4 @@ use App\Models\System;
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="modal fade" id="no-auth" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-danger">
|
||||
<h5 class="modal-title">ERROR: No authorisation</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>It appears that you are not allowed to create this entry.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('page-scripts')
|
||||
<script type='text/javascript'>
|
||||
var system_id;
|
||||
var noauth = new bootstrap.Modal(document.getElementById('no-auth'), {});
|
||||
|
||||
function validation(item,message) {
|
||||
var attr = $('input[id='+item+']');
|
||||
attr.addClass('is-invalid')
|
||||
attr.parent().find('.invalid-feedback').empty().append(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* We have selected a BBS from the link/register form, and it's either a new entry or an existing one
|
||||
* @param icon
|
||||
*/
|
||||
function getform(icon) {
|
||||
$.ajax({
|
||||
url : '{{ url('user/system/register') }}',
|
||||
type : 'POST',
|
||||
data : { system_id: system_id,name: $('#system').val(),action: 'register',old: {!! json_encode(old()) !!} },
|
||||
dataType : 'json',
|
||||
async : true,
|
||||
cache : false,
|
||||
beforeSend : function() {
|
||||
if (icon)
|
||||
icon.toggleClass('d-none');
|
||||
},
|
||||
complete : function(data) {
|
||||
switch (data.status) {
|
||||
case 200:
|
||||
// if json is null, means no match, won't do again.
|
||||
if(data.responseText===null || (data.responseText.length===0)) return;
|
||||
$('#create').empty().append(data.responseText);
|
||||
|
||||
@if($errors->count())
|
||||
@foreach($errors->keys() as $key)
|
||||
validation('{{ $key }}','{{ $errors->first($key) }}');
|
||||
@endforeach
|
||||
@endif
|
||||
|
||||
break;
|
||||
|
||||
case 403:
|
||||
if (icon)
|
||||
icon.toggleClass('d-none');
|
||||
noauth.show();
|
||||
break;
|
||||
|
||||
case 419:
|
||||
location.reload();
|
||||
break;
|
||||
|
||||
case 422:
|
||||
validation('name',data.responseJSON.errors.name[0]);
|
||||
|
||||
if (icon)
|
||||
icon.toggleClass('d-none');
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if ({{ old('submit') === 'create' ? 'true' : 'false' }}) {
|
||||
getform();
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('button[name=submit]').on('click',function() {
|
||||
icon = $(this).parent().find('i');
|
||||
|
||||
if (! $('#system').val())
|
||||
return;
|
||||
|
||||
getform(icon);
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@append
|
57
resources/views/user/system/register_confirm.blade.php
Normal file
57
resources/views/user/system/register_confirm.blade.php
Normal file
@ -0,0 +1,57 @@
|
||||
<!-- $so=System::class -->
|
||||
@use(App\Models\System)
|
||||
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('htmlheader_title')
|
||||
Register System
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
@if(! $so->address)
|
||||
<h3 class="pt-2">Enable to complete registration</h3>
|
||||
|
||||
<p>The system you selected <strong class="highlight">{{ $so->name }}</strong> doesnt have mailer details, please contact that system administration to update those details first</p>
|
||||
@else
|
||||
<h3 class="pt-2">System Details:</h3>
|
||||
<table class="monotable">
|
||||
<tr>
|
||||
<th>System</th>
|
||||
<th>{{ $so->name }}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Sysop</th>
|
||||
<th>{{ $so->sysop }}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Location</th>
|
||||
<th>{{ $so->location }}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Networks</th>
|
||||
<th>{{ $so->akas->pluck('ftn')->join(', ') }}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Address</th>
|
||||
<th>{{ $so->access_mailer }}</th>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>If the details are above are not correct, then please contact the (ZC) to have them corrected first.</p>
|
||||
|
||||
<p>Otherwise, if all is good, we'll send a netmail to <strong class="highlight">{{ $so->sysop }}</strong> at <strong class="highlight">{{ $so->access_mailer }}</strong></p> with further details.
|
||||
|
||||
<form class="needs-validation" method="post" autocomplete="off" action="{{ url('user/system/link') }}" novalidate>
|
||||
@csrf
|
||||
|
||||
<input type="hidden" name="system_id" value="{{ $so->id }}">
|
||||
<input type="hidden" name="name" value="{{ $so->name }}">
|
||||
|
||||
<div class="row pb-2">
|
||||
<div class="col-12">
|
||||
<input type="submit" name="action" class="btn btn-success" value="Link">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@endif
|
||||
@endsection
|
@ -1,41 +0,0 @@
|
||||
<!-- $o = System::class -->
|
||||
<h3>System Details:</h3>
|
||||
<table class="monotable">
|
||||
<tr>
|
||||
<th>System</th>
|
||||
<th>{{ $o->name }}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Sysop</th>
|
||||
<th>{{ $o->sysop }}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Location</th>
|
||||
<th>{{ $o->location }}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Networks</th>
|
||||
<th>{{ $o->akas->pluck('ftn')->join(', ') }}</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Address</th>
|
||||
<th>{{ $o->access_mailer }}</th>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>If the details are above are not correct, then please contact the (ZC) to have them corrected first.</p>
|
||||
|
||||
<p>Otherwise, if all is good, we'll send a netmail to <strong class="highlight">{{ $o->sysop }}</strong> at <strong class="highlight">{{ $o->access_mailer }}</strong></p> with further details.
|
||||
|
||||
<form class="needs-validation" method="post" autocomplete="off" action="{{ url('user/system/link') }}" novalidate>
|
||||
@csrf
|
||||
|
||||
<input type="hidden" name="system_id" value="{{ $o->id }}">
|
||||
<input type="hidden" name="name" value="{{ $o->name }}">
|
||||
|
||||
<div class="row pb-2">
|
||||
<div class="col-12">
|
||||
<input type="submit" name="action" class="btn btn-success" value="Link">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
@ -135,7 +135,9 @@ Route::middleware(['auth','verified','activeuser'])->group(function () {
|
||||
|
||||
Route::view('user/system/register','user.system.register');
|
||||
Route::post('user/system/register',[SystemController::class,'register']);
|
||||
Route::match(['post'],'user/system/link',[SystemController::class,'system_link']);
|
||||
Route::view('user/system/register_confirm/{so}','user.system.register_confirm')
|
||||
->where('so','[0-9]+');
|
||||
Route::post('user/system/link',[SystemController::class,'system_link']);
|
||||
|
||||
/* ZONE PATHS */
|
||||
Route::view('zone','zone.home');
|
||||
|
Loading…
Reference in New Issue
Block a user