diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php index 20eb0da..f88494d 100644 --- a/app/Http/Controllers/SystemController.php +++ b/app/Http/Controllers/SystemController.php @@ -5,7 +5,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models\{Address,System}; -use App\Rules\TwoByteInteger; +use App\Rules\{FidoInteger,TwoByteInteger}; class SystemController extends Controller { @@ -74,7 +74,7 @@ class SystemController extends Controller case 'host': $request->validate([ - 'region_id' => ['required',new TwoByteInteger], + 'region_id' => ['required',new FidoInteger], 'host_id_new' => [ 'required', new TwoByteInteger, @@ -133,8 +133,8 @@ class SystemController extends Controller case 'node': $request->validate([ - 'region_id' => ['required',new TwoByteInteger], - 'host_id' => ['required',new TwoByteInteger], + 'region_id' => ['required',new FidoInteger], + 'host_id' => ['required',new FidoInteger], 'node_id' => [ 'required', new TwoByteInteger, @@ -215,6 +215,42 @@ class SystemController extends Controller ->with('o',$o); } + /** + * Delete address assigned to a host + * + * @param Address $o + * @return \Illuminate\Http\RedirectResponse + * @throws \Illuminate\Auth\Access\AuthorizationException + */ + public function del_address(Address $o) + { + $this->authorize('admin',$o); + session()->flash('add_address',TRUE); + + $sid = $o->system_id; + $o->delete(); + + return redirect()->to(sprintf('ftn/system/addedit/%d',$sid)); + } + + /** + * Suspend address assigned to a host + * + * @param Address $o + * @return \Illuminate\Http\RedirectResponse + * @throws \Illuminate\Auth\Access\AuthorizationException + */ + public function sus_address(Address $o) + { + $this->authorize('admin',$o); + session()->flash('add_address',TRUE); + + $o->active = (! $o->active); + $o->save(); + + return redirect()->to(sprintf('ftn/system/addedit/%d',$o->system_id)); + } + public function home() { return view('system.home'); diff --git a/app/Rules/FidoInteger.php b/app/Rules/FidoInteger.php new file mode 100644 index 0000000..f5123f3 --- /dev/null +++ b/app/Rules/FidoInteger.php @@ -0,0 +1,33 @@ += 0) && ($value < DomainController::NUMBER_MAX)); + } + + /** + * Get the validation error message. + * + * @return string + */ + public function message() + { + return sprintf('The number must be between 0 and %d.',DomainController::NUMBER_MAX); + } +} diff --git a/app/Rules/TwoByteInteger.php b/app/Rules/TwoByteInteger.php index edcc93f..e388edc 100644 --- a/app/Rules/TwoByteInteger.php +++ b/app/Rules/TwoByteInteger.php @@ -16,9 +16,9 @@ class TwoByteInteger implements Rule * @param mixed $value * @return bool */ - public function passes($attribute, $value) + public function passes($attribute,$value) { - return (is_numeric($value) && ($value > 0) && ($value < DomainController::NUMBER_MAX)) || ($value === 'no'); + return (is_numeric($value) && ($value > 0) && ($value < DomainController::NUMBER_MAX)); } /** diff --git a/public/oldschool/css/main.css b/public/oldschool/css/main.css index 6d70a1a..248bceb 100644 --- a/public/oldschool/css/main.css +++ b/public/oldschool/css/main.css @@ -257,8 +257,8 @@ ul#searchbar li i { #sidebar { position:absolute; left:0; - top:calc(3em + 8px); - height:calc(100vh - 3em + 8px); + top:calc(3em + 5px); + height:calc(100vh - 3em + 5px); width:22ch; overflow:hidden; padding-top:1.5em; @@ -708,4 +708,11 @@ a.goback:focus:before { .gohome:hover:before, .gohome:hover:after { color:#a50!important +} + +.modal-header.bg-danger .modal-title { + color: #fff !important; +} +.modal-body { + color: #0c0c0c; } \ No newline at end of file diff --git a/resources/views/system/addedit.blade.php b/resources/views/system/addedit.blade.php index 52851f7..3936560 100644 --- a/resources/views/system/addedit.blade.php +++ b/resources/views/system/addedit.blade.php @@ -290,7 +290,7 @@ Address Active - Role + Role @@ -300,6 +300,16 @@ {{ $oo->ftn }} {{ $oo->active ? 'YES' : 'NO' }} {{ $oo->role }} + + @can('admin',$oo) + + {{-- + + + --}} + + @endcan + @endforeach @@ -494,6 +504,8 @@ @endif + + @include('widgets.modal_delete') @endsection @section('page-scripts') diff --git a/resources/views/widgets/modal_delete.blade.php b/resources/views/widgets/modal_delete.blade.php new file mode 100644 index 0000000..3c537be --- /dev/null +++ b/resources/views/widgets/modal_delete.blade.php @@ -0,0 +1,31 @@ + + +@section('page-scripts') + +@append \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index bada59e..2dd44fc 100644 --- a/routes/web.php +++ b/routes/web.php @@ -44,6 +44,10 @@ Route::middleware(['verified','activeuser'])->group(function () { ->where('o','[0-9]+'); Route::post('ftn/system/addaddress/{o?}',[SystemController::class,'add_address']) ->where('o','[0-9]+'); + Route::get('ftn/system/deladdress/{o?}',[SystemController::class,'del_address']) + ->where('o','[0-9]+'); + Route::get('ftn/system/susaddress/{o?}',[SystemController::class,'sus_address']) + ->where('o','[0-9]+'); Route::get('ftn/zone',[ZoneController::class,'home']); Route::match(['get','post'],'ftn/zone/addedit/{o?}',[ZoneController::class,'add_edit'])