|
@@ -5,6 +5,8 @@ namespace StatsBundle\Controller;
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
|
|
use StatsBundle\Services\DeviceManager;
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
|
+use Symfony\Component\HttpFoundation\Request;
|
|
|
+use Symfony\Component\HttpFoundation\JsonResponse;
|
|
|
|
|
|
class StatsController extends Controller
|
|
|
{
|
|
@@ -23,4 +25,53 @@ class StatsController extends Controller
|
|
|
return $this->redirect($this->generateUrl('admin_stats_statsdevice_list'));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @Route("/admin/stats/stats/graph", name="stats_graph")
|
|
|
+ *
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function getStatsGraphAction(Request $request)
|
|
|
+ {
|
|
|
+// $deviceType = $request->get('deviceType','FTTHBundle\Entity\OLT');
|
|
|
+ $grafana_url = $this->getParameter('grafana_url');
|
|
|
+
|
|
|
+ // Puertos pon
|
|
|
+ $pons = array();
|
|
|
+ for ($x = 1; $x <= 8; $x++) {
|
|
|
+ for ($y = 1; $y <= 8; $y++) {
|
|
|
+ $index = "{$x}.{$y}";
|
|
|
+ $pons[$index] = "PON PORT $index";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for ($x = 11; $x <= 18; $x++) {
|
|
|
+ for ($y = 1; $y <= 8; $y++) {
|
|
|
+ $index = "{$x}.{$y}";
|
|
|
+ $pons[$index] = "PON PORT {$index}";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $panelIds = array(6, 4, 5, 1, 2, 3,);
|
|
|
+
|
|
|
+ $pon = '1.1';
|
|
|
+ if ($request->isMethod('POST')) {
|
|
|
+ $pon = $request->request->get('pon', $pon);
|
|
|
+ }
|
|
|
+ $urls = array('olt-total-rate?orgId=1&panelId=1',);
|
|
|
+ foreach ($panelIds as $panelId) {
|
|
|
+ $urls[] = "olt-pon-ports?orgId=1&panelId={$panelId}&var-ponport={$pon}";
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($request->isMethod('GET')) {
|
|
|
+ return $this->render('StatsBundle:Stats:graph.html.twig', array(
|
|
|
+ 'grafana_url' => $grafana_url,
|
|
|
+ 'urls' => $urls,
|
|
|
+ 'pons' => $pons,
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
+ return new JsonResponse(array(
|
|
|
+ 'urls' => $urls,
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
}
|