From 83a0b4f5ba2420ba846d607b205f07bce0b19c05 Mon Sep 17 00:00:00 2001 From: lelo Date: Fri, 30 May 2025 22:29:53 +0200 Subject: [PATCH 1/5] rename file, show correct status --- auth.py | 4 ++-- templates/{index.html => permission.html} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename templates/{index.html => permission.html} (100%) diff --git a/auth.py b/auth.py index e604ed0..72c2cca 100644 --- a/auth.py +++ b/auth.py @@ -152,7 +152,7 @@ def require_secret(f): header_text_color = app_config.get('header_text_color', '#fff') background_color = app_config.get('background_color', '#fff') main_text_color = app_config.get('main_text_color', '#000') - return render_template('index.html', + return render_template('permission.html', title_short=title_short, title_long=title_long, header_color=header_color, @@ -160,7 +160,7 @@ def require_secret(f): main_text_color=main_text_color, background_color=background_color, admin_enabled=is_admin() - ) + ), 403 # Forbidden return decorated_function def require_admin(f): diff --git a/templates/index.html b/templates/permission.html similarity index 100% rename from templates/index.html rename to templates/permission.html From 05cbd5efa19a2be297b16df89189191ef55bc16f Mon Sep 17 00:00:00 2001 From: lelo Date: Sun, 1 Jun 2025 09:35:42 +0000 Subject: [PATCH 2/5] cuda with cpu fallback --- transcribe_all.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/transcribe_all.py b/transcribe_all.py index de02fa6..e8df9af 100755 --- a/transcribe_all.py +++ b/transcribe_all.py @@ -1,6 +1,7 @@ import os import sys import time +import torch import whisper import concurrent.futures import json @@ -18,7 +19,6 @@ with open("transcription_config.yml", "r", encoding="utf-8") as file: settings = yaml.safe_load(file) folder_list = settings.get("folder_list") model_name = settings.get("model_name") - device = settings.get("device") def load_audio_librosa(path: str, sr: int = 16_000) -> np.ndarray: audio, orig_sr = librosa.load(path, sr=sr) # load + resample to 16 kHz @@ -222,7 +222,10 @@ def process_folder(root_folder): else: print(f"Checked {checked_files} files. Start to transcribe {len(valid_files)} files.") - print("Loading Whisper model...") + # Choose “cuda” if available, otherwise “cpu” + device = "cuda" if torch.cuda.is_available() else "cpu" + print(f"Loading Whisper model on {device}…") + model = whisper.load_model(model_name, device=device) # Use a thread pool to pre-load files concurrently. From 199e4003a01548b457f3cfd663eb77fb65cb9127 Mon Sep 17 00:00:00 2001 From: lelo Date: Sun, 1 Jun 2025 09:36:04 +0000 Subject: [PATCH 3/5] collapsable cards --- static/app.css | 21 +++++++++++++++ static/app.js | 54 +++++++++++++++++++++++++++++++++++++- templates/connections.html | 2 +- templates/file_access.html | 9 ++++--- 4 files changed, 80 insertions(+), 6 deletions(-) diff --git a/static/app.css b/static/app.css index 9911970..53870e1 100644 --- a/static/app.css +++ b/static/app.css @@ -346,4 +346,25 @@ footer { @keyframes spin { to { transform: rotate(360deg); } +} + +.card-body.collapsable { + display: none; + transition: max-height 0.3s ease; + overflow: hidden; + +} + +.card-body.collapsable.show { + display: block; + max-height: 1000px; +} + +.toggle-icon { + font-size: 1.25rem; + user-select: none; +} + +.toggle-icon:hover { + color: #007bff; } \ No newline at end of file diff --git a/static/app.js b/static/app.js index cf4e913..97117b1 100644 --- a/static/app.js +++ b/static/app.js @@ -498,4 +498,56 @@ function syncThemeColor() { .forEach(svg => svg.setAttribute('fill', cssVar)); } -document.addEventListener('DOMContentLoaded', syncThemeColor); \ No newline at end of file +document.addEventListener('DOMContentLoaded', syncThemeColor); + + +// toggle card visibility +document.addEventListener('DOMContentLoaded', function() { + // 1. Select all plus/minus icons + var icons = document.querySelectorAll('.card .toggle-icon'); + + icons.forEach(function(icon) { + // 2. For each icon, find its corresponding collapsable body + var card = icon.closest('.card'); + if (!card) return; + + var body = card.querySelector('.card-body.collapsable'); + if (!body) return; + + // 3. Initialize aria‐expanded & icon text based on whether .show is present + if (body.classList.contains('show')) { + icon.textContent = '–'; + icon.setAttribute('aria-expanded', 'true'); + } else { + icon.textContent = '+'; + icon.setAttribute('aria-expanded', 'false'); + } + + function toggleSection() { + // Toggle the 'show' class + if (body.classList.contains('show')) { + body.classList.remove('show'); + icon.textContent = '+'; + icon.setAttribute('aria-expanded', 'false'); + } else { + body.classList.add('show'); + icon.textContent = '–'; + icon.setAttribute('aria-expanded', 'true'); + } + } + + // 4. Click listener + icon.addEventListener('click', function(e) { + e.stopPropagation(); + toggleSection(); + }); + + // 5. Keydown listener (Enter/Space for accessibility) + icon.addEventListener('keydown', function(e) { + if (e.key === 'Enter' || e.key === ' ') { + e.preventDefault(); + toggleSection(); + } + }); + }); + }); \ No newline at end of file diff --git a/templates/connections.html b/templates/connections.html index 67b59b9..e89f48c 100644 --- a/templates/connections.html +++ b/templates/connections.html @@ -26,7 +26,7 @@ {% block content %}
-

