From 262a31e65a02301d659e3c0257b4c105366ff9be Mon Sep 17 00:00:00 2001 From: lelo Date: Wed, 2 Apr 2025 20:09:50 +0200 Subject: [PATCH] cleanup backend gui --- analytics.py | 13 +- templates/connections.html | 28 +- templates/dashboard.html | 687 +++++++++++++++++++------------------ templates/mylinks.html | 31 +- 4 files changed, 389 insertions(+), 370 deletions(-) diff --git a/analytics.py b/analytics.py index c569e28..eba9f28 100644 --- a/analytics.py +++ b/analytics.py @@ -145,13 +145,12 @@ def dashboard(): now = datetime.now() - # Determine which file type we're filtering by. + # default filetype if not found filetype = 'other' - # Some simplistic sets to decide how we match the MIME type - audio_list = ['mp3', 'wav', 'audio'] - image_list = ['jpg', 'jpeg', 'image', 'photo'] - video_list = ['mp4', 'mov', 'wmv', 'avi'] + audio_list = ['mp3', 'wav', 'ton', 'audio'] + image_list = ['jpg', 'jpeg', 'image', 'photo', 'bild', 'foto'] + video_list = ['mp4', 'mov', 'wmv', 'avi', 'film', 'video'] if session['filetype'].lower() in audio_list: filetype = 'audio/' @@ -292,9 +291,9 @@ def dashboard(): dict(bucket=r[0], count=r[1]) for r in timeframe_data_rows ] - # 4. User agent distribution + # 4. User agent distribution: Count user_agent once per device_id query = f''' - SELECT user_agent, COUNT(*) AS count + SELECT user_agent, COUNT(DISTINCT device_id) AS count FROM file_access_log WHERE timestamp >= ? {filetype_filter_sql} GROUP BY user_agent diff --git a/templates/connections.html b/templates/connections.html index a41dc15..6cc6b0d 100644 --- a/templates/connections.html +++ b/templates/connections.html @@ -1,7 +1,7 @@ - + Recent Connections @@ -11,13 +11,11 @@ margin: 0; padding: 0; } - /* Use full width */ .container-fluid { height: 100%; display: flex; flex-direction: column; } - /* Header area takes as much room as needed; the table container fills the rest */ .table-container { flex: 1; overflow-y: auto; @@ -25,17 +23,25 @@ -
-

Downloads in den letzten 10 Minute

-
- App - Meine Links - Verbindungen - Auswertung + + + +
- + diff --git a/templates/dashboard.html b/templates/dashboard.html index 9b9217f..e22f2a5 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -11,375 +11,382 @@ margin: 0; padding: 0; } - /* Use full width */ .container-fluid { height: 100%; display: flex; flex-direction: column; } - .card { margin-bottom: 20px; } + .card { + margin-bottom: 1.5rem; + } - -
-

Dashboard - Verbindungsanalyse ({{ timeframe }})

- - -
- + + + -
- -
-
-
-
-
Alle Downloads
-

{{ total_accesses }}

-
-
-
-
-
-
-
eindeutige Dateien
-

{{ unique_files }}

-
-
-
-
-
-
-
eindeutige Nutzer
-

{{ unique_user }}

-
-
-
-
-
-
-
beschleunigte Downloads
-

{{ cached_percentage }} %

-
-
-
-
- - -
- -
-
-
-
eindeutige Nutzer nach Zeit
- -
-
-
- -
-
-
-
Downloads nach Zeit
- -
-
-
- -
-
-
-
Verwendete Endgeräte
- -
-
-
- -
-
-
-
Verteilung auf Ordner
- -
-
-
-
- - -
-
- Verteilung der Zugriffe -
-
-
Timestamp IP Address
- - - - - - - - - {% for loc in location_data %} - - - - - {% else %} - - - - {% endfor %} - -
Anzahl DownloadsStadtLand
{{ loc.count }}{{ loc.city }}{{ loc.country }}
No access data available for the selected timeframe.
+ Select File Type + {% endif %} + + +
+
+ + +
+
+
+
+
Alle Downloads
+

{{ total_accesses }}

+
+
+
+
+
+
+
unterschiedliche Dateien
+

{{ unique_files }}

+
+
+
+
+
+
+
unterschiedliche Nutzer
+

{{ unique_user }}

+
+
+
+
+
+
+
beschleunigte Downloads
+

{{ cached_percentage }} %

+
+
+
+
+ + +
+ +
+
+
+
Anzahl Nutzer
+ +
+
+
+ +
+
+
+
Anzahl Downloads
+ +
+
+
+ +
+
+
+
Endgeräte der Nutzer
+ +
+
+
+ +
+
+
+
Verteilung auf Ordner
+ +
+
+
+
+ + +
+
+ Verteilung der Zugriffe +
+
+
+ + + + + + + + + + {% for loc in location_data %} + + + + + + {% else %} + + + + {% endfor %} + +
Anzahl DownloadsStadtLand
{{ loc.count }}{{ loc.city }}{{ loc.country }}
No access data available for the selected timeframe.
+
+
+
+ + +
+
+ Detaillierte Dateizugriffe (Top 20) +
+
+
+ + + + + + + + + {% for row in rows %} + + + + + {% else %} + + + + {% endfor %} + +
File PathAccess Count
{{ row.rel_path }}{{ row.access_count }}
No data available for the selected timeframe.
+
+
- -
-
- Detailierte Dateizugriffe (Top 20) -
-
- - - - - - - - - {% for row in rows %} - - - - - {% else %} - - - - {% endfor %} - -
File PathAccess Count
{{ row.rel_path }}{{ row.access_count }}
No data available for the selected timeframe.
-
-
+ + + + - - - + // Folder Distribution Chart - Pie Chart + const ctxFolder = document.getElementById('folderChart').getContext('2d'); + new Chart(ctxFolder, { + type: 'pie', + data: { + labels: folderData.map(item => item.folder), + datasets: [{ + data: folderData.map(item => item.count) + }] + }, + options: { responsive: true } + }); + + diff --git a/templates/mylinks.html b/templates/mylinks.html index d7b5b8c..f0e54d1 100644 --- a/templates/mylinks.html +++ b/templates/mylinks.html @@ -1,17 +1,16 @@ - + - - Meine Links + - + Meine Links + -
-

Übersicht deiner gültigen Links

-
- App - Meine Links - Verbindungen - Auswertung + + + +
{% if allowed_secrets %}
{% for secret in allowed_secrets %}