From 3fd45dfd065dd347338e4576c5733d3e4ba13364 Mon Sep 17 00:00:00 2001 From: Nick Hilliard Date: Mon, 4 Apr 2022 16:00:35 +0100 Subject: [PATCH] add patch_panel.colo_pp_type (#779) --- .../PatchPanel/PatchPanelController.php | 1 + app/Http/Requests/StorePatchPanel.php | 1 + .../Aggregators/PatchPanelPortAggregator.php | 6 +++- app/Models/PatchPanel.php | 26 +++++++++++++++ app/Models/PatchPanelPort.php | 8 +++++ ...12_183121_add_colo_pp_type_patch_panel.php | 33 +++++++++++++++++++ resources/views/patch-panel/edit.foil.php | 10 ++++++ resources/views/patch-panel/view.foil.php | 10 ++++++ 8 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2022_02_12_183121_add_colo_pp_type_patch_panel.php diff --git a/app/Http/Controllers/PatchPanel/PatchPanelController.php b/app/Http/Controllers/PatchPanel/PatchPanelController.php index cb3f9293f..d28ab0aa5 100644 --- a/app/Http/Controllers/PatchPanel/PatchPanelController.php +++ b/app/Http/Controllers/PatchPanel/PatchPanelController.php @@ -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 ), ]); diff --git a/app/Http/Requests/StorePatchPanel.php b/app/Http/Requests/StorePatchPanel.php index 79acbf88b..b0ede793f 100644 --- a/app/Http/Requests/StorePatchPanel.php +++ b/app/Http/Requests/StorePatchPanel.php @@ -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', ]; diff --git a/app/Models/Aggregators/PatchPanelPortAggregator.php b/app/Models/Aggregators/PatchPanelPortAggregator.php index 0d5e3bfce..8c937921d 100644 --- a/app/Models/Aggregators/PatchPanelPortAggregator.php +++ b/app/Models/Aggregators/PatchPanelPortAggregator.php @@ -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, diff --git a/app/Models/PatchPanel.php b/app/Models/PatchPanel.php index ac33b0c86..04f02a67f 100644 --- a/app/Models/PatchPanel.php +++ b/app/Models/PatchPanel.php @@ -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 @@ -104,6 +105,7 @@ class PatchPanel extends Model 'installation_date', 'port_prefix', 'active', + 'colo_pp_type', 'chargeable', 'location_notes', 'u_position', @@ -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 @@ -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') diff --git a/app/Models/PatchPanelPort.php b/app/Models/PatchPanelPort.php index 4ad40ce09..14ab1772c 100644 --- a/app/Models/PatchPanelPort.php +++ b/app/Models/PatchPanelPort.php @@ -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 */ diff --git a/database/migrations/2022_02_12_183121_add_colo_pp_type_patch_panel.php b/database/migrations/2022_02_12_183121_add_colo_pp_type_patch_panel.php new file mode 100644 index 000000000..70beb54cd --- /dev/null +++ b/database/migrations/2022_02_12_183121_add_colo_pp_type_patch_panel.php @@ -0,0 +1,33 @@ +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'); + }); + + } +} diff --git a/resources/views/patch-panel/edit.foil.php b/resources/views/patch-panel/edit.foil.php index 4ad93b776..8e0e79233 100644 --- a/resources/views/patch-panel/edit.foil.php +++ b/resources/views/patch-panel/edit.foil.php @@ -133,6 +133,16 @@ ->value( date( 'Y-m-d' ) ); ?> + 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.' ) + ; + ?> + +
diff --git a/resources/views/patch-panel/view.foil.php b/resources/views/patch-panel/view.foil.php index 7541633e7..7d29142c3 100644 --- a/resources/views/patch-panel/view.foil.php +++ b/resources/views/patch-panel/view.foil.php @@ -137,6 +137,16 @@ chargeable() ?> (default for ports) + + + + Co-lo Patch Panel Type: + + + + coloPpType() ?> + +