Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5f61802

Browse files
committed
[BF] Refactoring admin related URLs to sit under an admin/ prefix
Commit not fully tested, but all unit tests passing. API URLs still to be reviewed.
1 parent 455d42b commit 5f61802

58 files changed

Lines changed: 35807 additions & 399 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/Http/Controllers/CabinetController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ class CabinetController extends EloquentController
6161
*/
6262
protected $object = null;
6363

64+
protected static bool $is_admin_route = true;
65+
6466
/**
6567
* The URL prefix to use.
6668
*
@@ -91,7 +93,7 @@ public function feInit(): void
9193
'locationname' => [
9294
'title' => 'Facility',
9395
'type' => self::$FE_COL_TYPES[ 'HAS_ONE' ],
94-
'controller' => 'facility',
96+
'controller' => 'admin/facility',
9597
'action' => 'view',
9698
'idField' => 'locationid'
9799
],

app/Http/Controllers/ConsoleServer/ConsoleServerConnectionController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class ConsoleServerConnectionController extends EloquentController
6666
*/
6767
protected $object = null;
6868

69+
protected static bool $is_admin_route = true;
70+
6971
/**
7072
* This function sets up the frontend controller
7173
*/
@@ -84,7 +86,7 @@ public function feInit(): void
8486
'customer' => [
8587
'title' => 'Customer',
8688
'type' => self::$FE_COL_TYPES[ 'HAS_ONE' ],
87-
'controller' => 'customer',
89+
'controller' => 'admin/customer',
8890
'action' => 'overview',
8991
'idField' => 'customerid'
9092
],
@@ -147,7 +149,7 @@ public function feInit(): void
147149
#[\Override]
148150
protected static function additionalRoutes( string $route_prefix ): void
149151
{
150-
Route::group( [ 'prefix' => $route_prefix ], static function() use ( $route_prefix ) {
152+
Route::group( [ 'prefix' => ( static::$is_admin_route ? 'admin/' : '' ) . $route_prefix ], static function() use ( $route_prefix ) {
151153
Route::get( 'list/port/{cs}', 'ConsoleServer\ConsoleServerConnectionController@listPort' )->name( $route_prefix . '@listPort' );
152154
});
153155
}

app/Http/Controllers/ConsoleServer/ConsoleServerController.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class ConsoleServerController extends EloquentController
6161
*/
6262
protected $object = null;
6363

64+
65+
protected static bool $is_admin_route = true;
66+
6467
/**
6568
* This function sets up the frontend controller
6669
*/
@@ -79,36 +82,36 @@ public function feInit(): void
7982
'name' => [
8083
'title' => 'Name',
8184
'type' => self::$FE_COL_TYPES[ 'HAS_ONE' ],
82-
'controller' => 'console-server-connection',
85+
'controller' => 'admin/console-server-connection',
8386
'action' => 'list/port',
8487
'idField' => 'id'
8588
],
8689
'facility' => [
8790
'title' => 'Facility',
8891
'type' => self::$FE_COL_TYPES[ 'HAS_ONE' ],
89-
'controller' => 'facility',
92+
'controller' => 'admin/facility',
9093
'action' => 'view',
9194
'idField' => 'locationid'
9295
],
9396
'cabinet' => [
94-
'title' => 'Cabinet',
97+
'title' => 'Rack',
9598
'type' => self::$FE_COL_TYPES[ 'HAS_ONE' ],
96-
'controller' => 'rack',
99+
'controller' => 'admin/rack',
97100
'action' => 'view',
98101
'idField' => 'cabinetid'
99102
],
100103
'vendor' => [
101104
'title' => 'Vendor',
102105
'type' => self::$FE_COL_TYPES[ 'HAS_ONE' ],
103-
'controller' => 'vendor',
106+
'controller' => 'admin/vendor',
104107
'action' => 'view',
105108
'idField' => 'vendorid'
106109
],
107110
'model' => 'Model',
108111
'num_connections' => [
109112
'title' => 'Connections',
110113
'type' => self::$FE_COL_TYPES[ 'HAS_ONE' ],
111-
'controller' => 'console-server-connection',
114+
'controller' => 'admin/console-server-connection',
112115
'action' => 'list/port',
113116
'idField' => 'id'
114117
],

app/Http/Controllers/Contact/ContactGroupController.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class ContactGroupController extends EloquentController
6363

6464
protected static $route_prefix = "contact-group";
6565

66+
protected static bool $is_admin_route = true;
67+
6668
/**
6769
* This function sets up the frontend controller
6870
*/
@@ -251,4 +253,20 @@ public function checkForm( Request $r ): void
251253
'limited_to' => 'required|integer|min:0',
252254
] );
253255
}
256+
257+
258+
/**
259+
* @inheritdoc
260+
*/
261+
#[\Override]
262+
protected function preDelete(): bool
263+
{
264+
$okay = true;
265+
if( ( $cnt = $this->object->contacts()->count() ) ) {
266+
AlertContainer::push( "You cannot delete this contact group as there are {$cnt} contacts associated with it.", Alert::DANGER );
267+
$okay = false;
268+
}
269+
270+
return $okay;
271+
}
254272
}

