mirror of
https://github.com/nidebr/as-stats-gui.git
synced 2025-02-20 11:23:18 +08:00
save
This commit is contained in:
parent
72a24ec46c
commit
b76ee94a83
@ -4,8 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Exception\ConfigErrorException;
|
||||
use App\Exception\KnownLinksEmptyException;
|
||||
use App\Repository\KnowlinksRepository;
|
||||
use App\Util\Annotation\Menu;
|
||||
use App\Util\GetStartEndGraph;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
@ -17,16 +20,28 @@ class LinksUsageController extends BaseController
|
||||
{
|
||||
protected array $data = [];
|
||||
|
||||
/**
|
||||
* @throws ConfigErrorException
|
||||
* @throws KnownLinksEmptyException
|
||||
*/
|
||||
#[Route(
|
||||
path: '/',
|
||||
name: 'links.usage',
|
||||
methods: ['GET'],
|
||||
)]
|
||||
public function index(): Response
|
||||
{
|
||||
public function index(
|
||||
GetStartEndGraph $getStartEndGraph,
|
||||
): Response {
|
||||
$this->base_data['content_wrapper']['titre'] = \sprintf(
|
||||
'Top %s AS - per link usage (%s)',
|
||||
$this->configApplication::getLinksUsageTop(),
|
||||
'24 hours'
|
||||
);
|
||||
|
||||
return $this->render('pages/link_usage/index.html.twig', [
|
||||
'base_data' => $this->base_data,
|
||||
'knownlinks' => KnowlinksRepository::get(),
|
||||
'data' => $getStartEndGraph->get(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,14 @@ class RRDLinksUsageRepository
|
||||
$i = 0;
|
||||
|
||||
foreach ($this->topas['asinfo'] as $as => $value) {
|
||||
if (ConfigApplication::getAsStatsConfigGraph()['outispositive'] && ConfigApplication::getAsStatsConfigGraph()['brighten_negative']) {
|
||||
$col = \sprintf('%sBB', $this->colors[$i]);
|
||||
} else {
|
||||
$col = $this->colors[$i];
|
||||
}
|
||||
|
||||
$descr = \str_replace(':', '\:', $value['info']['description']); // Escaping colons in description
|
||||
$cmd .= \sprintf('AREA:as%1$s_%2$sin_bits#%3$s:"AS%1$s (%4$s)\\n"', $as, $this->v6, $this->colors[$i], $descr);
|
||||
$cmd .= \sprintf('AREA:as%1$s_%2$sin_bits#%3$s:"AS%1$s (%4$s)\\n"', $as, $this->v6, $col, $descr);
|
||||
|
||||
if ($i > 0) {
|
||||
$cmd .= ':STACK';
|
||||
@ -81,7 +87,13 @@ class RRDLinksUsageRepository
|
||||
$i = 0;
|
||||
|
||||
foreach ($this->topas['asinfo'] as $as => $value) {
|
||||
$cmd .= \sprintf('AREA:as%s_%sout_bits#%s:', $as, $this->v6, $this->colors[$i]);
|
||||
if (ConfigApplication::getAsStatsConfigGraph()['outispositive'] || !ConfigApplication::getAsStatsConfigGraph()['brighten_negative']) {
|
||||
$col = $this->colors[$i];
|
||||
} else {
|
||||
$col = \sprintf('%sBB', $this->colors[$i]);
|
||||
}
|
||||
|
||||
$cmd .= \sprintf('AREA:as%s_%sout_bits#%s:', $as, $this->v6, $col);
|
||||
|
||||
if ($i > 0) {
|
||||
$cmd .= ':STACK';
|
||||
|
@ -21,7 +21,7 @@ class GenGraphExtension extends AbstractExtension
|
||||
{
|
||||
return [
|
||||
new TwigFunction('gen_graph', [$this, 'genGraph'], ['is_safe' => ['html']]),
|
||||
//new TwigFunction('gen_graph_linkusage', [$this, 'genGraphLinkUsage'], ['is_safe' => ['html']]),
|
||||
new TwigFunction('gen_graph_linkusage', [$this, 'genGraphLinksUsage'], ['is_safe' => ['html']]),
|
||||
];
|
||||
}
|
||||
|
||||
@ -56,4 +56,32 @@ class GenGraphExtension extends AbstractExtension
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function genGraphLinksUsage(
|
||||
string $link,
|
||||
int $ipversion,
|
||||
string $title,
|
||||
int $start,
|
||||
int $end,
|
||||
?int $width = null,
|
||||
?int $height = null,
|
||||
): string {
|
||||
return \sprintf(
|
||||
'<img alt="Graph IPv%s for Link %s" src="%s">',
|
||||
$ipversion,
|
||||
$link,
|
||||
$this->router->generate(
|
||||
'render.links.usage.graph',
|
||||
[
|
||||
'link' => $link,
|
||||
'v' => $ipversion,
|
||||
'title' => $title,
|
||||
'start' => $start,
|
||||
'end' => $end,
|
||||
'width' => $width,
|
||||
'height' => $height,
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,34 @@
|
||||
{% extends "base/_layout.html.twig" %}
|
||||
|
||||
{% block content %}
|
||||
dede
|
||||
<div class="row row-cards">
|
||||
{% for link in knownlinks %}
|
||||
<div class="col-lg-6 col-sm-12">
|
||||
<div class="space-y">
|
||||
{% embed 'core/card_history.html.twig' with {link: link, data: data} only %}
|
||||
{% block title %}
|
||||
{{ link.descr }}
|
||||
{% endblock %}
|
||||
|
||||
{% block graph %}
|
||||
<div class="row">
|
||||
<div class="space-y">
|
||||
<div class="col-12">
|
||||
{% set title_v4 = "#{link.descr} - IPv4" %}
|
||||
<div class="text-center">{{ gen_graph_linkusage(link.tag, 4, title_v4, data.start, data.end) }}</div>
|
||||
</div>
|
||||
{% if configapplication_graph('showv6') %}
|
||||
<div class="col-12">
|
||||
{% set title_v6 = "#{link.descr} - IPv6" %}
|
||||
<div class="text-center">{{ gen_graph_linkusage(link.tag, 6, title_v6, data.start, data.end) }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user