-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* comment out triggers * ide-helper * it's a mess but the result should be a beauty * update internet accesses table * remove internet user role * fixing filter on names * Comments and minor UI improvements * added tests * style: format code with PHP CS Fixer This commit fixes the style issues introduced in 8d97de4 according to the output from PHP CS Fixer. Details: #386 * ide:helper * style: format code with PHP CS Fixer This commit fixes the style issues introduced in 4898a70 according to the output from PHP CS Fixer. Details: #386 * Update app/Http/Controllers/Network/AdminInternetController.php Co-authored-by: Sámuel Szajbély <[email protected]> * Update app/Http/Controllers/Network/MacAddressController.php Co-authored-by: Sámuel Szajbély <[email protected]> * address changes * style: format code with PHP CS Fixer This commit fixes the style issues introduced in c8ee212 according to the output from PHP CS Fixer. Details: #386 * fix router page * style: format code with PHP CS Fixer This commit fixes the style issues introduced in 92fe6f2 according to the output from PHP CS Fixer. Details: #386 * auto approve macs for admins * style: format code with PHP CS Fixer This commit fixes the style issues introduced in ae43849 according to the output from PHP CS Fixer. Details: #386 * composer update * update ci * fix merge * fix locale test * fix deepsource issues * fix wrong return type * configure test email sending and test fault reports * completed tests * style: format code with PHP CS Fixer This commit fixes the style issues introduced in 8cdd25e according to the output from PHP CS Fixer. Details: #386 * deepsource fix * send mac status changed mail * style: format code with PHP CS Fixer This commit fixes the style issues introduced in cf1c302 according to the output from PHP CS Fixer. Details: #386 --------- Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> Co-authored-by: Sámuel Szajbély <[email protected]>
- Loading branch information
1 parent
db6810e
commit ab26f45
Showing
100 changed files
with
4,621 additions
and
2,314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
app/Http/Controllers/Network/AdminInternetController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Network; | ||
|
||
use App\Http\Controllers\Controller; | ||
use App\Models\Internet\InternetAccess; | ||
use App\Models\Internet\WifiConnection; | ||
use App\Utils\TabulatorPaginator; | ||
use Carbon\Carbon; | ||
use Illuminate\Auth\Access\AuthorizationException; | ||
use Illuminate\Contracts\View\View; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Response; | ||
use Illuminate\Pagination\LengthAwarePaginator; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class AdminInternetController extends Controller | ||
{ | ||
/** | ||
* Show the admin internet access page. | ||
* | ||
* @throws AuthorizationException | ||
*/ | ||
public function index(): View | ||
{ | ||
$this->authorize('handleAny', InternetAccess::class); | ||
|
||
return view('network.admin.app', [ | ||
'activation_date' => InternetAccess::getInternetDeadline()->format('Y-m-d H:i'), | ||
]); | ||
} | ||
|
||
/** | ||
* Return paginated internet access data. | ||
* | ||
* @return LengthAwarePaginator | ||
* @throws AuthorizationException | ||
*/ | ||
public function indexInternetAccesses(): LengthAwarePaginator | ||
{ | ||
$this->authorize('handleAny', InternetAccess::class); | ||
|
||
return TabulatorPaginator::from( | ||
InternetAccess::query() | ||
->join('users as user', 'user.id', '=', 'user_id') | ||
->select('internet_accesses.*') | ||
->with('user') | ||
) | ||
->sortable(['auto_approved_mac_slots', 'has_internet_until', 'user.name']) | ||
->filterable(['auto_approved_mac_slots', 'has_internet_until', 'user.name']) | ||
->paginate(); | ||
|
||
} | ||
|
||
/** | ||
* Get paginated wifi connections data. | ||
* @param Request $request | ||
* @return LengthAwarePaginator | ||
* @throws AuthorizationException | ||
*/ | ||
public function indexWifi(Request $request): LengthAwarePaginator | ||
{ | ||
$this->authorize('viewAny', WifiConnection::class); | ||
|
||
return TabulatorPaginator::from( | ||
WifiConnection::query() | ||
->groupBy(['wifi_username', 'mac_address', 'ip', 'lease_start', 'lease_end', 'note']) | ||
->select(['wifi_username', 'mac_address', 'ip', 'lease_start', 'lease_end', 'note', | ||
DB::raw('COUNT(*) as radius_connections')]) | ||
) | ||
->sortable(['wifi_username', 'mac_address', 'ip', 'lease_start']) | ||
->filterable(['wifi_username', 'mac_address', 'ip', 'lease_start']) | ||
->paginate(); | ||
} | ||
|
||
|
||
/** | ||
* Extends the internet access of a user until the given date or until the general internet access deadline. | ||
* @throws AuthorizationException | ||
* | ||
*/ | ||
public function extend(Request $request, InternetAccess $internetAccess): Carbon | ||
{ | ||
$this->authorize('extend', $internetAccess); | ||
|
||
$request->validate([ | ||
'has_internet_until' => 'nullable|date', | ||
]); | ||
|
||
return $internetAccess->extendInternetAccess($request->get('has_internet_until')); | ||
} | ||
|
||
/** | ||
* Revokes the internet access of a user. | ||
* @throws AuthorizationException | ||
*/ | ||
public function revoke(Request $request, InternetAccess $internetAccess): Response | ||
{ | ||
$this->authorize('extend', $internetAccess); | ||
|
||
$internetAccess->update(['has_internet_until' => null]); | ||
return response()->noContent(); | ||
} | ||
|
||
} |
Oops, something went wrong.