Enable demoting and promoting address role
This commit is contained in:
@@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user