Skip to content

Commit

Permalink
[NF] Filter by ports prewired only - closes #814
Browse files Browse the repository at this point in the history
barryo committed Nov 3, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 93b8dc4 commit 844e16a
Showing 3 changed files with 19 additions and 3 deletions.
7 changes: 5 additions & 2 deletions app/Http/Controllers/PatchPanel/Port/PortController.php
Original file line number Diff line number Diff line change
@@ -93,16 +93,19 @@ public function advancedIndex( Request $r ): View
$cabinet = is_numeric( $r->cabinet ) ? (int) $r->cabinet : 0;
$cabletype = is_numeric( $r->type ) ? (int) $r->type : 0;
$availableForUse = (bool) $r->available;
$prewiredOnly = (bool) $r->prewiredOnly;

$summary = "Filtered for: ";
$summary .= $location ? Location::find( $location )->name : 'all locations';
$summary .= ', ' . ( $cabinet ? Cabinet::find( $cabinet )->name : 'all cabinets' );
$summary .= ', ' . ( $cabletype ? PatchPanel::$CABLE_TYPES[ $cabletype ] : 'all cable types' );
$summary .= ( $availableForUse ? ', available for use.' : '.' );
$summary .= ( $availableForUse ? ', available for use' : '' );
$summary .= ( $prewiredOnly ? ', prewired only' : '' );
$summary .= '.';

return view( 'patch-panel-port/index' )->with([
'patchPanelPorts' => PatchPanelPortAggregator::list(
null, true, $location, $cabinet, $cabletype, $availableForUse
null, true, $location, $cabinet, $cabletype, $availableForUse, $prewiredOnly
),
'pp' => false,
'summary' => $summary,
5 changes: 4 additions & 1 deletion app/Models/Aggregators/PatchPanelPortAggregator.php
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ class PatchPanelPortAggregator extends PatchPanelPort
*
* @return Collection
*/
public static function list( int $ppid = null, bool $advanced = false, int $location = null, int $cabinet = null, int $cabletype = null, bool $availableForUse = false ): Collection
public static function list( int $ppid = null, bool $advanced = false, int $location = null, int $cabinet = null, int $cabletype = null, bool $availableForUse = false, bool $prewiredOnly = false ): Collection
{
return self::selectRaw( '
ppp.*,
@@ -109,6 +109,9 @@ public static function list( int $ppid = null, bool $advanced = false, int $loca
->when( $cabletype , function( Builder $q, $cabletype ) {
return $q->where('pp.cable_type', $cabletype );
} )
->when( $prewiredOnly, function( Builder $q, $prewired ) {
return $q->where( 'ppp.state', '=', PatchPanelPort::STATE_PREWIRED );
} )
->when( $availableForUse , function( Builder $q ) {
return $q->whereIn('ppp.state', PatchPanelPort::$AVAILABLE_STATES );
} )
10 changes: 10 additions & 0 deletions resources/views/patch-panel/index.foil.php
Original file line number Diff line number Diff line change
@@ -77,6 +77,16 @@
</div>
</li>

<li class="nav-item">
<div class="nav-link d-flex ">
<label>
<input name="prewiredOnly" value='true' id="prewiredOnly" class="mr-2" type="checkbox">
Prewired Only
</label>
</div>
</li>


<li class="nav-item">
<button type="submit" class="float-right btn btn-white">
Filter Ports

0 comments on commit 844e16a

Please sign in to comment.