浏览代码

FD3-634 Se actualiza selector de período del STAR

Maxi Schvindt 6 年之前
父节点
当前提交
53b600087c

+ 63 - 5
src/StatsBundle/Controller/StatsController.php

@@ -1843,11 +1843,11 @@ class StatsController extends Controller
         return $days;
     }
 
-     /**
-     * @Route("/admin/stats/star/getjson", name="star_get_json")
-     *
-     * @return string
-     */
+    /**
+    * @Route("/admin/stats/star/getjson", name="star_get_json")
+    *
+    * @return string
+    */
     public function starGetJson(Request $request)
     {
         
@@ -1864,5 +1864,63 @@ class StatsController extends Controller
 
         return new JsonResponse($series);
     }
+    
+    /**
+    * @Route("/admin/stats/star/getxls", name="star_get_xls")
+    *
+    * @return string
+    */
+    public function starGetXls(Request $request)
+    {
+        
+        ($request->get('from'))? $from = date("Y-m-d", $request->get('from')) : $from = date("Y-m-d",strtotime("-12 hour"));
+        ($request->get('to'))? $to = date("Y-m-d", $request->get('to')) : $to = date("Y-m-d",strtotime("now"));
+        
+        $server = $request->get('server');
+        $fatherDevice = $request->get('fatherDevice');
+        $fatherDeviceType = $request->get('fatherDeviceType');
+        $device = $request->get('device');
+
+
+        $series = $this->getConsumptionDevice($server,$fatherDevice,$fatherDeviceType,$device,$from,$to);
+
+        
+        $header = 
+                "<tr>
+                    <th>date</th>
+                    <th>in</th>
+                    <th>out</th>
+                    <th>total</th>
+                    <th>accumulated</th>
+                </tr>
+                ";
+        
+        $tbody = "";
+        foreach($series['categories'] as $index => $value) {
+            $tbody .= "
+                    <tr>
+                        <td>{$index}</td>
+                        <td>{$series['in'][$index]}</td>
+                        <td>{$series['out'][$index]}</td>
+                        <td>{$series['total'][$index]}</td>
+                        <td>{$series['accumulated'][$index]}</td>
+                    </tr>
+            ";
+        }
+
+        $data = 
+        "<table>
+            {$header}
+            {$tbody}
+        </table>
+        ";
+        
+
+        header ( "Content-type: application/vnd.ms-excel" );
+        header ( "Content-Disposition: attachment; filename=data.xls" );
+
+        echo $data;
+        die;
+    }
 
 }

+ 4 - 0
src/StatsBundle/Resources/public/css/style.css

@@ -107,4 +107,8 @@
 
 .green-value {
     color:#3f6833;
+}
+
+a.pickerXlsSlaButton:hover {
+    color: white!important;
 }

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

@@ -337,10 +337,11 @@ msg_no_enable_geoserver_service: El servicio Geoserver no se encuentra habilitad
 no_defined: No reportado
 link_action_reload_show_stats: Recargar por problema de conexión
 link_action_edit_location: Modificar/Añadir ubicación
-consumption_info_evolution: Evolución del consumo mensual y porcentaje de utilización. El valor se reinicia con el comienzo de un nuevo mes.
+consumption_info_evolution: Evolución del consumo acumulado, el mismo puede mostrar reinicios debido al contador o tiempo de inactividad del dispositivo. Para obtener valores acumulados por período se encuentra el módulo STAR
 nas_data_origen: Salvo OLT Huawei, estos valores se obtienen desde el NAS, consultar sobre la ejecución de los comandos de estadísticas sobre el mismo.
 picker_find: Buscar
 picker_find_star: Buscar STAR
+picker_download_star: Descargar xls
 rx_tx_title: Tx & Rx
 cablemodems_with_lat_lng: cablemodems geolocalizados
 interface_cms_map_title: RX de cablemodems en la Interface

+ 19 - 0
src/StatsBundle/Resources/views/Stats/Template/load_svg.html.twig

