Skip to content

Commit

Permalink
[WIP] Migrate and fix member graphs view
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Jul 19, 2017
1 parent 3004b05 commit c6820b0
Show file tree
Hide file tree
Showing 6 changed files with 274 additions and 4 deletions.
122 changes: 121 additions & 1 deletion .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 82 additions & 0 deletions app/Http/Controllers/StatisticsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
/*
* Copyright (C) 2009-2017 Internet Neutral Exchange Association Company Limited By Guarantee.
* All Rights Reserved.
*
* This file is part of IXP Manager.
*
* IXP Manager is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, version v2.0 of the License.
*
* IXP Manager is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License v2.0
* along with IXP Manager. If not, see:
*
* http://www.gnu.org/licenses/gpl-2.0.html
*/

namespace IXP\Http\Controllers;

use App, D2EM;

use IXP\Services\Grapher\Graph;

use Illuminate\View\View;
use Illuminate\Support\Facades\Cache;

use Entities\{
Customer as CustomerEntity,
Vlan as VlanEntity
};

/**
* Statistics Controller
* @author Barry O'Donovan <barry@islandbridgenetworks.ie>
* @category Statistics
* @copyright Copyright (C) 2009-2017 Internet Neutral Exchange Association Company Limited By Guarantee
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU GPL V2.0
*/
class StatisticsController extends Controller
{

/**
* Display all member graphs
*
* @return View
*/
public function members() : View {

// $this->setIXP();
// $this->setInfrastructure();
// $this->setCategory();
// $category = $this->setCategory();
// $period = $this->setPeriod();

$grapher = App::make('IXP\Services\Grapher');

$custs = D2EM::getRepository( CustomerEntity::class )->getCurrentActive( false, true, false );

// if( $this->infra instanceof Entities\Infrastructure ) {
// $custs = $this->getD2R( 'Entities\Customer')->filterForInfrastructure( $custs, $this->infra );
// }

$graphs = [];

foreach( $custs as $c ) {
$graphs[] = $grapher->customer( $c )
->setType( Graph::TYPE_PNG )
->setProtocol( Graph::PROTOCOL_ALL )
->setCategory( Graph::CATEGORY_BITS )
->setPeriod( Graph::PERIOD_DAY );
}

return view( 'statistics/members' )->with([
'graphs' => $graphs,
]);
}
}
6 changes: 3 additions & 3 deletions resources/views/services/grapher/renderer/box/legacy.foil.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

?>

<table width="506" cellspacing="1" cellpadding="1">
<table cellspacing="1" cellpadding="1">
<tr>
<td colspan="8" style="width: 500; height: 135;">
<img width="500" height="135" border="0" src="data:image/png;base64,<?=base64_encode( $t->graph->png() )?>" />
<td colspan="8">
<img width="100%" border="0" src="data:image/png;base64,<?=base64_encode( $t->graph->png() )?>" />
</td>
</tr>
<tr>
Expand Down
61 changes: 61 additions & 0 deletions resources/views/statistics/members.foil.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/** @var Foil\Template\Template $t */

$this->layout( 'layouts/ixpv4' )
?>

<?php $this->section( 'title' ) ?>
Home / Statistics / Graphs ( Bits / Day )
<?php $this->append() ?>

<?php $this->section( 'page-header-postamble' ) ?>
<li>
Home / Statistics / Graphs ( Bits / Day )
</li>

<span class="pull-right">
<div class="btn-group btn-group-xs" role="group">
<a type="button" class="btn btn-default" id="add-l2a">
<span class="glyphicon glyphicon-plus"></span>
</a>
</div>
</span>
<?php $this->append() ?>


<?php $this->section( 'content' ) ?>

<div class="row-fluid">

<?php
foreach( $t->graphs as $graph ): ?>

<div class="col-md-12 col-lg-4">

<div class="well">
<h4 style="vertical-align: middle">
<?= $graph->customer()->getFormattedName() ?>
<?php if( config('grapher.backends.sflow.enabled') /* && ( $category == 'bits' || $category == 'pkts' ) */ ): ?>
<span class="btn btn-mini" style="float: right">
<?php /* {genUrl controller="statistics" action="p2p" shortname=$graph->customer()->getShortname() category=$category period=$period} */ ?>
<a href="#"><i class="icon-random"></i></a>
</span>
<?php endif; ?>
</h4>

<p>
<br />
<?= $graph->renderer()->boxLegacy() ?>
</p>
</div>

</div>

<?php endforeach; ?>

</div>

<?php $this->append() ?>

<?php $this->section( 'scripts' ) ?>
<?php $this->append() ?>
3 changes: 3 additions & 0 deletions routes/apiv4-auth-superuser.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,6 @@
Route::get( 'birdseye-bgp-sessions/{vlanid}/{protocol}/{type}/{template}', 'NagiosController@birdseyeBgpSessions');
Route::post( 'birdseye-bgp-sessions/{vlanid}/{protocol}/{type}/{template}', 'NagiosController@birdseyeBgpSessions');
});



4 changes: 4 additions & 0 deletions routes/web-auth-superuser.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@

Route::post( 'store', 'RouterController@store' );
});

Route::group( [ 'prefix' => 'statistics' ], function() {
Route::get( 'memberss', 'StatisticsController@members' );
});

0 comments on commit c6820b0

Please sign in to comment.