Übersicht deiner gültigen Links

+

Verbindungen der letzten 10 Minuten

Anzahl Verbindungen: 0 diff --git a/templates/file_access.html b/templates/file_access.html index 8c97e95..f8a2d90 100644 --- a/templates/file_access.html +++ b/templates/file_access.html @@ -62,10 +62,11 @@ {% for top20_item in top20 %}
-
- Top 20 Dateizugriffe ({{ top20_item['category'] }}) +
+ Top 20 Dateizugriffe ({{ top20_item['category'] }}) + +
-
+
@@ -95,5 +96,5 @@ {% endblock %} {% block scripts %} - + {% endblock %} From 09bf289cf63f9edd9774614249ae4783c7e27338 Mon Sep 17 00:00:00 2001 From: lelo Date: Sun, 1 Jun 2025 20:28:11 +0000 Subject: [PATCH 4/5] small improvements --- analytics.py | 12 +++-- helperfunctions.py | 2 +- static/app.css | 2 +- static/app.js | 52 ---------------------- static/general.js | 34 ++++++++++++++ templates/base.html | 2 +- templates/file_access.html | 18 +++++--- templates/folder_secret_config_editor.html | 3 +- 8 files changed, 59 insertions(+), 66 deletions(-) create mode 100644 static/general.js diff --git a/analytics.py b/analytics.py index eccc8b7..cbccb40 100644 --- a/analytics.py +++ b/analytics.py @@ -353,6 +353,8 @@ def dashboard(): start_dt = now - timedelta(hours=24) elif session['timeframe'] == '7days': start_dt = now - timedelta(days=7) + elif session['timeframe'] == '14days': + start_dt = now - timedelta(days=14) elif session['timeframe'] == '30days': start_dt = now - timedelta(days=30) elif session['timeframe'] == '365days': @@ -381,7 +383,7 @@ def dashboard(): # removed and moved to file_access() function # 2. Distinct device trend - # We'll group by hour if "today", by day if "7days"/"30days", by month if "365days" + # We'll group by hour if "today", by day if 7days/14days/30days, by month if 365days if session['timeframe'] == 'last24hours': # Group by hour: substr(timestamp, 12, 2) -> HH query = f''' @@ -391,7 +393,7 @@ def dashboard(): GROUP BY bucket ORDER BY bucket ''' - elif session['timeframe'] in ('7days', '30days'): + elif session['timeframe'] in ('7days', '14days', '30days'): # Group by day: substr(timestamp, 1, 10) -> YYYY-MM-DD query = f''' SELECT substr(timestamp, 1, 10) AS bucket, COUNT(DISTINCT device_id) AS count @@ -426,7 +428,7 @@ def dashboard(): ] # 3. Download trend - # We'll group by hour if "today", by day if "7days"/"30days", by month if "365days". + # We'll group by hour if "today", by day if 7days/14days/30days, by month if 365days. if session['timeframe'] == 'last24hours': # Hour: substr(timestamp, 12, 2) -> HH query = f''' @@ -436,7 +438,7 @@ def dashboard(): GROUP BY bucket ORDER BY bucket ''' - elif session['timeframe'] in ('7days', '30days'): + elif session['timeframe'] in ('7days', '14days', '30days'): # Day: substr(timestamp, 1, 10) -> YYYY-MM-DD query = f''' SELECT substr(timestamp, 1, 10) AS bucket, COUNT(*) AS count @@ -615,6 +617,8 @@ def file_access(): start_dt = now - timedelta(hours=24) elif session['timeframe'] == '7days': start_dt = now - timedelta(days=7) + elif session['timeframe'] == '14days': + start_dt = now - timedelta(days=14) elif session['timeframe'] == '30days': start_dt = now - timedelta(days=30) elif session['timeframe'] == '365days': diff --git a/helperfunctions.py b/helperfunctions.py index 92ba3c0..4c9f17e 100644 --- a/helperfunctions.py +++ b/helperfunctions.py @@ -107,7 +107,7 @@ def generate_top_list(category): now = datetime.now() # We'll compare the timestamp - start_dt = now - timedelta(days=30) + start_dt = now - timedelta(days=14) start_str = start_dt.isoformat() # Filter for mimes that start with the given type diff --git a/static/app.css b/static/app.css index 53870e1..cf0740a 100644 --- a/static/app.css +++ b/static/app.css @@ -361,7 +361,7 @@ footer { } .toggle-icon { - font-size: 1.25rem; + font-size: 1.5rem; user-select: none; } diff --git a/static/app.js b/static/app.js index 97117b1..af89095 100644 --- a/static/app.js +++ b/static/app.js @@ -499,55 +499,3 @@ function syncThemeColor() { } document.addEventListener('DOMContentLoaded', syncThemeColor); - - -// toggle card visibility -document.addEventListener('DOMContentLoaded', function() { - // 1. Select all plus/minus icons - var icons = document.querySelectorAll('.card .toggle-icon'); - - icons.forEach(function(icon) { - // 2. For each icon, find its corresponding collapsable body - var card = icon.closest('.card'); - if (!card) return; - - var body = card.querySelector('.card-body.collapsable'); - if (!body) return; - - // 3. Initialize aria‐expanded & icon text based on whether .show is present - if (body.classList.contains('show')) { - icon.textContent = '–'; - icon.setAttribute('aria-expanded', 'true'); - } else { - icon.textContent = '+'; - icon.setAttribute('aria-expanded', 'false'); - } - - function toggleSection() { - // Toggle the 'show' class - if (body.classList.contains('show')) { - body.classList.remove('show'); - icon.textContent = '+'; - icon.setAttribute('aria-expanded', 'false'); - } else { - body.classList.add('show'); - icon.textContent = '–'; - icon.setAttribute('aria-expanded', 'true'); - } - } - - // 4. Click listener - icon.addEventListener('click', function(e) { - e.stopPropagation(); - toggleSection(); - }); - - // 5. Keydown listener (Enter/Space for accessibility) - icon.addEventListener('keydown', function(e) { - if (e.key === 'Enter' || e.key === ' ') { - e.preventDefault(); - toggleSection(); - } - }); - }); - }); \ No newline at end of file diff --git a/static/general.js b/static/general.js new file mode 100644 index 0000000..56d59d4 --- /dev/null +++ b/static/general.js @@ -0,0 +1,34 @@ + document.addEventListener('DOMContentLoaded', function() { + // (No per-icon setup needed here—just ensure your CSS is in place.) + }); + + // 1) Delegate clicks on any .toggle-icon, now or in the future: + document.addEventListener('click', function(e) { + // Find the closest .toggle-icon ancestor of the click target, if any + if (!e.target.classList.contains('toggle-icon')) return; + var icon = e.target; + + // Prevent clicks on the icon from bubbling further if you want + e.stopPropagation(); + + // Locate its .card-body.collapsable in the same card + var card = icon.closest('.card'); + if (!card) return; + var body = card.querySelector('.card-body.collapsable'); + if (!body) return; + + // Toggle the 'show' class and swap +/– text + if (body.classList.contains('show')) { + // Collapse: remove show, update icon, remove from set + body.classList.remove('show'); + icon.textContent = '+'; + icon.setAttribute('aria-expanded', 'false'); + openCards.add(key); + } else { + // Expand: add show, update icon, add to set + body.classList.add('show'); + icon.textContent = '–'; + icon.setAttribute('aria-expanded', 'true'); + openCards.add(key); + } + }); diff --git a/templates/base.html b/templates/base.html index c4f288d..3552ee0 100644 --- a/templates/base.html +++ b/templates/base.html @@ -57,7 +57,7 @@ {% block scripts %}{% endblock %} - + diff --git a/templates/file_access.html b/templates/file_access.html index f8a2d90..78ac21d 100644 --- a/templates/file_access.html +++ b/templates/file_access.html @@ -9,7 +9,7 @@
-