@@ -0,0 +1,19 @@
+<svg id="loader" style="display:none; float:left" class="lds-polar" width="35px" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid"><g transform="translate(50 50)"><g transform="scale(0.8780218186353332)">
+<path d="M0 0L0 -40A40 40 0 0 1 34.64101615137754 -20.000000000000004" transform="rotate(0 0 0)" stroke="none" fill="#1d3f72"></path>
+<animateTransform attributeName="transform" type="scale" values="0.8780218186353332;0.884786130589434;0.5342315887395934;0.17453079196443083;0.7159374117286236;0.8780218186353332" keyTimes="0;0.2;0.4;0.6;0.8;1" dur="1.5s" repeatCount="indefinite"></animateTransform>
+</g><g transform="scale(0.02223813056279795)">
+<path d="M0 0L0 -40A40 40 0 0 1 34.64101615137754 -20.000000000000004" transform="rotate(60 0 0)" stroke="none" fill="#5699d2"></path>
+<animateTransform attributeName="transform" type="scale" values="0.02223813056279795;0.37084029868553225;0.5828480347836038;0.15066733799945028;0.6942832732116193;0.17457184787393654;0.02223813056279795" keyTimes="0;0.16666666666666666;0.3333333333333333;0.5;0.6666666666666666;0.8333333333333334;1" dur="1.5s" repeatCount="indefinite"></animateTransform>
+</g><g transform="scale(0.6764099251986221)">
+<path d="M0 0L0 -40A40 40 0 0 1 34.64101615137754 -20.000000000000004" transform="rotate(120 0 0)" stroke="none" fill="#d8ebf9"></path>
+<animateTransform attributeName="transform" type="scale" values="0.6764099251986221;0.013125369880694618;0.35026957404081177;0.4762044726228394;0.7637378542310113;0.6764099251986221" keyTimes="0;0.2;0.4;0.6;0.8;1" dur="1.5s" repeatCount="indefinite"></animateTransform>
+</g><g transform="scale(0.5878860631237611)">
+<path d="M0 0L0 -40A40 40 0 0 1 34.64101615137754 -20.000000000000004" transform="rotate(180 0 0)" stroke="none" fill="#71c2cc"></path>
+<animateTransform attributeName="transform" type="scale" values="0.5878860631237611;0.9870877544948929;0.17696236773061805;0.5878860631237611" keyTimes="0;0.3333333333333333;0.6666666666666666;1" dur="1.5s" repeatCount="indefinite"></animateTransform>
+</g><g transform="scale(0.3664762972995939)">
+<path d="M0 0L0 -40A40 40 0 0 1 34.64101615137754 -20.000000000000004" transform="rotate(240 0 0)" stroke="none" fill="#1d3f72"></path>
+<animateTransform attributeName="transform" type="scale" values="0.3664762972995939;0.2672683449487724;0.3664762972995939" keyTimes="0;0.5;1" dur="1.5s" repeatCount="indefinite"></animateTransform>
+</g><g transform="scale(0.4869928171688228)">
+<path d="M0 0L0 -40A40 40 0 0 1 34.64101615137754 -20.000000000000004" transform="rotate(300 0 0)" stroke="none" fill="#5699d2"></path>
+<animateTransform attributeName="transform" type="scale" values="0.4869928171688228;0.8339110034839239;0.3943009866896828;0.4869928171688228" keyTimes="0;0.3333333333333333;0.6666666666666666;1" dur="1.5s" repeatCount="indefinite"></animateTransform>
+</g></g></svg>

+ 1 - 1
src/StatsBundle/Resources/views/Stats/Template/star_accumulated_last_value.html.twig

@@ -4,7 +4,7 @@
     {% set limit = remoteData['profile_limit'] %}
 {% else %}
     {% set profile_limit = false %}
-    {% set limit = 800 %}
+    {% set limit = 350 %}
 {% endif %}
 
 {% set total = star['accumulated_last']|number_format(3,'.','') %}

+ 36 - 53
src/StatsBundle/Resources/views/Stats/picker-sla.html.twig

