From 1fd51a435992985bc33b926fc0ad768e481e21bf Mon Sep 17 00:00:00 2001 From: Barry O'Donovan Date: Sun, 24 Nov 2024 14:24:26 +0000 Subject: [PATCH 1/4] [IM] Include ports without type in snmp discovery - closes inex/IXP-Manager#910 --- app/Models/Switcher.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/Switcher.php b/app/Models/Switcher.php index c06e79ffa..7f4b5bc78 100644 --- a/app/Models/Switcher.php +++ b/app/Models/Switcher.php @@ -382,7 +382,7 @@ public function snmpPollSwitchPorts( $host, $logger = false, bool|array &$result // iterate over all the ports discovered on the switch: foreach( $host->useIface()->indexes() as $index ) { // Port types - see https://docs.ixpmanager.org/latest/usage/switches/#snmp-and-port-types-iftype - if( !in_array( $host->useIface()->types()[ $index ], config('ixp.snmp.allowed_interface_types') ) ) { + if( isset( $host->useIface()->types()[ $index ] ) && !in_array( $host->useIface()->types()[ $index ], config('ixp.snmp.allowed_interface_types') ) ) { continue; } From 1670101b16dcad43c28ca94a92822ef8572db7e4 Mon Sep 17 00:00:00 2001 From: Barry O'Donovan Date: Mon, 16 Dec 2024 19:52:41 +0000 Subject: [PATCH 2/4] Redirect consistency --- app/Http/Controllers/Auth/ForgotPasswordController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 1708f48fc..ccadbd0ff 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -141,8 +141,8 @@ protected function sendResetLinkResponse(): RedirectResponse */ protected function sendResetLinkFailedResponse(): RedirectResponse { - AlertContainer::push( "If your email matches user(s) on the system, then an email listing those users has been sent to you." , Alert::INFO ); - return back(); + AlertContainer::push( 'If your email matches user(s) on the system, then an email listing those users has been sent to you.', Alert::INFO ); + return redirect( route( 'login@login' ) ); } /** From a4a786491f3c514a16f3e85dad07ebb854f58f65 Mon Sep 17 00:00:00 2001 From: Barry O'Donovan Date: Mon, 16 Dec 2024 20:23:53 +0000 Subject: [PATCH 3/4] [BF|IM] Fix customer names in dropdown for virtual interfaces * multiple customers with the same name (e.g. previous customer rejoined, associate became full, etc) prevented the dropdown from including more than one. * additional information when editing to show if a customer has left or not --- .../Interfaces/VirtualInterfaceController.php | 9 ++++--- app/Models/Aggregators/CustomerAggregator.php | 27 +++++++++++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Interfaces/VirtualInterfaceController.php b/app/Http/Controllers/Interfaces/VirtualInterfaceController.php index 43c51ffb1..185925b98 100644 --- a/app/Http/Controllers/Interfaces/VirtualInterfaceController.php +++ b/app/Http/Controllers/Interfaces/VirtualInterfaceController.php @@ -36,7 +36,8 @@ RedirectResponse }; -use IXP\Models\{Aggregators\VirtualInterfaceAggregator, +use IXP\Models\{Aggregators\CustomerAggregator, + Aggregators\VirtualInterfaceAggregator, Customer, PhysicalInterface, Switcher, @@ -146,7 +147,7 @@ public function create( Request $r, Customer $cust = null ): View } return view( 'interfaces/virtual/add' )->with([ - 'custs' => Customer::groupBy( 'name' )->get(), + 'custs' => CustomerAggregator::reformatNameWithDetail( Customer::trafficking()->current()->orderBy('name')->get() ), 'vlans' => [], 'vi' => false, 'cb' => false, @@ -207,7 +208,7 @@ public function edit( Request $r, VirtualInterface $vi ): View ]); return view( 'interfaces/virtual/add' )->with([ - 'custs' => Customer::groupBy( 'name' )->get(), + 'custs' => CustomerAggregator::reformatNameWithDetail( Customer::trafficking()->orderBy('name')->get() ), 'vlans' => Vlan::orderBy( 'number' )->get(), 'vi' => $vi, 'cb' => $vi->getCoreBundle(), @@ -279,7 +280,7 @@ public function wizard( Customer $cust = null ): View } return view( 'interfaces/virtual/wizard' )->with([ - 'custs' => Customer::groupBy( 'name' )->get(), + 'custs' => CustomerAggregator::reformatNameWithDetail( Customer::trafficking()->current()->orderBy('name')->get() ), 'vli' => false, 'vlans' => Vlan::orderBy( 'number' )->get(), 'pi_switches' => Switcher::where( 'active', true ) diff --git a/app/Models/Aggregators/CustomerAggregator.php b/app/Models/Aggregators/CustomerAggregator.php index 595a02118..4b438b90d 100644 --- a/app/Models/Aggregators/CustomerAggregator.php +++ b/app/Models/Aggregators/CustomerAggregator.php @@ -28,6 +28,7 @@ use Illuminate\Database\Eloquent\{ Builder, + Collection as EloquentCollection, }; use IXP\Models\{ @@ -442,7 +443,7 @@ public static function getPeeringManagerArrayByType( Customer $cust, $vlans, arr "custs" => $custs, "bilat" => $bilat, "vlan" => $vlans , - "protos" => $protos + "protos" => $protos, ]; } @@ -474,7 +475,7 @@ public static function deleteObject( Customer $cust ): bool $contacts = $cust->contacts(); DB::table( 'contact_to_group' ) - ->whereIn( 'contact_id', $contacts->get()->pluck( 'id' )->toArray(),) + ->whereIn( 'contact_id', $contacts->get()->pluck( 'id' )->toArray() ) ->delete(); $cust->contacts()->delete(); @@ -531,6 +532,28 @@ public static function deleteObject( Customer $cust ): bool return true; } + /** + * Reformat the name of the customers with additional details such as their date of leaving, + * if they have left, appended to the name. + * + * @param \Illuminate\Database\Eloquent\Collection $custs Collection of customers + * @return \Illuminate\Database\Eloquent\Collection Updated collection with reformatted names + */ + public static function reformatNameWithDetail( EloquentCollection $custs ): EloquentCollection { + + /** @var Customer $cust */ + foreach( $custs as $id => $cust ) { + + if( $cust->hasLeft() ) { + $custs[$id]->name .= " [Left $cust->dateleave]"; + } + + } + + return $custs; + } + + /** * Get atlas probes for a given customer and protocol. * From e82af409401e1fc3edd07a3b191228cfadffccdc Mon Sep 17 00:00:00 2001 From: Barry O'Donovan Date: Mon, 16 Dec 2024 20:30:33 +0000 Subject: [PATCH 4/4] [BF|IM] Show additional detail on customer drop down for patch panel port edits --- app/Http/Controllers/PatchPanel/Port/PortController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/PatchPanel/Port/PortController.php b/app/Http/Controllers/PatchPanel/Port/PortController.php index 88876a596..3a8585cf4 100644 --- a/app/Http/Controllers/PatchPanel/Port/PortController.php +++ b/app/Http/Controllers/PatchPanel/Port/PortController.php @@ -37,7 +37,8 @@ use IXP\Http\Requests\StorePatchPanelPort as StorePatchPanelPortRequest; -use IXP\Models\{Aggregators\PatchPanelPortAggregator, +use IXP\Models\{Aggregators\CustomerAggregator, + Aggregators\PatchPanelPortAggregator, Cabinet, Customer, Location, @@ -209,7 +210,7 @@ public function edit( Request $r, PatchPanelPort $ppp, string $formType = null ) return view( 'patch-panel-port/edit' )->with([ 'states' => $states, - 'customers' => Customer::select( [ 'id', 'name' ] )->orderBy( 'name' )->get(), + 'customers' => CustomerAggregator::reformatNameWithDetail( Customer::trafficking()->orderBy( 'name' )->get() ), 'switches' => Switcher::select( [ 'switch.id', 'switch.name' ] ) ->leftJoin( 'cabinet AS cab', 'cab.id', 'switch.cabinetid' ) ->where( 'active', true )