]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 24 Jun 2023 10:37:13 +0000 (12:37 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 24 Jun 2023 10:37:13 +0000 (12:37 +0200)
- count all found records, output message if requested amount is same
- renamed template variable blocks -> blocklist so it is the same as in api.py

api.py
templates/base.html
templates/views/scoreboard.html
templates/views/top.html

diff --git a/api.py b/api.py
index 3e0e8251ff5ff473aca5295a47b2161352bbc3cf..3710197a39fe0cc1b3c60a478c1789945fcbbef4 100644 (file)
--- a/api.py
+++ b/api.py
@@ -285,18 +285,21 @@ def top(request: Request, mode: str, value: str, amount: int = 500):
     if response is not None:
         blocklist = response.json()
 
+    found = 0
     for block_level in blocklist:
         for block in blocklist[block_level]:
             block["first_seen"] = datetime.utcfromtimestamp(block["first_seen"]).strftime(config.get("timestamp_format"))
             block["last_seen"]  = datetime.utcfromtimestamp(block["last_seen"]).strftime(config.get("timestamp_format"))
+            found = found + 1
 
     return templates.TemplateResponse("views/top.html", {
-        "request": request,
-        "mode"   : mode if response is not None else None,
-        "value"  : value if response is not None else None,
-        "amount" : amount if response is not None else None,
-        "blocks" : blocklist,
-        "info"   : info,
+        "request"  : request,
+        "mode"     : mode if response is not None else None,
+        "value"    : value if response is not None else None,
+        "amount"   : amount if response is not None else None,
+        "found"    : found,
+        "blocklist": blocklist,
+        "info"     : info,
     })
 
 @router.get(config.get("base_url") + "/rss")
index 485eb445d867947fabfa4d4a2686332bcac6e66a..26e3fae538943047ffb413cd9f9ca9689b8347f4 100644 (file)
@@ -91,7 +91,7 @@
             min-width: 50%;
             width: 50em;
         }
-        .notes {
+        .notice {
             margin-left: auto;
             margin-right: auto;
             margin-bottom: 20px;
             border: 1px solid #eaeaea;
             border-radius: 5px;
         }
-        .notes > div {
+        .notice > div {
             margin: 0px;
             padding: 5px;
         }
-        .notes > h2 {
+        .notice > h2 {
             margin: 0px;
             padding: 5px;
             background-color: #eaeaea;
index b8449ad4fbc3896209b1a7a929aafe7be2efde72..ba54fbd1818cf12280d63302c806c3aa64a90734 100644 (file)
 
 {% block footer %}
     {% if mode == 'error_code' %}
-        <div class="notes">
+        <div class="notice">
             <h2>Error codes:</h2>
             <ul>
                 <li>Error code 999 is fake and covers a lot of reasons why the domain/instance is not reachable. Mostly that the domain is not resolvable or the server refused connection.</li>
             </ul>
         </div>
     {% elif mode == 'detection_mode' %}
-        <div class="notes">
+        <div class="notice">
             <h2>Detection modes:</h2>
             <div>
                 Detection is done in following order:
@@ -85,7 +85,7 @@
             </ol>
         </div>
     {% elif mode == 'obfuscation' %}
-        <div class="notes">
+        <div class="notice">
             <h2>Obfuscation status:</h2>
             <ul>
                 <li>Only supported networks are counted here.</li>
index c18da52000f202b9623aef4a340080c9427c11aa..82acd71f94e9fb3526962e3d979b5593f027be22 100644 (file)
 {% endblock %}
 
 {% block content %}
-    {% for block_level in blocks %}
+    {% if amount == found %}
+        <div class="notice">
+            <h2>Maximum amount reached!</h2>
+            <div>
+                Please note that the maximum allowed amount is only returned, the blocker/blocked/reason might be more.
+                Paging support is not finished yet.
+            </div>
+        </div>
+    {% endif %}
+
+    {% for block_level in blocklist %}
         <div class="block_level" id="{{block_level}}">
-            <h2>{{block_level}} ({{blocks[block_level]|length}})</h2>
+            <h2>{{block_level}} ({{blocklist[block_level]|length}})</h2>
             <table>
                 <thead>
                     <th>Blocker</th>
@@ -35,7 +45,7 @@
                 </thead>
 
                 <tbody>
-                {% for block in blocks[block_level] %}
+                {% for block in blocklist[block_level] %}
                     <tr>
                         <td>
                             {% with domain=block['blocker'] %}