mirror of
https://github.com/nidebr/as-stats-gui.git
synced 2025-02-20 11:23:18 +08:00
add ix stats
This commit is contained in:
parent
615acd2e86
commit
60d77e95e7
@ -41,6 +41,14 @@ config:
|
||||
## PEERINGDB
|
||||
my_asn: 34863
|
||||
|
||||
api:
|
||||
peeringdb:
|
||||
host: 'https://peeringdb.com'
|
||||
url : '/api'
|
||||
user: ''
|
||||
pass: ''
|
||||
token : ''
|
||||
|
||||
customlinks:
|
||||
PeeringDB: 'https://www.peeringdb.com/asn/%as%'
|
||||
robtex: 'https://www.robtex.com/as/as%as%.html'
|
||||
|
@ -4,7 +4,7 @@ application:
|
||||
release: '1.0'
|
||||
controller: 'src/Controllers'
|
||||
model: 'src/Models'
|
||||
locale: 'fr'
|
||||
locale: 'en'
|
||||
debug: TRUE
|
||||
template_dir: 'web/template'
|
||||
twig:
|
||||
|
@ -9,6 +9,10 @@ use Silex\Provider\SessionServiceProvider;
|
||||
use Silex\Provider\DoctrineServiceProvider;
|
||||
use Application\ConfigApplication as ConfigApplication;
|
||||
use DDesrosiers\SilexAnnotations\AnnotationServiceProvider;
|
||||
/*use Silex\Provider\TranslationServiceProvider;
|
||||
use Symfony\Component\Translation\Loader\YamlFileLoader;
|
||||
use Symfony\Bridge\Twig\Extension\TranslationExtension;
|
||||
use Silex\Provider\SymfonyBridgesServiceProvider;*/
|
||||
use \utilphp\util as Util;
|
||||
use \Mobile_Detect;
|
||||
|
||||
@ -51,6 +55,10 @@ class ApplicationProvider implements ServiceProviderInterface
|
||||
return new \Models\Whois($app);
|
||||
};
|
||||
|
||||
$app['peeringdb'] = function() use($app) {
|
||||
return new \Models\PeeringDB();
|
||||
};
|
||||
|
||||
$app->register(new AnnotationServiceProvider(), array(
|
||||
'annot.controllerDir' => realpath(ConfigApplication::getControllerRootDirectory()),
|
||||
));
|
||||
|
@ -116,4 +116,8 @@ class ConfigApplication
|
||||
return self::getConfigASStats()['config']['whois'];
|
||||
}
|
||||
|
||||
public static function getUrlPeeringDB()
|
||||
{
|
||||
return self::getConfigASStats()['api']['peeringdb']['host'].''.self::getConfigASStats()['api']['peeringdb']['url'];
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ class Asset extends BaseController
|
||||
|
||||
$topas = $this->db->GetASStatsTop(200, Func::statsFileForHours($hours), $selected_links, $this->data['aslist']);
|
||||
|
||||
$this->data['asinfo'] = NULL;
|
||||
foreach ($topas as $as => $nbytes) {
|
||||
$this->data['asinfo'][$as]['info'] = Func::GetASInfo($as);
|
||||
|
||||
|
@ -127,7 +127,7 @@ class Func
|
||||
$active_top = $dpagename == "index" ? "active": "";
|
||||
$active_searchas = $dpagename == "history" ? "active" : "";
|
||||
$active_searchasset = $dpagename == "asset" ? "active" : "";
|
||||
$active_ix = $dpagename == "ix" ? "active" : "";
|
||||
$active_ix = $dpagename == "ixstats" ? "active" : "";
|
||||
|
||||
$return = [
|
||||
'active_top' => $active_top,
|
||||
|
103
src/Controllers/IXStats.php
Normal file
103
src/Controllers/IXStats.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Controllers;
|
||||
use Silex\Application;
|
||||
use DDesrosiers\SilexAnnotations\Annotations as SLX;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Application\ConfigApplication as ConfigApplication;
|
||||
use Controllers\Func;
|
||||
|
||||
/**
|
||||
* @SLX\Controller(prefix="/ixstats")
|
||||
*/
|
||||
class IXStats extends BaseController
|
||||
{
|
||||
/**
|
||||
* @SLX\Route(
|
||||
* @SLX\Request(method="GET", uri=""),
|
||||
* @SLX\Bind(routeName="ixstats")
|
||||
* )
|
||||
*/
|
||||
public function index(Request $request, Application $app)
|
||||
{
|
||||
$this->data['active_page'] = Func::getRouteName($request);
|
||||
$req = $request->query->all();
|
||||
|
||||
$hours = 24;
|
||||
if (@$req['numhours']) $hours = (int)$req['numhours'];
|
||||
|
||||
$this->data['knownlinks'] = Func::getKnowlinks();
|
||||
$selected_links = array();
|
||||
foreach($this->data['knownlinks'] as $link){
|
||||
if(isset($req["link_${link['tag']}"]))
|
||||
$selected_links[] = $link['tag'];
|
||||
}
|
||||
$this->data['selected_links'] = $selected_links;
|
||||
$this->data['hours'] = $hours;
|
||||
|
||||
if ( $this->data['config']['my_asn'] ) {
|
||||
$this->data['myix'] = $app['peeringdb']->GetIX('34863');
|
||||
}
|
||||
|
||||
if ( isset($req['ix']) ) {
|
||||
if (isset($req['n'])) $ntop = (int)$req['n'];
|
||||
else $ntop = $this->data['config']['ntop'];
|
||||
if ($ntop > 200) $ntop = 200;
|
||||
|
||||
$this->data['request'] = $req;
|
||||
|
||||
$list_asn = $app['peeringdb']->GetIXASN($req['ix']);
|
||||
$topas = $this->db->GetASStatsTop($ntop, Func::statsFileForHours($hours), $selected_links, $list_asn);
|
||||
|
||||
$this->data['asinfo'] = NULL;
|
||||
foreach ($topas as $as => $nbytes) {
|
||||
$this->data['asinfo'][$as]['info'] = Func::GetASInfo($as);
|
||||
|
||||
$this->data['asinfo'][$as]['v4'] = [
|
||||
'in' => $nbytes[0],
|
||||
'out' => $nbytes[1],
|
||||
];
|
||||
|
||||
if ( $this->data['config']['showv6'] ) {
|
||||
$this->data['asinfo'][$as]['v6'] = [
|
||||
'in' => $nbytes[2],
|
||||
'out' => $nbytes[3],
|
||||
];
|
||||
}
|
||||
|
||||
$this->data['customlinks'][$as] = Func::getCustomLinks($as);
|
||||
}
|
||||
|
||||
$this->data['start'] = time() - $hours*3600;
|
||||
$this->data['end'] = time();
|
||||
$this->data['ntop'] = $ntop;
|
||||
$this->data['label'] = Func::statsLabelForHours($hours);
|
||||
return $app['twig']->render('pages/ixstats/ixstats.html.twig', $this->data);
|
||||
}
|
||||
|
||||
return $app['twig']->render('pages/ixstats/search.html.twig', $this->data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @SLX\Route(
|
||||
* @SLX\Request(method="GET", uri="get_ixname"),
|
||||
* @SLX\Bind(routeName="get_ixname")
|
||||
* )
|
||||
*/
|
||||
public function get_ixname(Request $request, Application $app)
|
||||
{
|
||||
$req = $request->query->all();
|
||||
$return = NULL;
|
||||
|
||||
if ( isset($req['name']) ) {
|
||||
foreach ($app['peeringdb']->GetIXName($req['name']) as $key => $value) {
|
||||
$return[] = array (
|
||||
'id' => strval($value->id),
|
||||
'name' => strval($value->name) . " (".$value->city." / ".$value->country.")",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($return);
|
||||
}
|
||||
}
|
97
src/Models/PeeringDB.php
Normal file
97
src/Models/PeeringDB.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace Models;
|
||||
use Controllers\Func;
|
||||
use Application\ConfigApplication as ConfigApplication;
|
||||
|
||||
class PeeringDB
|
||||
{
|
||||
protected $url;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = ConfigApplication::getUrlPeeringDB();
|
||||
}
|
||||
|
||||
protected function sendRequest( $url ) {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function GetInfo( $asn = NULL ) {
|
||||
if ( $asn ) {
|
||||
$json = $this->sendRequest($this->url."/net?asn=".$asn);
|
||||
$json = json_decode($json);
|
||||
if ( isset($json->meta->error) ) { return 0; }
|
||||
else { return $json->data[0]; }
|
||||
}
|
||||
}
|
||||
|
||||
public function GetIX( $asn = NULL ) {
|
||||
if ( $asn ) {
|
||||
$json = $this->sendRequest($this->url."/netixlan?asn=".$asn);
|
||||
$json = json_decode($json);
|
||||
|
||||
if ( empty($json->data) ) { return 0; }
|
||||
else { return $json->data; }
|
||||
}
|
||||
}
|
||||
|
||||
public function GetAllNet( $regex = NULL) {
|
||||
if ( $regex ) { $regex = '?asn__contains='.$regex; }
|
||||
$json = json_decode($this->sendRequest($this->url."/net".$regex));
|
||||
return $json->data;
|
||||
}
|
||||
|
||||
public function GetIXInfo( $id = NULL ) {
|
||||
if ( $id ) {
|
||||
$json = $this->sendRequest($this->url."/ix?id=".$id);
|
||||
$json = json_decode($json);
|
||||
|
||||
if ( empty($json->data) ) { return 0; }
|
||||
else { return $json->data; }
|
||||
}
|
||||
}
|
||||
|
||||
public function GetIXMembers( $id = NULL ) {
|
||||
if ( $id ) {
|
||||
$json = $this->sendRequest($this->url."/net?ix_id=".$id);
|
||||
$json = json_decode($json);
|
||||
|
||||
if ( empty($json->data) ) { return 0; }
|
||||
else { return $json->data; }
|
||||
}
|
||||
}
|
||||
|
||||
public function GetIXMembersLan( $id = NULL ) {
|
||||
if ( $id ) {
|
||||
$json = $this->sendRequest($this->url."/netixlan?ix_id=".$id);
|
||||
$json = json_decode($json);
|
||||
|
||||
if ( empty($json->data) ) { return 0; }
|
||||
else { return $json->data; }
|
||||
}
|
||||
}
|
||||
|
||||
public function GetIXASN($id = NULL) {
|
||||
$return = "";
|
||||
if ( $id ) {
|
||||
foreach ($this->GetIXMembers($id) as $key => $value) {
|
||||
$return[] = $value->asn;
|
||||
};
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function GetIXName( $regex = NULL) {
|
||||
if ( $regex ) { $regex = '?name__contains='.$regex; }
|
||||
$json = json_decode($this->sendRequest($this->url."/ix".$regex));
|
||||
return $json->data;
|
||||
}
|
||||
}
|
24
src/Views/base/legend.html.twig
Normal file
24
src/Views/base/legend.html.twig
Normal file
@ -0,0 +1,24 @@
|
||||
<table width="100%" class='small'>
|
||||
{% for link in knownlinks %}
|
||||
{% set tag = "link_#{ link.tag }" %}
|
||||
{% if request[tag] is defined and request[tag] == 'on' %}
|
||||
{% set checked = 'checked' %}
|
||||
{% else %}
|
||||
{% set checked = '' %}
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td style="border: 4px solid #fff;">
|
||||
<table style="border-collapse: collapse; margin: 0; padding: 0"><tr>
|
||||
{% if config.brighten_negative %}
|
||||
<td width="9" height="18" style="background-color: #{{ link.color }}"> </td>
|
||||
<td width="9" height="18" style="opacity: 0.73; background-color: #{{ link.color }}"> </td>
|
||||
{% else %}
|
||||
<td width="18" height="18" style="background-color: #{{ link.color }}"> </td>
|
||||
{% endif %}
|
||||
</tr></table>
|
||||
</td>
|
||||
<td> {{ link.descr }}</td>
|
||||
<td> <input type='checkbox' name='{{ tag }}' id ='{{ tag }}' {{ checked }}></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
28
src/Views/base/legend_small.html.twig
Normal file
28
src/Views/base/legend_small.html.twig
Normal file
@ -0,0 +1,28 @@
|
||||
<table width="100%" class='small'>
|
||||
<tr>
|
||||
<td>
|
||||
{% for link in knownlinks %}
|
||||
{% set tag = "link_#{ link.tag }" %}
|
||||
{% if request[tag] is defined and request[tag] == 'on' %}
|
||||
{% set checked = 'checked' %}
|
||||
{% else %}
|
||||
{% set checked = '' %}
|
||||
{% endif %}
|
||||
<td>
|
||||
<table style="border-collapse: collapse; margin: 0; padding: 0">
|
||||
<tr>
|
||||
{% if config.brighten_negative %}
|
||||
<td width="9" height="18" style="background-color: #{{ link.color }}"> </td>
|
||||
<td width="9" height="18" style="opacity: 0.73; background-color: #{{ link.color }}"> </td>
|
||||
{% else %}
|
||||
<td width="18" height="18" style="background-color: #{{ link.color }}"> </td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td> {{ link.descr }}</td>
|
||||
<td> <input type='checkbox' name='{{ tag }}' id ='{{ tag }}' {{ checked }}> </td>
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
@ -22,18 +22,38 @@
|
||||
{% endif %}
|
||||
<li class="{{ active_page.active_searchas }}"><a href="{{ path('history') }}">View AS</a></li>
|
||||
<li class="{{ active_page.active_searchasset }}"><a href="{{ path('asset') }}">View AS-SET</a></li>
|
||||
<li class="{{ active_page.active_ix }}"><a href="ix.php">View IX Stats</a></li>
|
||||
<li class="{{ active_page.active_ix }}"><a href="{{ path('ixstats') }}">View IX Stats</a></li>
|
||||
</ul>
|
||||
{% if active_page.active_top == "active" %}
|
||||
{% if active_page.active_top == "active" or active_page.active_ix == "active" %}
|
||||
<form class="navbar-form navbar-left" role="search">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control menu-input" name="n" placeholder="Top AS" value="">
|
||||
<input type="text" class="form-control menu-input" name="n" placeholder="Top AS" value="{{ request.n|default('') }}">
|
||||
<span class="input-group-btn">
|
||||
<button type="submit" class="btn btn-flat button-input">
|
||||
<i class="fa fa-search"></i>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
{% if active_page.active_ix == "active" %}
|
||||
{% if request is defined %}
|
||||
<input type='hidden' name='ix' value='{{ request.ix }}'/>
|
||||
<input type='hidden' name='numhours' value='{{ hours }}'/>
|
||||
{% if request.name_myix is defined %}
|
||||
<input type='hidden' name='name_myix' value='{{ request.name_myix }}'/>
|
||||
{% endif %}
|
||||
|
||||
{% if request.name_ix is defined %}
|
||||
<input type='hidden' name='name_ix' value='{{ request.name_ix }}'/>
|
||||
{% endif %}
|
||||
|
||||
{% if selected_links %}
|
||||
{% for link in selected_links %}
|
||||
{% set tag = "link_#{ link }" %}
|
||||
<input type='hidden' name='{{ tag }}' value='on'/>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -33,9 +33,11 @@
|
||||
{% endif %}
|
||||
{% endset %}
|
||||
|
||||
{% if outispositive != "NONE" %}
|
||||
<ol class="breadcrumb">
|
||||
<li>{{ traffic }}</li>
|
||||
</ol>
|
||||
{% endif %}
|
||||
</section>
|
||||
<hr>
|
||||
{% endmacro %}
|
||||
|
@ -85,64 +85,6 @@ History for AS-SET: {{ asset }}
|
||||
{% endif %}
|
||||
{% endset %}
|
||||
|
||||
{% set legend %}
|
||||
<table width="100%" class='small'>
|
||||
{% for link in knownlinks %}
|
||||
{% set tag = "link_#{ link.tag }" %}
|
||||
{% if request[tag] is defined and request[tag] == 'on' %}
|
||||
{% set checked = 'checked' %}
|
||||
{% else %}
|
||||
{% set checked = '' %}
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td width='15%' style="border: 4px solid #fff;">
|
||||
<table style="border-collapse: collapse; margin: 0; padding: 0"><tr>
|
||||
{% if config.brighten_negative %}
|
||||
<td width="9" height="18" style="background-color: #{{ link.color }}"> </td>
|
||||
<td width="9" height="18" style="opacity: 0.73; background-color: #{{ link.color }}"> </td>
|
||||
{% else %}
|
||||
<td width="18" height="18" style="background-color: #{{ link.color }}"> </td>
|
||||
{% endif %}
|
||||
</tr></table>
|
||||
</td>
|
||||
<td> {{ link.descr }}</td>
|
||||
<td> <input type='checkbox' name='{{ tag }}' id ='{{ tag }}' {{ checked }}></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endset %}
|
||||
|
||||
{% set legend_small %}
|
||||
<table width="100%" class='small'>
|
||||
<tr>
|
||||
<td>
|
||||
{% for link in knownlinks %}
|
||||
{% set tag = "link_#{ link.tag }" %}
|
||||
{% if request[tag] is defined and request[tag] == 'on' %}
|
||||
{% set checked = 'checked' %}
|
||||
{% else %}
|
||||
{% set checked = '' %}
|
||||
{% endif %}
|
||||
<td>
|
||||
<table style="border-collapse: collapse; margin: 0; padding: 0">
|
||||
<tr>
|
||||
{% if config.brighten_negative %}
|
||||
<td width="9" height="18" style="background-color: #{{ link.color }}"> </td>
|
||||
<td width="9" height="18" style="opacity: 0.73; background-color: #{{ link.color }}"> </td>
|
||||
{% else %}
|
||||
<td width="18" height="18" style="background-color: #{{ link.color }}"> </td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td> {{ link.descr }}</td>
|
||||
<td> <input type='checkbox' name='{{ tag }}' id ='{{ tag }}' {{ checked }}> </td>
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endset %}
|
||||
|
||||
{% set counter = 0 %}
|
||||
|
||||
{% set aff_astable %}
|
||||
@ -269,9 +211,9 @@ History for AS-SET: {{ asset }}
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{% if mobile %}
|
||||
{{ legend_small }}
|
||||
{{ include('/base/legend_small.html.twig') }}
|
||||
{% else %}
|
||||
{{ legend }}
|
||||
{{ include('/base/legend.html.twig') }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
|
@ -13,7 +13,7 @@ History for AS-SET
|
||||
|
||||
{% block content_wrapper %}
|
||||
{% set title = "History for AS-SET" %}
|
||||
{{ macro.content_header(title, "", config.outispositive ) }}
|
||||
{{ macro.content_header(title, "", 'NONE' ) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@ -13,7 +13,7 @@ History
|
||||
|
||||
{% block content_wrapper %}
|
||||
{% set title = "History for AS" %}
|
||||
{{ macro.content_header(title, "", config.outispositive ) }}
|
||||
{{ macro.content_header(title, "", 'NONE' ) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@ -64,64 +64,6 @@ Top {{ ntop }} AS ({{ label }})
|
||||
{{ macro.content_header(title, label, config.outispositive ) }}
|
||||
{% endblock %}
|
||||
|
||||
{% set legend %}
|
||||
<table class='small'>
|
||||
{% for link in knownlinks %}
|
||||
{% set tag = "link_#{ link.tag }" %}
|
||||
{% if request[tag] is defined and request[tag] == 'on' %}
|
||||
{% set checked = 'checked' %}
|
||||
{% else %}
|
||||
{% set checked = '' %}
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td style="border: 4px solid #fff;">
|
||||
<table style="border-collapse: collapse; margin: 0; padding: 0"><tr>
|
||||
{% if config.brighten_negative %}
|
||||
<td width="9" height="18" style="background-color: #{{ link.color }}"> </td>
|
||||
<td width="9" height="18" style="opacity: 0.73; background-color: #{{ link.color }}"> </td>
|
||||
{% else %}
|
||||
<td width="18" height="18" style="background-color: #{{ link.color }}"> </td>
|
||||
{% endif %}
|
||||
</tr></table>
|
||||
</td>
|
||||
<td> {{ link.descr }}</td>
|
||||
<td> <input type='checkbox' name='{{ tag }}' id ='{{ tag }}' {{ checked }}></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endset %}
|
||||
|
||||
{% set legend_small %}
|
||||
<table width="100%" class='small'>
|
||||
<tr>
|
||||
<td>
|
||||
{% for link in knownlinks %}
|
||||
{% set tag = "link_#{ link.tag }" %}
|
||||
{% if request[tag] is defined and request[tag] == 'on' %}
|
||||
{% set checked = 'checked' %}
|
||||
{% else %}
|
||||
{% set checked = '' %}
|
||||
{% endif %}
|
||||
<td>
|
||||
<table style="border-collapse: collapse; margin: 0; padding: 0">
|
||||
<tr>
|
||||
{% if config.brighten_negative %}
|
||||
<td width="9" height="18" style="background-color: #{{ link.color }}"> </td>
|
||||
<td width="9" height="18" style="opacity: 0.73; background-color: #{{ link.color }}"> </td>
|
||||
{% else %}
|
||||
<td width="18" height="18" style="background-color: #{{ link.color }}"> </td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td> {{ link.descr }}</td>
|
||||
<td> <input type='checkbox' name='{{ tag }}' id ='{{ tag }}' {{ checked }}> </td>
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endset %}
|
||||
|
||||
{% set counter = 0 %}
|
||||
|
||||
{% if config.showv6 %}
|
||||
@ -182,27 +124,27 @@ Top {{ ntop }} AS ({{ label }})
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-{{ first_col }}">
|
||||
<form method='get'>
|
||||
<input type='hidden' name='numhours' value='{{ hours }}'/>
|
||||
<input type='hidden' name='n' value='{{ ntop }}'/>
|
||||
<div data-spy="affix" data-offset-top="100">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Legend</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{% if mobile %}
|
||||
{{ legend_small }}
|
||||
{% else %}
|
||||
{{ legend }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button type="submit" class="btn pull-right"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
<form method='get'>
|
||||
<input type='hidden' name='numhours' value='{{ hours }}'/>
|
||||
<input type='hidden' name='n' value='{{ ntop }}'/>
|
||||
<div data-spy="affix" data-offset-top="100">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Legend</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{% if mobile %}
|
||||
{{ include('/base/legend_small.html.twig') }}
|
||||
{% else %}
|
||||
{{ include('/base/legend.html.twig') }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button type="submit" class="btn pull-right"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 col-lg-{{ second_col }} col-lg-offset-{{ offset_second_col }}">
|
||||
|
23
src/Views/pages/ixstats/_allix.html.twig
Normal file
23
src/Views/pages/ixstats/_allix.html.twig
Normal file
@ -0,0 +1,23 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<form method='get' id="search_ix_name">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Search IX</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<input type="text" class="form-control" name="name_ix" placeholder="Search IX" id="peeringdb" data-provide="typeahead" autocomplete="off" value="{{ request.name_ix|default('') }}">
|
||||
<input type='hidden' id='ix' name='ix'/>
|
||||
<div id="message"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% if selected_links %}
|
||||
{% for link in selected_links %}
|
||||
{% set tag = "link_#{ link }" %}
|
||||
<input type='hidden' name='{{ tag }}' value='on'/>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<input type='hidden' name='numhours' value='{{ hours }}'/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
58
src/Views/pages/ixstats/_graphs.html.twig
Normal file
58
src/Views/pages/ixstats/_graphs.html.twig
Normal file
@ -0,0 +1,58 @@
|
||||
{% import "macros/macros.html.twig" as macro %}
|
||||
|
||||
{% set counter = 0 %}
|
||||
|
||||
{% set aff_astable %}
|
||||
{% for key_as, as_data in asinfo %}
|
||||
{% set class %}
|
||||
{% if (counter % 2) != 0 %}
|
||||
even
|
||||
{% endif %}
|
||||
{% endset %}
|
||||
<li class="li-padding {{ class }}">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-lg-2">
|
||||
<b><img src="{{ global.request.baseUrl }}/flags/blank.gif" class="flag flag-{{ as_data.info.country|lower }}"/> AS{{ key_as }}: </b><small><i>{{ as_data.info.descr }}</i></small>
|
||||
<div class="small">In the last {{ label|default('') }}</div>
|
||||
<div class="small">IPv4: ~ {{ as_data.v4.in|format_bytes }} in / {{ as_data.v4.out|format_bytes }} out</div>
|
||||
{% if as_data.v6 is defined %}
|
||||
<div class="small">IPv6: ~ {{ as_data.v6.in|format_bytes }} in / {{ as_data.v6.out|format_bytes }} out</div>
|
||||
{% endif %}
|
||||
<span class="small">{{ attribute(customlinks, key_as)|raw }}</span>
|
||||
<div class="rank">
|
||||
{% set counter = counter + 1 %}
|
||||
# {{ counter }}
|
||||
</div>
|
||||
</div>
|
||||
{% if config.showv6 %}
|
||||
<div class="col-md-12 col-lg-5">
|
||||
<span class="pull-right">
|
||||
{{ macro.getHTMLUrl(key_as, 4, as_data.info.descr, start, end, 0, selected_links, config.top_graph_width, config.top_graph_height) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-5">
|
||||
<span class="pull-right">
|
||||
{{ macro.getHTMLUrl(key_as, 6, as_data.info.descr, start, end, 0, selected_links, config.top_graph_width, config.top_graph_height) }}
|
||||
</span>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col-md-12 col-lg-10">
|
||||
<span class="pull-right">
|
||||
{{ macro.getHTMLUrl(key_as, 4, as_data.info.descr, start, end, 0, selected_links, config.top_graph_width, config.top_graph_height) }}
|
||||
</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% endset %}
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="box box-primary">
|
||||
<div class="box-body">
|
||||
<ul class="nav nav-stacked">
|
||||
{{ aff_astable }}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
37
src/Views/pages/ixstats/_interval.html.twig
Normal file
37
src/Views/pages/ixstats/_interval.html.twig
Normal file
@ -0,0 +1,37 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<form method='get' id="search_ix_name">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Interval</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<select name="numhours" id="numhours" class="form-control" onchange="this.form.submit()">
|
||||
<option value="24">24 hours</option>
|
||||
{% for top in topinterval %}
|
||||
{% set selected %}
|
||||
{% if hours is defined and hours == top.hours %}
|
||||
selected
|
||||
{% endif %}
|
||||
{% endset %}
|
||||
<option {{ selected }} value="{{ top.hours }}">{{ top.label }}</option>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<input type='hidden' name='ix' value='{{ request.ix }}'/>
|
||||
{% if request.name_myix is defined %}
|
||||
<input type='hidden' name='name_myix' value='{{ request.name_myix }}'/>
|
||||
{% endif %}
|
||||
{% if request.name_ix is defined %}
|
||||
<input type='hidden' name='name_ix' value='{{ request.name_ix }}'/>
|
||||
{% endif %}
|
||||
|
||||
{% if selected_links %}
|
||||
{% for link in selected_links %}
|
||||
{% set tag = "link_#{ link }" %}
|
||||
<input type='hidden' name='{{ tag }}' value='on'/>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
32
src/Views/pages/ixstats/_myix.html.twig
Normal file
32
src/Views/pages/ixstats/_myix.html.twig
Normal file
@ -0,0 +1,32 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<form method='get'>
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">My IX</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<select name="ix" id="ix" class="form-control">
|
||||
<option value="">Select IX</option>
|
||||
{% for list_myix in myix %}
|
||||
{% set selected %}
|
||||
{% if request.ix is defined and request.ix == list_myix.ix_id %}
|
||||
selected
|
||||
{% endif %}
|
||||
{% endset %}
|
||||
<option {{ selected }} value="{{ list_myix.ix_id }}">{{ list_myix.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<input type='hidden' id='name_myix' name='name_myix'/>
|
||||
{% if selected_links %}
|
||||
{% for link in selected_links %}
|
||||
{% set tag = "link_#{ link }" %}
|
||||
<input type='hidden' name='{{ tag }}' value='on'/>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<input type='hidden' name='numhours' value='{{ hours }}'/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
208
src/Views/pages/ixstats/ixstats.html.twig
Normal file
208
src/Views/pages/ixstats/ixstats.html.twig
Normal file
@ -0,0 +1,208 @@
|
||||
{% extends "base/base.html.twig" %}
|
||||
{% import "macros/macros.html.twig" as macro %}
|
||||
|
||||
{% set add_title %}
|
||||
{% if request.name_ix is defined %}
|
||||
{{ request.name_ix }}
|
||||
{% endif %}
|
||||
|
||||
{% if request.name_myix is defined %}
|
||||
{{ request.name_myix }}
|
||||
{% endif %}
|
||||
{% endset %}
|
||||
|
||||
{% block refresh %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
IX Stats: {{ add_title }}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
<style>
|
||||
.affix {
|
||||
top:55px;
|
||||
z-index: 1;
|
||||
width: 6.8%;
|
||||
}
|
||||
@media (max-width:1680px) {
|
||||
.affix {
|
||||
width: 6.5%;
|
||||
}
|
||||
}
|
||||
@media (max-width:1600px) {
|
||||
.affix {
|
||||
width: 6.5%;
|
||||
}
|
||||
}
|
||||
@media (max-width:1440px) {
|
||||
.affix {
|
||||
width: 6.3%;
|
||||
}
|
||||
}
|
||||
@media (max-width:1280px) {
|
||||
.affix {
|
||||
width: 6.1%;
|
||||
}
|
||||
}
|
||||
@media (max-width:1024px) {
|
||||
.affix {
|
||||
width: 97%;
|
||||
}
|
||||
}
|
||||
@media (max-width:768px) {
|
||||
.affix {
|
||||
width: 96%;
|
||||
}
|
||||
}
|
||||
@media (max-width:667px) {
|
||||
.affix {
|
||||
width: 95.5%;
|
||||
}
|
||||
}
|
||||
@media (max-width:375px) {
|
||||
.affix {
|
||||
width: 92%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% if topinterval is defined %}
|
||||
{% set col_search = 4 %}
|
||||
{% set col_search_no_myasn = 6 %}
|
||||
{% else %}
|
||||
{% set col_search = 6 %}
|
||||
{% set col_search_no_myasn = 12 %}
|
||||
{% endif %}
|
||||
|
||||
{% if config.showv6 %}
|
||||
{% set first_col = "1" %}
|
||||
{% set second_col = "11" %}
|
||||
{% set offset_second_col = "0" %}
|
||||
{% else %}
|
||||
{% set first_col = "2" %}
|
||||
{% set second_col = "9" %}
|
||||
{% set offset_second_col = "1" %}
|
||||
{% endif %}
|
||||
|
||||
{% block content_wrapper %}
|
||||
{% set title = "IX Stats - #{add_title}" %}
|
||||
{% set label = "(top #{ntop} - #{label})" %}
|
||||
{{ macro.content_header(title, label, config.outispositive ) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-md-12 col-lg-{{ first_col }}">
|
||||
<form method='get'>
|
||||
<input type='hidden' name='ix' value='{{ request.ix }}'/>
|
||||
<input type='hidden' name='numhours' value='{{ hours }}'/>
|
||||
{% if request.name_myix is defined %}
|
||||
<input type='hidden' name='name_myix' value='{{ request.name_myix }}'/>
|
||||
{% endif %}
|
||||
{% if request.name_ix is defined %}
|
||||
<input type='hidden' name='name_ix' value='{{ request.name_ix }}'/>
|
||||
{% endif %}
|
||||
<div data-spy="affix" data-offset-top="100">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Legend</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{% if mobile %}
|
||||
{{ include('/base/legend_small.html.twig') }}
|
||||
{% else %}
|
||||
{{ include('/base/legend.html.twig') }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button type="submit" class="btn pull-right"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-{{ second_col }} col-lg-offset-{{ offset_second_col }}">
|
||||
<div class="row">
|
||||
{% if config.my_asn %}
|
||||
<div class="col-md-12 col-lg-{{ col_search }}">
|
||||
{{ include('/pages/ixstats/_myix.html.twig') }}
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-{{ col_search }}">
|
||||
{{ include('/pages/ixstats/_allix.html.twig') }}
|
||||
</div>
|
||||
{% if topinterval is defined %}
|
||||
<div class="col-md-12 col-lg-4">
|
||||
{{ include('/pages/ixstats/_interval.html.twig') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="col-md-{{ col_search_no_myasn }}">
|
||||
{{ include('/pages/ixstats/_allix.html.twig') }}
|
||||
</div>
|
||||
{% if topinterval is defined %}
|
||||
<div class="col-md-12 col-lg-6">
|
||||
{{ include('/pages/ixstats/_interval.html.twig') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{{ include('/pages/ixstats/_graphs.html.twig') }}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block modal %}
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script src="{{ global.request.baseUrl }}/template/bower_components/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="{{ global.request.baseUrl }}/template/plugins/typeahead/bootstrap3-typeahead.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#peeringdb').typeahead({
|
||||
source: function (query, process) {
|
||||
$.ajax({
|
||||
url: '{{ path('get_ixname') }}',
|
||||
dataType: 'JSON',
|
||||
minLength: 2,
|
||||
data: 'name=' + query,
|
||||
success: function(data) {
|
||||
if ( data !== null ) {
|
||||
process(data);
|
||||
} else {
|
||||
$("#message").html('<small class="form-text text-muted">No IX found.</small>');
|
||||
}
|
||||
},
|
||||
beforeSend: function () {
|
||||
$("#peeringdb").addClass("searchBox");
|
||||
},
|
||||
complete: function () {
|
||||
$("#peeringdb").removeClass("searchBox");
|
||||
},
|
||||
});
|
||||
},
|
||||
updater : function (item) {
|
||||
$("form input[name=ix]").val(item.id);
|
||||
//$("#ix").val("");
|
||||
this.$element[0].value = item.name;
|
||||
this.$element[0].form.submit();
|
||||
return item.name;
|
||||
},
|
||||
autoselect: true,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type='text/javascript'>
|
||||
$(function() {
|
||||
$('#ix').change(function() {
|
||||
var name = $(this).find(':selected')[0].text;
|
||||
$('#name_ix').val(name);
|
||||
this.form.submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
88
src/Views/pages/ixstats/search.html.twig
Normal file
88
src/Views/pages/ixstats/search.html.twig
Normal file
@ -0,0 +1,88 @@
|
||||
{% extends "base/base.html.twig" %}
|
||||
{% import "macros/macros.html.twig" as macro %}
|
||||
|
||||
{% block refresh %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}
|
||||
IX Stats
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content_wrapper %}
|
||||
{% set title = "IX Stats" %}
|
||||
{{ macro.content_header(title, "", 'NONE' ) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
{% if config.my_asn %}
|
||||
<div class="col-md-12 col-lg-6">
|
||||
{{ include('/pages/ixstats/_myix.html.twig') }}
|
||||
</div>
|
||||
<div class="col-md-12 col-lg-6">
|
||||
{{ include('/pages/ixstats/_allix.html.twig') }}
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col-md-12">
|
||||
{{ include('/pages/ixstats/_allix.html.twig') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block modal %}
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script src="{{ global.request.baseUrl }}/template/bower_components/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="{{ global.request.baseUrl }}/template/plugins/typeahead/bootstrap3-typeahead.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#peeringdb').typeahead({
|
||||
source: function (query, process) {
|
||||
$.ajax({
|
||||
url: '{{ path('get_ixname') }}',
|
||||
dataType: 'JSON',
|
||||
minLength: 2,
|
||||
data: 'name=' + query,
|
||||
success: function(data) {
|
||||
if ( data !== null ) {
|
||||
process(data);
|
||||
} else {
|
||||
$("#message").html('<small class="form-text text-muted">No IX found.</small>');
|
||||
}
|
||||
},
|
||||
beforeSend: function () {
|
||||
$("#peeringdb").addClass("searchBox");
|
||||
},
|
||||
complete: function () {
|
||||
$("#peeringdb").removeClass("searchBox");
|
||||
},
|
||||
});
|
||||
},
|
||||
updater : function (item) {
|
||||
$("form input[name=ix]").val(item.id);
|
||||
//$("#ix").val("");
|
||||
this.$element[0].value = item.name;
|
||||
this.$element[0].form.submit();
|
||||
return item.name;
|
||||
},
|
||||
autoselect: true,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type='text/javascript'>
|
||||
$(function() {
|
||||
$('#ix').change(function() {
|
||||
var name = $(this).find(':selected')[0].text;
|
||||
$('#name_myix').val(name);
|
||||
this.form.submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
BIN
web/images/ajax-loader.gif
Executable file
BIN
web/images/ajax-loader.gif
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
1
web/template/plugins/typeahead/bootstrap3-typeahead.min.js
vendored
Normal file
1
web/template/plugins/typeahead/bootstrap3-typeahead.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user