Minor css fixes, delete/pause addresses, validation fixes for nodes with 0 in address
This commit is contained in:
@@ -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');
|
||||
|
33
app/Rules/FidoInteger.php
Normal file
33
app/Rules/FidoInteger.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
use App\Http\Controllers\DomainController;
|
||||
|
||||
class FidoInteger implements Rule
|
||||
{
|
||||
/**
|
||||
* Determine if the validation rule passes.
|
||||
* This will check that a number used for zone, net, host is between 1 and DomainController::NUMBER_MAX.
|
||||
*
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute,$value)
|
||||
{
|
||||
return (is_numeric($value) && ($value >= 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);
|
||||
}
|
||||
}
|
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user