فهرست منبع

Se agrega listado con las últimas alertas o reportes de fallas para una
OLT. De momento son fallas de SNMP contra la OLT o falla de lectura en
el ENDPOINT.

Maximiliano Schvindt 7 سال پیش
والد
کامیت
d9b3d014fb

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

@@ -285,5 +285,42 @@ class OltReportController extends Controller
             }
         }
     }
+
+    public function oltReportAction($oltServerId, $oltDeviceId) {
+        
+        $em = $this->get('doctrine')->getManager();
+        
+        $reports = $em->getRepository('StatsBundle:Report')->createQueryBuilder('r')
+            ->select('r')
+            ->where('r.deviceServer = :oltServerId')
+            ->andWhere('r.deviceId = :oltDeviceId')
+            ->andWhere('r.deviceType = :deviceType')
+            ->andWhere('r.created >= :created')
+            ->setParameter('oltServerId', $oltServerId)
+            ->setParameter('oltDeviceId', $oltDeviceId)
+            ->setParameter('deviceType', 'FTTHBundle\Entity\OLT')
+            ->setParameter('created', date("Y-m-d 00:00:00",strtotime("-5 days")))
+            ->orderBy('r.id', 'DESC')
+            ->getQuery()->getResult();
+
+        $results = array();
+        foreach($reports as $report) {
+            $row = array();
+            $row['type'] = $report->getReportType();
+            $row['time'] = $report->getCreated()->format('Y-m-d H:i:s');
+            $aux = json_decode($report->getExtraData(),true);
+            if(isset($aux['msg'])) {
+                $row['msg'] = $aux['msg'];
+            } else {
+                continue;
+            }
+            $results[] = $row;
+        }
+
+
+        return $this->render('StatsBundle:Device:Report/reportList.html.twig', array(
+            'results' => $results
+        ));
+    }
     
 }

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

@@ -98,6 +98,9 @@ list:
     label_olt_mark: Marca
     label_olt_library: Librería
     label_olt_executeSnmp: Stats
+    label_report_type: Tipo
+    label_created: Fecha
+    label_msg: Mensaje
     
 help:
     url: Url a consultar dispositivos
@@ -138,4 +141,6 @@ pon_port_outBandwidth: OUT
 pon_port_totalBandwidth: Total
 pon_bandwidth: Top 10 - Bandwidth de PONPORT (en Mb)
 olt_consumption: Consumo de OLT (en Gb)
-olt_report_no_data_found: No se encontraron puntos
+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

+ 53 - 0
src/StatsBundle/Resources/views/Device/Report/reportList.html.twig

@@ -0,0 +1,53 @@
+
+<div class="box box-widget">
+    <div class="box-header">
+        <h4 class="box-title">{{ 'olt_reports'|trans({}, 'StatsBundle') }}</h4>
+        <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">
+        {% if results|length > 0  %}
+            <div class="col-sm-12">
+                <table id="reports" class="table table-bordered table-hover table-condensed table-striped" style="font-size:12px">
+                    <thead>
+                        <tr>
+                            <th>{{ 'list.label_created'|trans({}, 'StatsBundle') }}</th>
+                            <th>{{ 'list.label_report_type'|trans({}, 'StatsBundle') }}</th>
+                            <th>{{ 'list.label_msg'|trans({}, 'StatsBundle') }}</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        {% for data in results %}
+                            <tr>
+                                <td>{{ data.time }}</td>
+                                <td>{{ data.type }}</td>
+                                <td>{{ data.msg }}</td>
+                            </tr>
+                        {% endfor %}
+                    </tbody>
+                </table>
+            </div>
+
+            <script>
+              $(function () {
+                $('#reports').DataTable({
+                  'order': [[ 0, "desc" ]],
+                  'paging'      : true,
+                  'lengthChange': false,
+                  'searching'   : false,
+                  'ordering'    : false,
+                  'info'        : true,
+                  'autoWidth'   : false
+                })
+              })
+            </script>
+        {% else %}
+            <div class="alert alert-success alert-dismissible">
+                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
+                <h4><i class="icon fa fa-hand-peace-o"></i>OK!</h4>
+                {{ 'olt_report_no_alerts_found'|trans({}, 'StatsBundle') }}
+            </div>
+        {% endif %}
+    </div>
+</div>

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

@@ -1,10 +1,16 @@
 {% extends "@BaseAdminBundle/Resources/views/standard_layout.html.twig" %}
 
+{% block stylesheets %}
+{{ parent() }}
+<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
+{% endblock %}
+
 {% block javascripts %}
 {{ parent() }}
 <script src="{{ asset('bundles/baseadmin/report/hinclude.js') }}"></script>
 <script src="{{ asset('bundles/baseadmin/report/randomColor.js') }}"></script>
 <script src="{{ asset('bundles/baseadmin/report/chart.min.js') }}"></script>
+<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
 {% endblock %}
 
 {% block content %}
@@ -46,6 +52,11 @@
                     {'default':  include("@Stats/Device/Report/default.html.twig")})
                 }}
             </div>
+            <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")})
+                }}
+            </div>
         </div>
     </div>
 {% endblock %}