]> git.pld-linux.org Git - projects/pld-ftp-admin.git/commitdiff
Add filter-out feature to rpmqa query page (adamg?)
authorJan Rękorajski <baggins@pld-linux.org>
Sat, 16 Jan 2021 19:57:11 +0000 (20:57 +0100)
committerJan Rękorajski <baggins@pld-linux.org>
Sat, 16 Jan 2021 19:57:11 +0000 (20:57 +0100)
html/qa.php

index a24416e9c9f031bb2f7a2080a54a19f60ed6a33a..4a74ff30d4ca1bfba961cbc9b4fc98124c41c864 100644 (file)
@@ -1,42 +1,20 @@
-<html>
+<!doctype html>
+<html lang='en'>
 <head>
 <link rel="Shortcut Icon" href="//www.pld-linux.org/favicon.ico"/>
        <title>PLD QA Reports</title>
        <link rel="stylesheet" type="text/css" charset="utf-8" media="all" href="//srcbuilder.pld-linux.org/th/style.css">
        <style>
-       .hidden { display: none; }
-       span#count { font-weight: bold; }
+               .hidden { display: none; }
+               span#count { font-weight: bold; }
        </style>
 </head>
-<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
-<script>
-jQuery(function($) {
-       $('#q').on('change', function(e) {
-               var el = e.target;
-               var o = el.options;
-               var v = o[o.selectedIndex].value;
-               location.href = "?q=" + v;
-       });
-
-       var $lines = $('#lines>li');
-       var $count = $('#count');
-       $('#filter').on('keyup', function() {
-               var search = $(this).val();
-               var count = 0;
-               $lines.each(function() {
-                       var $line = $(this);
-                       var text = $line.text();
-                       var fn = text.match(search) && ++count ? 'removeClass' : 'addClass';
-                       $line[fn]('hidden');
-               });
-               $count.html(count);
-       });
-       $count.html($lines.length);
-});
-</script>
 <body>
 <?php
 
+// (c) -2019 PLD developers
+// filter-out feature - adamg
+
 $report = isset($_GET['q']) ? basename($_GET['q']) : null;
 $reports = array(
        "main" => "Main deps x86_64",
@@ -72,7 +50,8 @@ function reports_selection($reports) {
  * Create text input for filtering results
  */
 function filter_box() {
-       echo '<br>Filter results: <input id="filter">';
+       echo '<br>Filter results: <input id="filter" class="filter">';
+       echo '<br>Filter-out (grep -v) <input id="filter_out" class="filter">';
        echo '<br><span id="count">?</span> errors';
 }
 
@@ -99,5 +78,40 @@ if (isset($reports[$report])) {
 }
 
 ?>
+<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
+<script>
+jQuery(function($) {
+       $('#q').on('change', function(e) {
+               var el = e.target;
+               var o = el.options;
+               var v = o[o.selectedIndex].value;
+               location.href = "?q=" + v;
+       });
+
+       var $lines = $('#lines>li');
+       var $count = $('#count');
+       $('.filter').on('keyup', function() {
+               var filter_in = $('#filter').val();
+               var filter_out = $('#filter_out').val().trim();
+               var do_filter_out = filter_out.length > 0;
+               var count = 0;
+               $lines.each(function() {
+                       var $line = $(this);
+                       var text = $line.text();
+                       // everything is visible by default
+                       $line.removeClass('hidden');
+                       count++;
+                       // but we hide lines that do not match filter
+                       // OR match non-empty filter-out
+                       if ( ! text.match(filter_in) || (do_filter_out && text.match(filter_out)) ) {
+                               $line.addClass('hidden');
+                               count--;
+                       }
+               });
+               $count.html(count);
+       });
+       $count.html($lines.length);
+});
+</script>
 </body>
 </html>
This page took 0.274877 seconds and 4 git commands to generate.