Explorar o código

FD3-672 se agrega límite de paquetes de kea

Espinoza Guillermo %!s(int64=6) %!d(string=hai) anos
pai
achega
4ebdd86436

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

@@ -83,3 +83,4 @@ kea_packet_list: Ver paquetes
 Filter: Filtro
 Packets: Paquetes
 kea_packet_list_help: Por defecto se muestran los últimos 100 paquetes de KEA
+insert a number upper to 100: Ingrese un número mayor a 100

+ 19 - 5
src/KeaBundle/Resources/views/Packet/list.html.twig

@@ -22,10 +22,12 @@
     
     client.onreceive = function(m) {};
     
+    var max_packets = 100;
+        
     var on_connect = function(x) {
       id = client.subscribe("/queue/kea", function(m) {
-          if ($('#tbody tr').length >= 100) {
-              $('#tbody tr:last').remove();
+          if ($('#tbody tr').length >= max_packets) {
+              $('#tbody td:not(:contains("' + $filter + '"))').last().parent('tr').remove();
           }
 
           $('#tbody').prepend($("<tr>").append($('<td class="sonata-ba-list-field sonata-ba-list-field-text td-bordered">').text(m.body)));
@@ -52,7 +54,7 @@
         var $filter = $('#filter').val();
         
         if ($filter.length >= 3) {
-            $('#tbody td:not(:contains("'+$filter+'"))').hide();
+            $('#tbody td:not(:contains("' + $filter + '"))').hide();
         } else {
             $('#tbody td').show();
         }
@@ -67,7 +69,14 @@
             e.preventDefault();
             
             return false;
-            
+        });
+        
+        $('#max_packets').on('change', function() {
+            var $value = parseInt($(this).val(), 10);
+            if ($value && $value >= 100) {
+                max_packets = $value;
+                console.log('max packets', max_packets);
+            }
         });
     });
 </script>
@@ -117,8 +126,13 @@
                         {{ 'Filter'|trans({}, 'KeaBundle') }}
                     </h4>
                     <form style="float: left;">
-                        <input id="filter" autocomplete="off"></input>
+                        <input id="filter" style="width: 220px;" autocomplete="off"></input>
                     </form>
+                    <br /><br />
+                    <h4 class="box-title" style="float: left; margin-right: 5px;">
+                        {{ 'Packets'|trans({}, 'KeaBundle') }}
+                    </h4>
+                    <input id="max_packets" min="100" max="1000" style="width: 220px;" type="number" value=100 placeholder="{{ 'insert a number upper to 100'|trans({}, 'KeaBundle') }}" title="{{ 'insert a number upper to 100'|trans({}, 'KeaBundle') }}">
                 </div>
             </div>
         </div>