From 8d4ca2963dceb2e790fd4f40022c4b36fd14b3c6 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 8 Aug 2021 17:27:22 +1000 Subject: [PATCH] Enabled moving address, minor CSS fixes --- app/Http/Controllers/SystemController.php | 42 +++++++ public/oldschool/css/main.css | 9 +- resources/views/setup.blade.php | 2 +- resources/views/system/addedit.blade.php | 21 ++-- resources/views/system/moveaddr.blade.php | 137 ++++++++++++++++++++++ routes/web.php | 3 + 6 files changed, 202 insertions(+), 12 deletions(-) create mode 100644 resources/views/system/moveaddr.blade.php diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 43e7225..8baf1bc 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; +use Illuminate\Support\Arr; use App\Models\{Address,System,Zone}; use App\Rules\{FidoInteger,TwoByteInteger}; @@ -312,6 +313,47 @@ class SystemController extends Controller return redirect()->to(sprintf('ftn/system/addedit/%d',$o->id)); } + /** + * Move address to another system + * + * @param Request $request + * @param System $so + * @param Address $o + * @throws \Illuminate\Auth\Access\AuthorizationException + */ + public function mov_address(Request $request,System $so,Address $o) + { + // Quick check that this address belongs to this system + if ($so->addresses->search(function($item) use ($o) { return $item->id == $o->id; }) === FALSE) + abort(404); + + if ($request->post()) { + $this->authorize('admin',$o); + + $validated = $request->validate([ + 'system_id' => 'required|exists:systems,id', + 'remove' => 'nullable|boolean', + 'remsess' => 'nullable|boolean|exclude_if:remove,1', + ]); + + $o->system_id = $validated['system_id']; + $o->save(); + + if (Arr::get($validated,'remove')) { + $so->sessions()->detach($o->zone); + $so->delete(); + + } elseif (Arr::get($validated,'remsess')) { + $so->sessions()->detach($o->zone); + } + + return redirect()->to('ftn/system/addedit/'.$validated['system_id']); + } + + return view('system.moveaddr') + ->with('o',$o); + } + public function ours() { return view('system.ours'); diff --git a/public/oldschool/css/main.css b/public/oldschool/css/main.css index 3dd0718..798b72d 100644 --- a/public/oldschool/css/main.css +++ b/public/oldschool/css/main.css @@ -398,6 +398,9 @@ ul#searchbar li i { margin-bottom: 16px; } +.actions { + width: 1%; +} dl { margin:1em -1px 0 1px } @@ -488,7 +491,9 @@ label.list-group-item { background-color: inherit; color: inherit; } - +.nowrap { + white-space: nowrap; +} p { margin:0 0 1em; padding:0; @@ -631,7 +636,7 @@ tbody { .monotable tbody td { padding-left:1.5ch!important; padding-right:1.5ch!important; - vertical-align:middle!important + vertical-align:top; } .monotable tbody tr:first-child td { padding-top:9px!important diff --git a/resources/views/setup.blade.php b/resources/views/setup.blade.php index 0a99ef4..91bd719 100644 --- a/resources/views/setup.blade.php +++ b/resources/views/setup.blade.php @@ -45,7 +45,7 @@ use App\Models\Setup; @if(! $o->system_id) Add a NEW System @else - Edit System + Edit System @endif diff --git a/resources/views/system/addedit.blade.php b/resources/views/system/addedit.blade.php index 13aa32b..2433473 100644 --- a/resources/views/system/addedit.blade.php +++ b/resources/views/system/addedit.blade.php @@ -4,6 +4,10 @@ @if($o->exists) Update @else Add @endif System @endsection +@php +use App\Http\Controllers\DomainController as DC; +@endphp + @section('content') @if ($o->exists)

{{ $o->name }}@if($o->setup)*@endif

@@ -158,17 +162,17 @@ {{ $oo->ftn }} {{ $oo->active ? 'YES' : 'NO' }} {{ $oo->role_name }} - - @if (! $oo->children) + @can('admin',$oo) - - {{-- - - - --}} + + {{-- + @if (! $oo->role & (DC::NODE_ZC|DC::NODE_RC|DC::NODE_NC)) + + @endif + --}} + @endcan - @endif @endforeach @@ -211,7 +215,6 @@ @foreach($x as $zo) - @foreach ($o->match($zo) as $oo) {{ $oo->ftn }} diff --git a/resources/views/system/moveaddr.blade.php b/resources/views/system/moveaddr.blade.php new file mode 100644 index 0000000..662b96b --- /dev/null +++ b/resources/views/system/moveaddr.blade.php @@ -0,0 +1,137 @@ +@extends('layouts.app') + +@section('htmlheader_title') +Move Address +@endsection + +@section('content') +
+
+

{{ $o->system->name }} - {{ $o->ftn }}@if($o->system->setup)*@endif

+ @if($o->system->setup)* This Host@endif +
+
+ +
+
+ +
+

Move Address

+ +
+ @csrf + +
+ +
+ +
+ + + + @error('system_id') + {{ $message }} + @else + Please select the System that should have the address. + @enderror + + + Add a NEW System + +
+
+ +
+ +
+
+ system->setup || $o->system->addresses->count() > 1)disabled @endif @if(old('remove',FALSE))checked @endif> + + + system->addresses->count() > 1)disabled @endif @if(! old('remove',FALSE))checked @endif> + +
+
+ + @error('remove') + {{ $message }} + @enderror + +
+ + @if ($o->session('sespass')) +
+ +
+
+ system->match($o->zone)->count() > 1)disabled @endif @if(old('remsess',FALSE))checked @endif> + + + system->match($o->zone)->count() > 1)disabled @endif @if(! old('remsess',FALSE))checked @endif> + +
+ + @error('remsess') + {{ $message }} + @enderror + +
+
+ @endif +
+ +
+
+ Cancel +
+ + + @if($errors->count()) + + There were errors with the submission. + @dump($errors) + + @endif + + + @can('admin',$o) +
+ +
+ @endcan +
+
+
+
+
+@endsection + +@section('page-css') + +@append +@section('page-scripts') + + + +@append \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 393a4e3..b94a304 100644 --- a/routes/web.php +++ b/routes/web.php @@ -50,6 +50,9 @@ Route::middleware(['verified','activeuser'])->group(function () { Route::get('ftn/system/delsession/{o}/{zo}',[SystemController::class,'del_session']) ->where('o','[0-9]+') ->where('zo','[0-9]+'); + Route::match(['get','post'],'ftn/system/movaddress/{so}/{o}',[SystemController::class,'mov_address']) + ->where('so','[0-9]+') + ->where('o','[0-9]+'); Route::get('ftn/system/susaddress/{o}',[SystemController::class,'sus_address']) ->where('o','[0-9]+');