Skip to content

Commit

Permalink
[BF] Fix issue with peering manager / peers and customer over display
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Jan 9, 2019
1 parent 0eb8e16 commit 5cf0de6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Customer/CustomerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ public function overview( $id = null, $tab = null ) : View {
'tab' => strtolower( $tab ),
'notes' => $cns,
'notesInfo' => D2EM::getRepository( CustomerNoteEntity::class )->analyseForUser( $cns, $c, Auth::user() ),
'peers' => D2EM::getRepository( CustomerEntity::class )->getPeeringManagerArrayByType( $c , D2EM::getRepository( VlanEntity::class )->getPeeringManagerVLANs(), [ 4, 6 ] )
'peers' => D2EM::getRepository( CustomerEntity::class )->getPeeringManagerArrayByType( $c , D2EM::getRepository( VlanEntity::class )->getPeeringManagerVLANs(), [ 4, 6 ] ) ?? false,
]);
}

Expand Down
9 changes: 8 additions & 1 deletion app/Http/Controllers/PeeringManagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ public function index() {

$protos = [ 4, 6 ];

$peers = D2EM::getRepository( CustomerEntity::class )->getPeeringManagerArrayByType( $c, $vlans, $protos );
$peers = D2EM::getRepository( CustomerEntity::class )->getPeeringManagerArrayByType( $c, $vlans, $protos ) ?? false;

if( !$peers ) {
AlertContainer::push( 'No peers have been found for the peering manager. Please see <a href="'
. 'https://github.com/inex/IXP-Manager/wiki/Peering-Manager">these instructions</a>'
. ' / ensure your database is populating with peering information.', Alert::DANGER );
return Redirect::to( '' );
}

/** @noinspection PhpUndefinedMethodInspection - need to sort D2EM::getRepository factory inspection */
return view( 'peering-manager/index' )->with([
Expand Down
11 changes: 2 additions & 9 deletions database/Repositories/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
Customer as CustomerEntity
};

use IXP\Utils\View\Alert\Container as AlertContainer;
use IXP\Utils\View\Alert\Alert;

/**
* CustomerRepository
Expand Down Expand Up @@ -497,15 +495,10 @@ public function getForPeeringManager()
*
* @throws
*/
public function getPeeringManagerArrayByType( CustomerEntity $cust , $vlans, $protos ){
public function getPeeringManagerArrayByType( CustomerEntity $cust , $vlans, $protos ) {

if( !count( $vlans ) ) {

// FIXME controller logic should not be in a repository:
AlertContainer::push( 'No VLANs have been enabled for the peering manager. Please see <a href="'
. 'https://github.com/inex/IXP-Manager/wiki/Peering-Manager">these instructions</a>'
. ' / contact our support team.', Alert::DANGER );
return Redirect::to('');
return null;
}

$bilat = array();
Expand Down
25 changes: 18 additions & 7 deletions resources/views/customer/overview.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,13 @@
<li role="cross-connects" <?php if( $t->tab == 'cross-connects' ): ?> class="active" <?php endif; ?>>
<a data-toggle="tab" href="#cross-connects" data-toggle="tab">Cross Connects</a>
</li>
<li role="peers" <?php if( $t->tab == 'peers' ): ?> class="active" <?php endif; ?>>
<a data-toggle="tab" href="#peers" data-toggle="tab">Peers</a>
</li>

<?php if( $t->peers ): ?>
<li role="peers" <?php if( $t->tab == 'peers' ): ?> class="active" <?php endif; ?>>
<a data-toggle="tab" href="#peers" data-toggle="tab">Peers</a>
</li>
<?php endif; ?>

<?php if( count( $c->getConsoleServerConnections() ) ): ?>
<li role="console-server-connections" <?php if( $t->tab == 'console-server-connections' ): ?> class="active" <?php endif; ?>>
<a data-toggle="tab" href="#console-server-connections" data-toggle="tab">OOB Access</a>
Expand Down Expand Up @@ -281,9 +285,13 @@
<div id="cross-connects" class="tab-pane fade">
<?= $t->insert( 'customer/overview-tabs/cross-connects' ); ?>
</div>
<div id="peers" class="tab-pane fade <?php if( $t->tab == 'peers' ): ?> in active <?php endif; ?>">
<?= $t->insert( 'customer/overview-tabs/peers' ); ?>
</div>

<?php if( $t->peers ): ?>
<div id="peers" class="tab-pane fade <?php if( $t->tab == 'peers' ): ?> in active <?php endif; ?>">
<?= $t->insert( 'customer/overview-tabs/peers' ); ?>
</div>
<?php endif; ?>

<div id="console-server-connections" class="tab-pane fade">
<?= $t->insert( 'customer/overview-tabs/console-server-connections' ); ?>
</div>
Expand All @@ -299,7 +307,10 @@
<?= $t->insert( 'customer/js/overview/users' ); ?>
<?= $t->insert( 'customer/js/overview/contacts' ); ?>
<?= $t->insert( 'customer/js/overview/notes' ); ?>
<?= $t->insert( 'customer/js/overview/peers' ); ?>

<?php if( $t->peers ): ?>
<?= $t->insert( 'customer/js/overview/peers' ); ?>
<?php endif; ?>

<script>
/**
Expand Down

0 comments on commit 5cf0de6

Please sign in to comment.