Skip to content

Commit

Permalink
add patch_panel.colo_pp_type (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickhilliard authored Apr 4, 2022
1 parent b5d070b commit 3fd45df
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/Http/Controllers/PatchPanel/PatchPanelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public function edit( Request $r, PatchPanel $pp ): View
'port_prefix' => $r->old( 'port_prefix', $pp->port_prefix ),
'location_notes' => $r->old( 'location_notes', $pp->location_notes ),
'u_position' => $r->old( 'u_position', $pp->u_position ),
'colo_pp_type' => $r->old( 'colo_pp_type', $pp->colo_pp_type ),
'mounted_at' => $r->old( 'mounted_at', $pp->mounted_at ),
'numberOfPorts' => $r->old( 'numberOfPorts',0 ),
]);
Expand Down
1 change: 1 addition & 0 deletions app/Http/Requests/StorePatchPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function rules(): array
'installation_date' => 'date',
'port_prefix' => 'string|nullable',
'u_position' => 'numeric|nullable',
'colo_pp_type' => 'numeric',
'mounted_at' => 'string|nullable|in:' . implode( ',', array_keys( PatchPanel::$MOUNTED_AT ) ),
'numberOfPorts' => 'required|integer',
];
Expand Down
6 changes: 5 additions & 1 deletion app/Models/Aggregators/PatchPanelPortAggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ public static function list( int $ppid = null, bool $advanced = false, int $loca
return self::selectRaw( '
ppp.*,
count( pppf.id ) AS files, count( ppph.id ) AS histories,
pp.name as ppname, pp.port_prefix AS prefix,
pp.name as ppname,
pp.colo_reference as ppcolo_reference,
pp.port_prefix AS prefix,
pp.cable_type AS ppcable_type,
pp.colo_pp_type,
sp.name AS spname,
s.name AS sname, c.abbreviatedName AS cname,
count( ppps.id ) AS nbslave,
Expand Down
26 changes: 26 additions & 0 deletions app/Models/PatchPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
* @property string|null $installation_date
* @property string $port_prefix
* @property int $active
* @property int $colo_pp_type
* @property int $chargeable
* @property string $location_notes
* @property int|null $u_position
Expand Down Expand Up @@ -104,6 +105,7 @@ class PatchPanel extends Model
'installation_date',
'port_prefix',
'active',
'colo_pp_type',
'chargeable',
'location_notes',
'u_position',
Expand Down Expand Up @@ -136,6 +138,19 @@ class PatchPanel extends Model
self::CABLE_TYPE_MMF,
];

/**
* CONST Co-lo simplex/duplex specification
*/
public const COLO_PP_TYPE_SIMPLEX = 0;
public const COLO_PP_TYPE_DUPLEX = 1;

/**
* Array Co-lo simplex/duplex specification
*/
public static $COLO_PP_TYPES = [
self::COLO_PP_TYPE_SIMPLEX => 'Simplex',
self::COLO_PP_TYPE_DUPLEX => 'Duplex',
];

/**
* CONST Connector types
Expand Down Expand Up @@ -228,6 +243,17 @@ public function chargeable(): string
return PatchPanelPort::$CHARGEABLES[ $this->chargeable ] ?? 'Unknown';
}

/**
* Specifies whether the co-location provider uses simplex ("port 1") or
* duplex ("fibre 1 / fibre 2") notation in their cross-connect database.
*
* @return string
*/
public function coloPpType(): string
{
return self::$COLO_PP_TYPES[ $this->colo_pp_type ] ?? 'Other';
}

/**
* Turn the database integer representation of the states into text as
* defined in the PatchPanelPort::$CHARGEABLES array (or 'Unknown')
Expand Down
8 changes: 8 additions & 0 deletions app/Models/PatchPanelPort.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,14 @@ class PatchPanelPort extends Model
self::STATE_CEASED,
];

/**
* Array STATES for cross-connects where there may be a circuit installed by the colo
*/
public static $COLO_ASSIGNED_STATES = [
self::STATE_CONNECTED,
self::STATE_AWAITING_CEASE,
];

/**
* Array $CHARGEABLES
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class AddColoPPTypePatchPanel extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('patch_panel', function (Blueprint $table) {
$table->tinyInteger( 'colo_pp_type' )->after( 'active' )->nullable( false )->default(1);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('patch_panel', function (Blueprint $table) {
$table->dropColumn('colo_pp_type');
});

}
}
10 changes: 10 additions & 0 deletions resources/views/patch-panel/edit.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,16 @@
->value( date( 'Y-m-d' ) );
?>

<?= Former::select( 'colo_pp_type' )
->label( 'Co-lo Patch Panel Port Type' )
->options( \IXP\Models\PatchPanel::$COLO_PP_TYPES )
->addClass( 'chzn-select' )
->blockHelp( 'Specify whether the co-location provider uses simplex ("Port 1") or duplex ("fibre 1 / fibre 2")'
. 'notation in their cross-connect database.' )
;
?>


<div class="form-group row">
<div class="col-sm-8">
<div class="card mt-4">
Expand Down
10 changes: 10 additions & 0 deletions resources/views/patch-panel/view.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@
<?= $pp->chargeable() ?> <em>(default for ports)</em>
</td>
</tr>
<tr>
<td>
<b>
Co-lo Patch Panel Type:
</b>
</td>
<td>
<?= $pp->coloPpType() ?>
</td>
</tr>
<tr>
<td>
<b>
Expand Down

0 comments on commit 3fd45df

Please sign in to comment.