app/Http/Controllers/CustKitController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class CustKitController extends EloquentController
5858
*/
5959
protected $object = null;
6060

61+
protected static bool $is_admin_route = true;
62+
6163
/**
6264
* This function sets up the frontend controller
6365
*/
@@ -78,14 +80,14 @@ public function feInit(): void
7880
'customer' => [
7981
'title' => 'Customer',
8082
'type' => self::$FE_COL_TYPES[ 'HAS_ONE' ],
81-
'controller' => 'customer',
83+
'controller' => 'admin/customer',
8284
'action' => 'overview',
8385
'idField' => 'custid'
8486
],
8587
'cabinet' => [
8688
'title' => 'Rack',
8789
'type' => self::$FE_COL_TYPES[ 'HAS_ONE' ],
88-
'controller' => 'rack',
90+
'controller' => 'admin/rack',
8991
'action' => 'view',
9092
'idField' => 'cabinetid'
9193
],

app/Http/Controllers/Customer/CustomerTagController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ class CustomerTagController extends EloquentController
6565
*/
6666
protected $object = null;
6767

68+
protected static bool $is_admin_route = true;
69+
70+
6871
/**
6972
* This function sets up the frontend controller
7073
*/
@@ -122,7 +125,7 @@ public function feInit(): void
122125
#[\Override]
123126
protected static function additionalRoutes( string $route_prefix ): void
124127
{
125-
Route::group( [ 'prefix' => $route_prefix ], static function() use ( $route_prefix ) {
128+
Route::group( [ 'prefix' => ( static::$is_admin_route ? 'admin/' : '' ) . $route_prefix ], static function() use ( $route_prefix ) {
126129
Route::get( 'cust/{cust}', 'Customer\CustomerTagController@linkCustomer' )->name( $route_prefix . '@link-customer' );
127130
Route::post( 'link/{cust}', 'Customer\CustomerTagController@link' )->name( $route_prefix . '@link' );
128131
});

app/Http/Controllers/DocstoreCustomer/DirectoryController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function listCustomers() : View
8787
*
8888
* @throws AuthorizationException
8989
*/
90-
public function list( Request $r, Customer $cust, DocstoreCustomerDirectory $dir = null ) : View
90+
public function list( Request $r, Customer $cust, ?DocstoreCustomerDirectory $dir ) : View
9191
{
9292
$this->authorize( 'list', [ DocstoreCustomerDirectory::class, $cust ] );
9393

@@ -115,7 +115,7 @@ public function list( Request $r, Customer $cust, DocstoreCustomerDirectory $dir
115115
*
116116
* @throws AuthorizationException
117117
*/
118-
public function listPatchPanelPortFiles( Request $r, Customer $cust = null ) : View
118+
public function listPatchPanelPortFiles( Request $r, ?Customer $cust ) : View
119119
{
120120
$this->authorize( 'listPatchPanelPortFiles', [ DocstoreCustomerDirectory::class, $cust ] );
121121

app/Http/Controllers/InfrastructureController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class InfrastructureController extends Eloquent2Frontend
6161
*/
6262
protected $object = null;
6363

64+
protected static bool $is_admin_route = true;
65+
66+
6467
/**
6568
* This function sets up the frontend controller
6669
*/

app/Http/Controllers/Irrdb/IrrdbConfigController.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class IrrdbConfigController extends EloquentController
6161
*/
6262
protected $object = null;
6363

64+
protected static bool $is_admin_route = true;
65+
66+
6467
/**
6568
* This function sets up the frontend controller
6669
*/

app/Http/Controllers/Layer2AddressController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class Layer2AddressController extends EloquentController
5757
*/
5858
protected $object = null;
5959

60+
protected static bool $is_admin_route = true;
61+
62+
6063
/**
6164
* Is this a read only controller?
6265
*
@@ -138,7 +141,7 @@ public function feInit(): void
138141
protected static function additionalRoutes( string $route_prefix ): Void
139142
{
140143
// NB: this route is marked as 'read-only' to disable normal CRUD operations. It's not really read-only.
141-
Route::group( [ 'prefix' => $route_prefix ], function() use ( $route_prefix ) {
144+
Route::group( [ 'prefix' => ( static::$is_admin_route ? 'admin/' : '' ) . $route_prefix ], function() use ( $route_prefix ) {
142145
Route::get( 'vlan-interface/{vli}', 'Layer2AddressController@forVlanInterface' )->name( $route_prefix . '@forVlanInterface' );
143146
});
144147
}

0 commit comments

Comments
 (0)