Explorar o código

Nueva gráfica en el apartado de reporte de OLT.

Maxi Schvindt %!s(int64=7) %!d(string=hai) anos
pai
achega
ddce883b34

+ 54 - 0
src/StatsBundle/Controller/OltReportController.php

@@ -338,5 +338,59 @@ class OltReportController extends Controller
             'results' => $results
         ));
     }
+
+    public function onuSignalAction($oltServerId, $oltDeviceId) {
+        
+        $em = $this->get('doctrine')->getManager();
+        $onus = $em->getRepository('StatsBundle:Onu')->createQueryBuilder('o')
+            ->select('o.txPower','o.rxPowerOlt', 'o.ponSerialNumber')
+            ->where('o.deviceServer = :oltServerId')
+            ->andWhere('o.oltDeviceId = :oltDeviceId')
+            ->setParameter('oltServerId', $oltServerId)
+            ->setParameter('oltDeviceId', $oltDeviceId)
+            ->getQuery()->getResult();
+        
+        $colors = $signals = array();
+
+        foreach($onus as $data) {
+            if($data['txPower'] == null || $data['rxPowerOlt'] == null) continue;
+
+            $color = $this->getRxColor($data['rxPowerOlt']);
+
+            if(!isset($signals[$color])) $signals[$color] = array();
+
+            $signals[$color][] = array('x' => $data['txPower'],'y' => $data['rxPowerOlt'], 'extraData' => $data['ponSerialNumber'], 'id' => "{$data['ponSerialNumber']}~{$oltDeviceId}~{$oltServerId}");
+            
+            //$colors[] = $this->getRxColor($data['rxPowerOlt']);
+        }
+        $_signals = array();
+        foreach($signals as $color => $points) {
+            $_signals[$color] = json_encode($points);
+        }
+
+
+        return $this->render('StatsBundle:Device:Report/onuSignal.html.twig', array(
+            'signals' => $_signals
+        ));
+    }
+
+    private function getRxColor($value) {
+
+
+        if($value < -30)
+            return "#a00400"; //bordó
+        elseif($value >= -30 and $value < -28)
+            return "#ff4d3f"; //rojo
+        elseif($value >= -28 and $value < -26)
+            return "#ffa732"; //amarillo
+        elseif($value >= -26 and $value < -20)
+            return "#00a65a"; //verde
+        elseif($value >= -20 and $value < -15)
+            return "#ffa732"; //amarillo
+        elseif($value >= -15 and $value < -13)
+            return "#ff4d3f"; //rojo
+        else
+            return "#a00400"; //bordó
+    }
     
 }

+ 1 - 0
src/StatsBundle/Resources/translations/StatsBundle.es.yml

@@ -214,3 +214,4 @@ olt_consumption: Consumo de OLT (en Gb)
 olt_report_no_data_found: No se encontraron puntos
 olt_reports: Alertas sobre la OLT (últimos 5 días)
 olt_report_no_alerts_found: No se encontraron alertas en los últimos 5 días
+onu_signals: Señal de ONU(TX Power, RX Power en OLT)

+ 65 - 0
src/StatsBundle/Resources/views/Device/Report/onuSignal.html.twig

@@ -0,0 +1,65 @@
+<div class="box box-widget">
+    <div class="box-header">
+        <div class="clearfix">
+            <div style="float:left">
+                <h4 class="box-title">{{ 'onu_signals'|trans({}, 'StatsBundle') }}
+                </h4>
+            </div>
+            <div id="onu-info" style="float:left; margin-left: 25px"></div>
+        </div>
+        <div class="box-tools pull-right">
+            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
+        </div>
+    </div>
+    <div class="box-body">
+        <canvas id="onu_signals"></canvas>
+    </div>
+</div>
+
+<script>
+    var scatterChart = new Chart($('#onu_signals'), {
+        type: 'scatter',
+        data: {
+            datasets: [
+                {% if signals|length > 0  %}
+                    {% for color,points in signals %}
+                    {
+                    data: {{points|raw}},
+                    backgroundColor: "{{color}}"
+                    },
+                    {% endfor %}
+                {% endif %}
+            ]
+        },
+        options: {
+            scales: {
+                xAxes: [{
+                    type: 'linear',
+                    position: 'bottom'
+                }]
+            },
+            legend: {
+                display: false
+            },
+            tooltips: {
+                custom: function(tooltipModel) {
+                    
+                    if(tooltipModel.dataPoints) {
+                        var datasetIndex = tooltipModel.dataPoints[0].datasetIndex;
+                        var index = tooltipModel.dataPoints[0].index;
+
+                        if(this._data.datasets[datasetIndex].data[index]) {
+                            var point = this._data.datasets[datasetIndex].data[index];
+                            console.log(point);
+                            var url = "{{url('admin_stats_onu_show',{id:'IDONU'})}}";
+                            url = url.replace('IDONU', point.id);
+                            console.log(url);
+                            var str = "<a href='"+url+"'>"+point.extraData.toUpperCase()+"</a>  "+point.x+"   >>   "+point.y;
+                            $("#onu-info").html(str);
+                        }
+                    }
+                }
+            }
+        }
+    });
+</script>

+ 11 - 2
src/StatsBundle/Resources/views/Device/report.html.twig

@@ -25,6 +25,9 @@
 {% block content %}
     {% set mark = data.mark %}
     <div class="box box-primary">
+
+        
+
         <br />
         <div class="box-body">
             <div class="col-sm-3">
@@ -50,10 +53,9 @@
                 }}
             </div>
             <div class="col-sm-6">
-                {{ render_hinclude(controller("StatsBundle:OltReport:ponBandwidth", {'oltServerId': device.getDeviceServer.getId(), 'oltDeviceId': device.getDeviceId()}),
+                {{ render_hinclude(controller("StatsBundle:OltReport:onuSignal", {'oltServerId': device.getDeviceServer.getId(), 'oltDeviceId': device.getDeviceId()}),
                     {'default':  include("@Stats/Device/Report/default.html.twig")})
                 }}
-            </div>
         </div>
         <div class="box-body">
             <div class="col-sm-6">
@@ -61,6 +63,13 @@
                     {'default':  include("@Stats/Device/Report/default.html.twig")})
                 }}
             </div>
+            <div class="col-sm-6">
+                {{ render_hinclude(controller("StatsBundle:OltReport:ponBandwidth", {'oltServerId': device.getDeviceServer.getId(), 'oltDeviceId': device.getDeviceId()}),
+                    {'default':  include("@Stats/Device/Report/default.html.twig")})
+                }}
+            </div>
+        </div>
+        <div class="box-body">
             <div class="col-sm-6">
                 {{ render_hinclude(controller("StatsBundle:OltReport:oltReport", {'oltServerId': device.getDeviceServer.getId(), 'oltDeviceId': device.getDeviceId()}),
                     {'default':  include("@Stats/Device/Report/default.html.twig")})