Enable demoting and promoting address role
This commit is contained in:
parent
7073fece94
commit
6c75659395
@ -373,6 +373,29 @@ class SystemController extends Controller
|
||||
return redirect()->to(sprintf('ftn/system/addedit/%d',$sid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Demo an address NC -> node
|
||||
*
|
||||
* @param Address $o
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function dem_address(Address $o)
|
||||
{
|
||||
// @todo This should be admin of the zone
|
||||
$this->authorize('admin',$o);
|
||||
session()->flash('accordion','address');
|
||||
|
||||
// Make sure that no other system has this address active.
|
||||
if ($o->role === Address::NODE_ACTIVE)
|
||||
return redirect()->back()->withErrors(['demaddress'=>sprintf('%s cannot be demoted any more',$o->ftn3D)]);
|
||||
|
||||
$o->role = ($o->role << 1);
|
||||
$o->save();
|
||||
|
||||
return redirect()->to(sprintf('ftn/system/addedit/%d',$o->system_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete address assigned to a host
|
||||
*
|
||||
@ -515,6 +538,29 @@ class SystemController extends Controller
|
||||
return view('system.ours');
|
||||
}
|
||||
|
||||
/**
|
||||
* Promote an address node -> NC
|
||||
*
|
||||
* @param Address $o
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Illuminate\Auth\Access\AuthorizationException
|
||||
*/
|
||||
public function pro_address(Address $o)
|
||||
{
|
||||
// @todo This should be admin of the zone
|
||||
$this->authorize('admin',$o);
|
||||
session()->flash('accordion','address');
|
||||
|
||||
// Make sure that no other system has this address active.
|
||||
if ($o->role === Address::NODE_NC)
|
||||
return redirect()->back()->withErrors(['proaddress'=>sprintf('%s cannot be promoted any more',$o->ftn3D)]);
|
||||
|
||||
$o->role = ($o->role >> 1);
|
||||
$o->save();
|
||||
|
||||
return redirect()->to(sprintf('ftn/system/addedit/%d',$o->system_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Suspend address assigned to a host
|
||||
*
|
||||
|
@ -127,6 +127,12 @@
|
||||
<a href="{{ url('ftn/system/susaddress',[$oo->id]) }}" title="@if($oo->active)Pause @else Activate @endif Address"><i class="bi @if($oo->active)bi-pause-circle-fill @else bi-play-circle-fill @endif"></i></a>
|
||||
<a href="{{ url('ftn/system/movaddress',[$o->id,$oo->id]) }}" title="Move Address to another System"><i class="bi bi-arrow-right-square-fill"></i></a>
|
||||
<a href="{{ url('ftn/system/deladdress',[$oo->id]) }}" title="Delete Address"><i class="bi bi-trash-fill"></i></a>
|
||||
@if ((\App\Models\Address::NODE_HC|\App\Models\Address::NODE_ACTIVE) & $oo->role)
|
||||
<a href="{{ url('ftn/system/proaddress',[$oo->id]) }}" title="Promote Address"><i class="bi bi-arrow-up-square-fill"></i></a>
|
||||
@endif
|
||||
@if ((\App\Models\Address::NODE_NC|\App\Models\Address::NODE_HC) & $oo->role)
|
||||
<a href="{{ url('ftn/system/demaddress',[$oo->id]) }}" title="Demote Address"><i class="bi bi-arrow-down-square-fill"></i></a>
|
||||
@endif
|
||||
@endif
|
||||
@endcan
|
||||
</td>
|
||||
@ -140,6 +146,18 @@
|
||||
{!! $message !!}
|
||||
</span>
|
||||
@enderror
|
||||
|
||||
@error('demaddress')
|
||||
<span class="btn btn-sm btn-danger" role="alert" style="text-align: left;">
|
||||
{!! $message !!}
|
||||
</span>
|
||||
@enderror
|
||||
|
||||
@error('proaddress')
|
||||
<span class="btn btn-sm btn-danger" role="alert" style="text-align: left;">
|
||||
{!! $message !!}
|
||||
</span>
|
||||
@enderror
|
||||
@endif
|
||||
|
||||
@can('admin',$o)
|
||||
|
@ -77,9 +77,13 @@ Route::middleware(['auth','verified','activeuser'])->group(function () {
|
||||
->where('o','[0-9]+');
|
||||
Route::get('ftn/system/deladdress/{o}',[SystemController::class,'del_address'])
|
||||
->where('o','[0-9]+');
|
||||
Route::get('ftn/system/demaddress/{o}',[SystemController::class,'dem_address'])
|
||||
->where('o','[0-9]+');
|
||||
Route::get('ftn/system/delsession/{o}/{zo}',[SystemController::class,'del_session'])
|
||||
->where('o','[0-9]+')
|
||||
->where('zo','[0-9]+');
|
||||
Route::get('ftn/system/proaddress/{o}',[SystemController::class,'pro_address'])
|
||||
->where('o','[0-9]+');
|
||||
Route::match(['get','post'],'ftn/system/echoarea/{o}',[SystemController::class,'echoareas'])
|
||||
->where('o','[0-9]+');
|
||||
Route::match(['get','post'],'ftn/system/filearea/{o}',[SystemController::class,'fileareas'])
|
||||
|
Loading…
Reference in New Issue
Block a user