@@ -1,54 +1,30 @@
-{# <form method="post" name="form" id="picker-form"> #}
-    <div class="container" style="width: 530px; padding: 0px 10px">
-            <div class="form-group picker" style="width:25%">
-                <div class='input-group date' id='sla-datetimepicker6'>
-                    <input type="text" class="form-control" style="border-color: #605ca8"/>
-                    
-                    <span class="input-group-addon calendar-icon" style="border-color: #605ca8">
-                        <span class="glyphicon glyphicon-calendar"></span>
-                    </span>
-                </div>
-            </div>
-
-            <div class="form-group picker"  style="margin-left: 10px;width:25%">
-                <div class='input-group date' id='sla-datetimepicker7'>
-                    <input type="text" class="form-control" style="border-color: #605ca8"/>
-                    
-                    <span class="input-group-addon calendar-icon" style="border-color: #605ca8">
-                        <span class="glyphicon glyphicon-calendar"></span>
-                    </span>
-                </div>
-            </div>
-
-            <input name="from" id="sla-from-unixtime" type="hidden" class="form-control"/>
-            <input name="to" id="sla-to-unixtime" type="hidden" class="form-control"/>
-
-            <div class="form-group picker" style="width: 40%">
-                <button type="submit" id="pickerSlaButton" type="button" class="btn bg-purple btn-flat margin" style="margin: 0px 10px; float:left"><i class="fa fa-search" aria-hidden="true"></i>&nbsp;&nbsp;{{ 'picker_find_star'|trans({}, 'StatsBundle') }}</button>
-                {# <img src="{{ asset('bundles/stats/images/load3.gif') }}" style="float:left" /> #}
-                <svg id="loader" style="display:none; float:left" class="lds-polar" width="35px" height="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid"><g transform="translate(50 50)"><g transform="scale(0.8780218186353332)">
-                <path d="M0 0L0 -40A40 40 0 0 1 34.64101615137754 -20.000000000000004" transform="rotate(0 0 0)" stroke="none" fill="#1d3f72"></path>
-                <animateTransform attributeName="transform" type="scale" values="0.8780218186353332;0.884786130589434;0.5342315887395934;0.17453079196443083;0.7159374117286236;0.8780218186353332" keyTimes="0;0.2;0.4;0.6;0.8;1" dur="1.5s" repeatCount="indefinite"></animateTransform>
-                </g><g transform="scale(0.02223813056279795)">
-                <path d="M0 0L0 -40A40 40 0 0 1 34.64101615137754 -20.000000000000004" transform="rotate(60 0 0)" stroke="none" fill="#5699d2"></path>
-                <animateTransform attributeName="transform" type="scale" values="0.02223813056279795;0.37084029868553225;0.5828480347836038;0.15066733799945028;0.6942832732116193;0.17457184787393654;0.02223813056279795" keyTimes="0;0.16666666666666666;0.3333333333333333;0.5;0.6666666666666666;0.8333333333333334;1" dur="1.5s" repeatCount="indefinite"></animateTransform>
-                </g><g transform="scale(0.6764099251986221)">
-                <path d="M0 0L0 -40A40 40 0 0 1 34.64101615137754 -20.000000000000004" transform="rotate(120 0 0)" stroke="none" fill="#d8ebf9"></path>
-                <animateTransform attributeName="transform" type="scale" values="0.6764099251986221;0.013125369880694618;0.35026957404081177;0.4762044726228394;0.7637378542310113;0.6764099251986221" keyTimes="0;0.2;0.4;0.6;0.8;1" dur="1.5s" repeatCount="indefinite"></animateTransform>
-                </g><g transform="scale(0.5878860631237611)">
-                <path d="M0 0L0 -40A40 40 0 0 1 34.64101615137754 -20.000000000000004" transform="rotate(180 0 0)" stroke="none" fill="#71c2cc"></path>
-                <animateTransform attributeName="transform" type="scale" values="0.5878860631237611;0.9870877544948929;0.17696236773061805;0.5878860631237611" keyTimes="0;0.3333333333333333;0.6666666666666666;1" dur="1.5s" repeatCount="indefinite"></animateTransform>
-                </g><g transform="scale(0.3664762972995939)">
-                <path d="M0 0L0 -40A40 40 0 0 1 34.64101615137754 -20.000000000000004" transform="rotate(240 0 0)" stroke="none" fill="#1d3f72"></path>
-                <animateTransform attributeName="transform" type="scale" values="0.3664762972995939;0.2672683449487724;0.3664762972995939" keyTimes="0;0.5;1" dur="1.5s" repeatCount="indefinite"></animateTransform>
-                </g><g transform="scale(0.4869928171688228)">
-                <path d="M0 0L0 -40A40 40 0 0 1 34.64101615137754 -20.000000000000004" transform="rotate(300 0 0)" stroke="none" fill="#5699d2"></path>
-                <animateTransform attributeName="transform" type="scale" values="0.4869928171688228;0.8339110034839239;0.3943009866896828;0.4869928171688228" keyTimes="0;0.3333333333333333;0.6666666666666666;1" dur="1.5s" repeatCount="indefinite"></animateTransform>
-                </g></g></svg>
-                
-            </div>
+<div class="container" style="width: 630px; padding: 0px 10px">
+    <div class="form-group picker" style="width:130px">
+        <div class='input-group date' id='sla-datetimepicker6'>
+            <input type="text" class="form-control" style="border-color: #605ca8"/>
+            
+            <span class="input-group-addon calendar-icon" style="border-color: #605ca8">
+                <span class="glyphicon glyphicon-calendar"></span>
+            </span>
+        </div>
+    </div>
+    <div class="form-group picker"  style="margin-left: 10px;width:130px">
+        <div class='input-group date' id='sla-datetimepicker7'>
+            <input type="text" class="form-control" style="border-color: #605ca8"/>
+            
+            <span class="input-group-addon calendar-icon" style="border-color: #605ca8">
+                <span class="glyphicon glyphicon-calendar"></span>
+            </span>
+        </div>
     </div>
-{# </form> #}
+    <input name="from" id="sla-from-unixtime" type="hidden" class="form-control"/>
+    <input name="to" id="sla-to-unixtime" type="hidden" class="form-control"/>
+    <div class="form-group picker" style="width: 55%">
+        <button type="submit" id="pickerSlaButton" type="button" class="btn bg-purple btn-flat margin" style="margin: 0px 10px; float:left"><i class="fa fa-search" aria-hidden="true"></i>&nbsp;&nbsp;{{ 'picker_find_star'|trans({}, 'StatsBundle') }}</button>
+        <a target="_blanck" href="#" id="pickerXlsSlaButton" type="button" class="btn bg-purple btn-flat pickerXlsSlaButton" style="margin: 0px 10px; float:left"><i class="fa fa-cloud-download" aria-hidden="true"></i>&nbsp;&nbsp;{{ 'picker_download_star'|trans({}, 'StatsBundle') }}</a>
+        {% include '@Stats/Stats/Template/load_svg.html.twig' %}
+    </div>
+</div>
 
 <script type="text/javascript">
     var fromStar = {{fs}};
@@ -58,6 +34,7 @@
 
     $(function () {
 
+        setUrlXls();
         
         $('#sla-datetimepicker6').datetimepicker({
             defaultDate: new Date(fromStar * 1000),
@@ -75,11 +52,13 @@
             date = (e.date._d.getTime() / 1000).toFixed(0);
             parameters.from = date;
             $("#sla-from-unixtime").val(date);
+            setUrlXls();
         });
         $("#sla-datetimepicker7").on("dp.change", function (e) {
             date = (e.date._d.getTime() / 1000).toFixed(0);
             parameters.to = date;
             $("#sla-to-unixtime").val(date);
+            setUrlXls();
         });
         
     });
@@ -105,10 +84,13 @@
             $("#loader").hide();
             $('#pickerSlaButton').removeAttr('disabled');
         });
-    
-
     });
 
+    function setUrlXls() {
+        var url = "{{url('star_get_xls')}}?server="+parameters.server+"&fatherDevice="+parameters.fatherDevice+"&fatherDeviceType="+parameters.fatherDeviceType+"&device="+parameters.device+"&from="+parameters.from+"&to="+parameters.to;
+        $('#pickerXlsSlaButton').attr('href',url);
+    }
+
     function reloadDaily(serie) {
         $.each(serie, function(i, values){
             $("#daily_"+i+"_in").html(values.in);
@@ -137,7 +119,8 @@
         var chart = $('#cablemodem_star').highcharts();
         
         var array = $.map(series.categories, function(value, index) {
-            return [value.replace("'", "")];
+            var aux = value.replace("'", "");
+            return [aux.replace("'","")];
         });
 
         chart.xAxis[0].setCategories(array);