Fixes for saving a new system
This commit is contained in:
parent
434226f8bc
commit
27cdb02b06
@ -45,6 +45,7 @@ class SystemController extends Controller
|
|||||||
default: $o->pollmode = NULL;
|
default: $o->pollmode = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$o->active = (! is_null($x=$request->validated('active'))) && $x;
|
||||||
$o->autohold = FALSE;
|
$o->autohold = FALSE;
|
||||||
$o->save();
|
$o->save();
|
||||||
|
|
||||||
@ -60,7 +61,9 @@ class SystemController extends Controller
|
|||||||
$o->users()->detach();
|
$o->users()->detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->to('system');
|
return redirect()
|
||||||
|
->to('system/addedit/'.$o->id)
|
||||||
|
->with('saved',TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
$o->load(['addresses.zone.domain','addresses.nodes_hub','addresses.system','sessions.domain','sessions.systems']);
|
$o->load(['addresses.zone.domain','addresses.nodes_hub','addresses.system','sessions.domain','sessions.systems']);
|
||||||
|
@ -8,7 +8,6 @@ use Illuminate\Support\Facades\Gate;
|
|||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
use App\Classes\FTN\Packet;
|
use App\Classes\FTN\Packet;
|
||||||
use App\Models\Setup;
|
|
||||||
|
|
||||||
class SystemRegisterRequest extends FormRequest
|
class SystemRegisterRequest extends FormRequest
|
||||||
{
|
{
|
||||||
@ -19,12 +18,10 @@ class SystemRegisterRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function authorize(Request $request)
|
public function authorize(Request $request)
|
||||||
{
|
{
|
||||||
if (! $request->post())
|
if (! $request->post() || (! $this->route('o')))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
// Cannot claim this site
|
// @todo Also disallow claiming this hosts system
|
||||||
if ($this->route('o')->id === Setup::findOrFail(config('app.id'))->system_id)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return Gate::allows($this->route('o')->users->count() ? 'update_nn' : 'register',$this->route('o'));
|
return Gate::allows($this->route('o')->users->count() ? 'update_nn' : 'register',$this->route('o'));
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ use App\Models\Address;
|
|||||||
<h1>
|
<h1>
|
||||||
{{ $o->name }}@if($o->setup)<sup class="success">*</sup>@endif
|
{{ $o->name }}@if($o->setup)<sup class="success">*</sup>@endif
|
||||||
@if($o->setup)<small class="success float-end">* This Host</small>@endif
|
@if($o->setup)<small class="success float-end">* This Host</small>@endif
|
||||||
|
<span style="top: 0.25em;position: relative;">@includeWhen(session()->has('saved'),'widgets.saved')</span>
|
||||||
</h1>
|
</h1>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
Systems
|
Systems
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@php
|
||||||
|
use App\Models\System;
|
||||||
|
@endphp
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@ -14,12 +18,12 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<p>This system is aware of the following systems
|
<p>This system is aware of the following systems
|
||||||
@can('create',(new \App\Models\System))(you can <a href="{{ url('user/system/register') }}">register</a> more):@endcan
|
@can('create',(new System))(you can <a href="{{ url('user/system/register') }}">register</a> more):@endcan
|
||||||
@can('admin',(new \App\Models\System))(you can <a href="{{ url('system/addedit') }}">add</a> more):@endcan
|
@can('admin',(new System))(you can <a href="{{ url('system/addedit') }}">add</a> more):@endcan
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@if (\App\Models\System::active()->count() === 0)
|
@if (System::active()->count() === 0)
|
||||||
@can('create',(new \App\Models\System))
|
@can('create',(new System))
|
||||||
<p>There are no systems setup, to <a href="{{ url('system/addedit') }}">set up your first</a>.</p>
|
<p>There are no systems setup, to <a href="{{ url('system/addedit') }}">set up your first</a>.</p>
|
||||||
@else
|
@else
|
||||||
<p class="pad">There are no systems - you need to ask an admin to create one for you.</p>
|
<p class="pad">There are no systems - you need to ask an admin to create one for you.</p>
|
||||||
@ -40,7 +44,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (\App\Models\System::active()->with(['addresses.zone.domain'])->get() as $oo)
|
@foreach (System::active()->with(['addresses.zone.domain'])->get() as $oo)
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ url('system/addedit',[$oo->id]) }}" @cannot('update_nn',$oo)class="disabled" @endcannot>{{ $oo->id }}</a></td>
|
<td><a href="{{ url('system/addedit',[$oo->id]) }}" @cannot('update_nn',$oo)class="disabled" @endcannot>{{ $oo->id }}</a></td>
|
||||||
<td>{{ $oo->name }} @if(! $oo->active)<span class="float-end"><small>[i]</small></span>@endif</td>
|
<td>{{ $oo->name }} @if(! $oo->active)<span class="float-end"><small>[i]</small></span>@endif</td>
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
Register System
|
Register System
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
|
@php
|
||||||
|
use App\Models\{Setup,System};
|
||||||
|
@endphp
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<form class="needs-validation" method="post" autocomplete="off" novalidate>
|
<form class="needs-validation" method="post" autocomplete="off" novalidate>
|
||||||
@csrf
|
@csrf
|
||||||
@ -22,8 +26,9 @@
|
|||||||
<span class="input-group-text"><i class="bi bi-laptop-fill"></i></span>
|
<span class="input-group-text"><i class="bi bi-laptop-fill"></i></span>
|
||||||
<select style="width: 80%;" class="form-select @error('system_id') is-invalid @enderror" id="system" name="id" required>
|
<select style="width: 80%;" class="form-select @error('system_id') is-invalid @enderror" id="system" name="id" required>
|
||||||
<option value=""> </option>
|
<option value=""> </option>
|
||||||
@foreach (\App\Models\System::select(['systems.id','systems.name'])
|
@foreach (System::select(['systems.id','systems.name'])
|
||||||
->active()
|
->active()
|
||||||
|
->where('id','<>',Setup::findOrFail(config('app.id'))->system_id)
|
||||||
->whereRaw('id NOT IN (SELECT system_id FROM system_user)')
|
->whereRaw('id NOT IN (SELECT system_id FROM system_user)')
|
||||||
->cursor() as $oo)
|
->cursor() as $oo)
|
||||||
<option value="{{ $oo->id }}" @if(old('id')===$oo->id)selected @endif>{{ $oo->name }}</option>
|
<option value="{{ $oo->id }}" @if(old('id')===$oo->id)selected @endif>{{ $oo->name }}</option>
|
||||||
|
1
resources/views/widgets/saved.blade.php
Normal file
1
resources/views/widgets/saved.blade.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
<button class="btn btn-success btn-sm float-end">Saved</button>
|
Loading…
Reference in New Issue
Block a user