Auswertung-Dateizugriffe

+

Top 20 Dateizugriffe

@@ -21,6 +21,8 @@ Last 24 Hours {% elif session['timeframe'] == '7days' %} Last 7 Days + {% elif session['timeframe'] == '14days' %} + Last 14 Days {% elif session['timeframe'] == '30days' %} Last 30 Days {% elif session['timeframe'] == '365days' %} @@ -42,6 +44,12 @@ Last 7 Days +
  • + + Last 14 Days + +
  • @@ -63,7 +71,7 @@ {% for top20_item in top20 %}
    - Top 20 Dateizugriffe ({{ top20_item['category'] }}) + {{ top20_item['category'] }} +
    @@ -93,8 +101,6 @@
    {% endfor %}
    - {% endblock %} - - {% block scripts %} - {% endblock %} + + diff --git a/templates/folder_secret_config_editor.html b/templates/folder_secret_config_editor.html index 451edb6..05b14e5 100644 --- a/templates/folder_secret_config_editor.html +++ b/templates/folder_secret_config_editor.html @@ -92,7 +92,8 @@ // header const h5 = document.createElement('h5'); - h5.innerHTML = `Link${expired ? ' ! abgelaufen !' : ''}`; + folderNames = rec.folders.map(f => f.foldername).join(', '); + h5.innerHTML = `Ordner: ${folderNames}${expired ? ' ! abgelaufen !' : ''}`; body.appendChild(h5); // secret input From b639ac0c770a25c2ddaadda8e1136a0f17b45898 Mon Sep 17 00:00:00 2001 From: lelo Date: Tue, 3 Jun 2025 19:02:38 +0000 Subject: [PATCH 5/5] add remaining 14 days selection --- templates/dashboard.html | 8 ++++++++ templates/songs_dashboard.html | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/templates/dashboard.html b/templates/dashboard.html index afe2494..90fbe78 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -20,6 +20,8 @@ Last 24 Hours {% elif session['timeframe'] == '7days' %} Last 7 Days + {% elif session['timeframe'] == '14days' %} + Last 14 Days {% elif session['timeframe'] == '30days' %} Last 30 Days {% elif session['timeframe'] == '365days' %} @@ -41,6 +43,12 @@ Last 7 Days
  • +
  • + + Last 14 Days + +
  • diff --git a/templates/songs_dashboard.html b/templates/songs_dashboard.html index f018e25..3be3b24 100644 --- a/templates/songs_dashboard.html +++ b/templates/songs_dashboard.html @@ -46,6 +46,8 @@ type="button" id="timeframeDropdown" data-bs-toggle="dropdown" aria-expanded="false"> {% if session['songs_dashboard_timeframe'] == '7' %} Last 7 Days + {% elif session['songs_dashboard_timeframe'] == '14' %} + Last 14 Days {% elif session['songs_dashboard_timeframe'] == '30' %} Last 30 Days {% elif session['songs_dashboard_timeframe'] == '90' %} @@ -65,6 +67,12 @@ Last 7 Days
  • +
  • + + Last 14 Days + +