Browse Source

Se agrega link al mapa y se añade estilo al popup del mapa.

Maximiliano Schvindt 7 years ago
parent
commit
ae7f76539e

+ 1 - 1
app/Resources/geoserverStyles/onuRxPower.xml

@@ -261,7 +261,7 @@
                 <Mark>
                   <WellKnownName>circle</WellKnownName>
                   <Fill>
-                    <CssParameter name="fill">#c2fdde</CssParameter>
+                    <CssParameter name="fill">#ffa732</CssParameter>
                   </Fill>
                 </Mark>
               <Size>7</Size>

+ 3 - 3
src/StatsBundle/Admin/OnuAdmin.php

@@ -88,9 +88,9 @@ class OnuAdmin extends BaseAdmin
     public function configureActionButtons($action, $object = null)
     {
         $actions = parent::configureActionButtons($action, $object);
-        //$actions['update_devices'] = array(
-        //    'template' => 'StatsBundle:Device:update_devices_button.html.twig',
-        //);
+        $actions['show_in_map'] = array(
+            'template' => 'StatsBundle:Onu:map_button.html.twig',
+        );
 
         return $actions;
     }

+ 0 - 4
src/StatsBundle/Controller/StatsController.php

@@ -160,10 +160,6 @@ class StatsController extends Controller
 
         $map = array('lat' => $lat, 'lng' => $lng, 'zoom' => $zoom);
 
-        /* print_r("<pre>");
-        print_r($data);
-        die; */
-
         return $this->render('StatsBundle:Stats:onu_map.html.twig', array(
             'base_template' => $adminPool->getTemplate('layout'),
             'admin_pool' => $adminPool,

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

@@ -86,4 +86,5 @@ Statistics: Estadísticas
 macroFields:
     notavailable: 'NULL'
 List: Listados
-ONU: ONU
+ONU: ONU
+link_action_show_onu_in_map: Ver en Mapa

+ 6 - 0
src/StatsBundle/Resources/views/Onu/map_button.html.twig

@@ -0,0 +1,6 @@
+<li>
+    <a class="sonata-action-element" href="{{ path('onu_stats_map') }}">
+        <i class="fa fa-map-marker" aria-hidden="true"></i>
+        {{ 'link_action_show_onu_in_map'|trans({}, 'StatsBundle') }}
+    </a>
+</li>

+ 53 - 2
src/StatsBundle/Resources/views/Stats/onu_map.html.twig

@@ -174,7 +174,7 @@ function initializeMap() {
         zIndex: 99,
 		maxZoom: 24,
         styles: 'onuStatus'
-	});
+	}).addTo(window.map);
     
     var extraLayers = L.control.layers({
         "TX": layerGeoTx,
@@ -189,8 +189,20 @@ function initializeMap() {
 function customPopupFeature(latlng, content) {
     
     id = content.id;
+
+    if(content.status == 1) {status = "On";} else {status = "Off";}
+    if(content.rx == 0) {rx = "-";} else {rx = content.rx;}
+    if(content.tx == 0) {tx = "-";} else {tx = content.tx;}
+    if(content.volt == 0) {volt = "-";} else {volt = content.volt;}
+    if(content.temp == 0) {temp = "-";} else {temp = content.temp;}
+
     ponSerialNumber = id.replace("onu.", "").toUpperCase();
-    data = "<b>" + ponSerialNumber + "</b><br /> Tx: " + content.tx + "<br /> Rx: " + content.rx + "<br /> Status: " + content.status  + "<br /> Voltage: " + content.volt + "<br /> Temperature: " + content.temp + "<br /> Muestreo: " + content.muestreo;
+    data = "<b>" + ponSerialNumber + "</b><br /> Tx: <span class='"+txStyle(content.tx)+"'>" + tx + 
+           "</span> dBm<br /> Rx: <span class='"+rxStyle(content.rx)+"'>" + rx + 
+           "</span> dBm<br /> Status: " + status  + 
+           "<br /> Voltage: " + volt + 
+           " V<br /> Temperature: " + temp + 
+           " ºC<br /> Muestreo: " + content.muestreo;
     
     popup = L.popup()
         .setLatLng(latlng)
@@ -199,6 +211,45 @@ function customPopupFeature(latlng, content) {
 
 }
 
+function rxStyle(value) {
+
+    style = "rx_ftth_bordo";
+
+    if (value >= -30 && value < -28) {
+        style = "rx_ftth_rojo";
+    } else if (value >= -28 && value < -26) {
+        style = "rx_ftth_amarillo";
+    } else if (value >= -26 && value < -20) {
+        style = "rx_ftth_verde";
+    } else if (value >= -20 && value < -15) {
+        style = "rx_ftth_amarillo";
+    } else if (value >= -15 && value < -13) {
+        style = "rx_ftth_rojo";
+    }
+
+    return style; 
+
+}
+
+function txStyle(value) {
+
+    style = "tx_ftth_bordo";
+
+    if (value < 1) {
+        style = "tx_ftth_bordo";
+    } else if (value >= 1 && value < 1.5) {
+        style = "tx_ftth_amarillo";
+    } else if (value >= 1.5 && value < 3.5) {
+        style = "tx_ftth_verde";
+    } else if (value >= 3.5 && value < 4.5) {
+        style = "tx_ftth_amarillo";
+    } else if (value >= 4.5 && value < 5) {
+        style = "tx_ftth_rojo";
+    } 
+
+    return style;
+}
+
 /* --------------------- Funciones ------------------------- */
 </script>
 {% endblock %}