small improvements
This commit is contained in:
parent
4411a9e96e
commit
09bf289cf6
12
analytics.py
12
analytics.py
@ -353,6 +353,8 @@ def dashboard():
|
|||||||
start_dt = now - timedelta(hours=24)
|
start_dt = now - timedelta(hours=24)
|
||||||
elif session['timeframe'] == '7days':
|
elif session['timeframe'] == '7days':
|
||||||
start_dt = now - timedelta(days=7)
|
start_dt = now - timedelta(days=7)
|
||||||
|
elif session['timeframe'] == '14days':
|
||||||
|
start_dt = now - timedelta(days=14)
|
||||||
elif session['timeframe'] == '30days':
|
elif session['timeframe'] == '30days':
|
||||||
start_dt = now - timedelta(days=30)
|
start_dt = now - timedelta(days=30)
|
||||||
elif session['timeframe'] == '365days':
|
elif session['timeframe'] == '365days':
|
||||||
@ -381,7 +383,7 @@ def dashboard():
|
|||||||
# removed and moved to file_access() function
|
# removed and moved to file_access() function
|
||||||
|
|
||||||
# 2. Distinct device trend
|
# 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':
|
if session['timeframe'] == 'last24hours':
|
||||||
# Group by hour: substr(timestamp, 12, 2) -> HH
|
# Group by hour: substr(timestamp, 12, 2) -> HH
|
||||||
query = f'''
|
query = f'''
|
||||||
@ -391,7 +393,7 @@ def dashboard():
|
|||||||
GROUP BY bucket
|
GROUP BY bucket
|
||||||
ORDER 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
|
# Group by day: substr(timestamp, 1, 10) -> YYYY-MM-DD
|
||||||
query = f'''
|
query = f'''
|
||||||
SELECT substr(timestamp, 1, 10) AS bucket, COUNT(DISTINCT device_id) AS count
|
SELECT substr(timestamp, 1, 10) AS bucket, COUNT(DISTINCT device_id) AS count
|
||||||
@ -426,7 +428,7 @@ def dashboard():
|
|||||||
]
|
]
|
||||||
|
|
||||||
# 3. Download trend
|
# 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':
|
if session['timeframe'] == 'last24hours':
|
||||||
# Hour: substr(timestamp, 12, 2) -> HH
|
# Hour: substr(timestamp, 12, 2) -> HH
|
||||||
query = f'''
|
query = f'''
|
||||||
@ -436,7 +438,7 @@ def dashboard():
|
|||||||
GROUP BY bucket
|
GROUP BY bucket
|
||||||
ORDER 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
|
# Day: substr(timestamp, 1, 10) -> YYYY-MM-DD
|
||||||
query = f'''
|
query = f'''
|
||||||
SELECT substr(timestamp, 1, 10) AS bucket, COUNT(*) AS count
|
SELECT substr(timestamp, 1, 10) AS bucket, COUNT(*) AS count
|
||||||
@ -615,6 +617,8 @@ def file_access():
|
|||||||
start_dt = now - timedelta(hours=24)
|
start_dt = now - timedelta(hours=24)
|
||||||
elif session['timeframe'] == '7days':
|
elif session['timeframe'] == '7days':
|
||||||
start_dt = now - timedelta(days=7)
|
start_dt = now - timedelta(days=7)
|
||||||
|
elif session['timeframe'] == '14days':
|
||||||
|
start_dt = now - timedelta(days=14)
|
||||||
elif session['timeframe'] == '30days':
|
elif session['timeframe'] == '30days':
|
||||||
start_dt = now - timedelta(days=30)
|
start_dt = now - timedelta(days=30)
|
||||||
elif session['timeframe'] == '365days':
|
elif session['timeframe'] == '365days':
|
||||||
|
|||||||
@ -107,7 +107,7 @@ def generate_top_list(category):
|
|||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
|
||||||
# We'll compare the timestamp
|
# We'll compare the timestamp
|
||||||
start_dt = now - timedelta(days=30)
|
start_dt = now - timedelta(days=14)
|
||||||
start_str = start_dt.isoformat()
|
start_str = start_dt.isoformat()
|
||||||
|
|
||||||
# Filter for mimes that start with the given type
|
# Filter for mimes that start with the given type
|
||||||
|
|||||||
@ -361,7 +361,7 @@ footer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.toggle-icon {
|
.toggle-icon {
|
||||||
font-size: 1.25rem;
|
font-size: 1.5rem;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -499,55 +499,3 @@ function syncThemeColor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', 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();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
34
static/general.js
Normal file
34
static/general.js
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -57,7 +57,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
|
<script src="{{ url_for('static', filename='general.js') }}"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<!-- Main Container -->
|
<!-- Main Container -->
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h2>Auswertung-Dateizugriffe</h2>
|
<h2>Top 20 Dateizugriffe</h2>
|
||||||
|
|
||||||
<!-- Dropdown Controls -->
|
<!-- Dropdown Controls -->
|
||||||
<div class="mb-4 d-flex flex-wrap gap-2">
|
<div class="mb-4 d-flex flex-wrap gap-2">
|
||||||
@ -21,6 +21,8 @@
|
|||||||
Last 24 Hours
|
Last 24 Hours
|
||||||
{% elif session['timeframe'] == '7days' %}
|
{% elif session['timeframe'] == '7days' %}
|
||||||
Last 7 Days
|
Last 7 Days
|
||||||
|
{% elif session['timeframe'] == '14days' %}
|
||||||
|
Last 14 Days
|
||||||
{% elif session['timeframe'] == '30days' %}
|
{% elif session['timeframe'] == '30days' %}
|
||||||
Last 30 Days
|
Last 30 Days
|
||||||
{% elif session['timeframe'] == '365days' %}
|
{% elif session['timeframe'] == '365days' %}
|
||||||
@ -42,6 +44,12 @@
|
|||||||
Last 7 Days
|
Last 7 Days
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a class="dropdown-item {% if session['timeframe'] == '14days' %}active{% endif %}"
|
||||||
|
href="{{ url_for('file_access', timeframe='14days') }}">
|
||||||
|
Last 14 Days
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a class="dropdown-item {% if session['timeframe'] == '30days' %}active{% endif %}"
|
<a class="dropdown-item {% if session['timeframe'] == '30days' %}active{% endif %}"
|
||||||
href="{{ url_for('file_access', timeframe='30days') }}">
|
href="{{ url_for('file_access', timeframe='30days') }}">
|
||||||
@ -63,7 +71,7 @@
|
|||||||
{% for top20_item in top20 %}
|
{% for top20_item in top20 %}
|
||||||
<div class="card mb-4">
|
<div class="card mb-4">
|
||||||
<div class="card-header d-flex justify-content-between align-items-center">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<span>Top 20 Dateizugriffe ({{ top20_item['category'] }})</span>
|
<span>{{ top20_item['category'] }}</span>
|
||||||
<span class="toggle-icon" aria-label="collapse" role="button" tabindex="0">+</span>
|
<span class="toggle-icon" aria-label="collapse" role="button" tabindex="0">+</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body collapsable">
|
<div class="card-body collapsable">
|
||||||
@ -95,6 +103,4 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block scripts %}
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
|
|||||||
@ -92,7 +92,8 @@
|
|||||||
|
|
||||||
// header
|
// header
|
||||||
const h5 = document.createElement('h5');
|
const h5 = document.createElement('h5');
|
||||||
h5.innerHTML = `Link${expired ? ' <span class="text-danger fw-bold"> ! abgelaufen !</span>' : ''}`;
|
folderNames = rec.folders.map(f => f.foldername).join(', ');
|
||||||
|
h5.innerHTML = `Ordner: ${folderNames}${expired ? ' <span class="text-danger fw-bold"> ! abgelaufen !</span>' : ''}`;
|
||||||
body.appendChild(h5);
|
body.appendChild(h5);
|
||||||
|
|
||||||
// secret input
|
// secret input
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user