Skip to content

Commit

Permalink
Merge remote-tracking branch 'ibn/release-v7' into release-v7
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Dec 16, 2024
2 parents 309f5a7 + e82af40 commit 477d808
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
RedirectResponse
};

use IXP\Models\{Aggregators\VirtualInterfaceAggregator,
use IXP\Models\{Aggregators\CustomerAggregator,
Aggregators\VirtualInterfaceAggregator,
Customer,
PhysicalInterface,
Switcher,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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() ),

Check failure on line 211 in app/Http/Controllers/Interfaces/VirtualInterfaceController.php

View workflow job for this annotation

GitHub Actions / ci-ex-dusk

InvalidArgument

app/Http/Controllers/Interfaces/VirtualInterfaceController.php:211:80: InvalidArgument: Argument 1 of IXP\Models\Aggregators\CustomerAggregator::reformatNameWithDetail expects Illuminate\Database\Eloquent\Collection<array-key, Illuminate\Database\Eloquent\Model>, but Illuminate\Database\Eloquent\Collection<int, Illuminate\Database\Eloquent\Model> provided (see https://psalm.dev/004)
'vlans' => Vlan::orderBy( 'number' )->get(),
'vi' => $vi,
'cb' => $vi->getCoreBundle(),
Expand Down Expand Up @@ -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 )
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/PatchPanel/Port/PortController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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() ),

Check failure on line 213 in app/Http/Controllers/PatchPanel/Port/PortController.php

View workflow job for this annotation

GitHub Actions / ci-ex-dusk

InvalidArgument

app/Http/Controllers/PatchPanel/Port/PortController.php:213:84: InvalidArgument: Argument 1 of IXP\Models\Aggregators\CustomerAggregator::reformatNameWithDetail expects Illuminate\Database\Eloquent\Collection<array-key, Illuminate\Database\Eloquent\Model>, but Illuminate\Database\Eloquent\Collection<int, Illuminate\Database\Eloquent\Model> provided (see https://psalm.dev/004)
'switches' => Switcher::select( [ 'switch.id', 'switch.name' ] )
->leftJoin( 'cabinet AS cab', 'cab.id', 'switch.cabinetid' )
->where( 'active', true )
Expand Down
27 changes: 25 additions & 2 deletions app/Models/Aggregators/CustomerAggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

use Illuminate\Database\Eloquent\{
Builder,
Collection as EloquentCollection,
};

use IXP\Models\{
Expand Down Expand Up @@ -442,7 +443,7 @@ public static function getPeeringManagerArrayByType( Customer $cust, $vlans, arr
"custs" => $custs,
"bilat" => $bilat,
"vlan" => $vlans ,
"protos" => $protos
"protos" => $protos,
];
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 477d808

Please sign in to comment.