cleanup backend gui
This commit is contained in:
parent
1c0a1a0182
commit
262a31e65a
13
analytics.py
13
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
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Recent Connections</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
@ -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 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<h1 class="mb-4">Downloads in den letzten 10 Minute</h1>
|
||||
<div class="mb-3">
|
||||
<a href="{{ url_for('index') }}" class="btn btn-primary mt-1">App</a>
|
||||
<a href="{{ url_for('mylinks') }}" class="btn btn-primary mt-1">Meine Links</a>
|
||||
<a href="{{ url_for('connections') }}" class="btn btn-primary mt-1">Verbindungen</a>
|
||||
<a href="{{ url_for('dashboard') }}" class="btn btn-primary mt-1">Auswertung</a>
|
||||
<!-- Navigation Bar -->
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-secondary mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Downloads der letzten 10 Minuten</a>
|
||||
<div class="navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a href="{{ url_for('index') }}" class="nav-link">App</a></li>
|
||||
<li class="nav-item"><a href="{{ url_for('mylinks') }}" class="nav-link">Meine Links</a></li>
|
||||
<li class="nav-item"><a href="{{ url_for('connections') }}" class="nav-link">Verbindungen</a></li>
|
||||
<li class="nav-item"><a href="{{ url_for('dashboard') }}" class="nav-link">Auswertung</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="table-responsive table-container">
|
||||
<table class="table table-hover">
|
||||
<thead class="table-info">
|
||||
<thead class="table-secondary">
|
||||
<tr>
|
||||
<th>Timestamp</th>
|
||||
<th>IP Address</th>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<h1 class="mb-4">Dashboard - Verbindungsanalyse ({{ timeframe }})</h1>
|
||||
<div class="mb-3">
|
||||
<a href="{{ url_for('index') }}" class="btn btn-primary mt-1">App</a>
|
||||
<a href="{{ url_for('mylinks') }}" class="btn btn-primary mt-1">Meine Links</a>
|
||||
<a href="{{ url_for('connections') }}" class="btn btn-primary mt-1">Verbindungen</a>
|
||||
<a href="{{ url_for('dashboard') }}" class="btn btn-primary mt-1">Auswertung</a>
|
||||
</div>
|
||||
<!-- Timeframe Dropdown -->
|
||||
<div class="mb-3">
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-sm mt-1 dropdown-toggle btn-secondary"
|
||||
type="button" id="timeframeDropdown" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
{% if session['timeframe'] == 'last24hours' %}
|
||||
Last 24 Hours
|
||||
{% elif session['timeframe'] == '7days' %}
|
||||
Last 7 Days
|
||||
{% elif session['timeframe'] == '30days' %}
|
||||
Last 30 Days
|
||||
{% elif session['timeframe'] == '365days' %}
|
||||
Last 365 Days
|
||||
{% else %}
|
||||
Select Timeframe
|
||||
{% endif %}
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="timeframeDropdown">
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['timeframe'] == 'last24hours' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', timeframe='last24hours') }}">
|
||||
<body>
|
||||
<!-- Navigation Bar -->
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-secondary mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Dashboard - Verbindungsanalyse</a>
|
||||
<div class="navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a href="{{ url_for('index') }}" class="nav-link">App</a></li>
|
||||
<li class="nav-item"><a href="{{ url_for('mylinks') }}" class="nav-link">Meine Links</a></li>
|
||||
<li class="nav-item"><a href="{{ url_for('connections') }}" class="nav-link">Verbindungen</a></li>
|
||||
<li class="nav-item"><a href="{{ url_for('dashboard') }}" class="nav-link">Auswertung</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<!-- Main Container -->
|
||||
<div class="container-fluid px-4">
|
||||
<!-- Dropdown Controls -->
|
||||
<div class="mb-4 d-flex flex-wrap gap-2">
|
||||
<!-- Timeframe Dropdown -->
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-secondary dropdown-toggle"
|
||||
type="button" id="timeframeDropdown" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
{% if session['timeframe'] == 'last24hours' %}
|
||||
Last 24 Hours
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['timeframe'] == '7days' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', timeframe='7days') }}">
|
||||
{% elif session['timeframe'] == '7days' %}
|
||||
Last 7 Days
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['timeframe'] == '30days' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', timeframe='30days') }}">
|
||||
{% elif session['timeframe'] == '30days' %}
|
||||
Last 30 Days
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['timeframe'] == '365days' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', timeframe='365days') }}">
|
||||
{% elif session['timeframe'] == '365days' %}
|
||||
Last 365 Days
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Filetype Dropdown -->
|
||||
<button class="btn btn-sm mt-1 dropdown-toggle btn-secondary"
|
||||
type="button" id="filetypeDropdown" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
{% if session['filetype'] == 'audio' %}
|
||||
Audio
|
||||
{% elif session['filetype'] == 'video' %}
|
||||
Video
|
||||
{% elif session['filetype'] == 'photo' %}
|
||||
Photo
|
||||
{% elif session['filetype'] == 'other' %}
|
||||
Other
|
||||
{% else %}
|
||||
Select File Type
|
||||
{% endif %}
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="filetypeDropdown">
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['filetype'] == 'audio' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', filetype='audio') }}">
|
||||
{% else %}
|
||||
Select Timeframe
|
||||
{% endif %}
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="timeframeDropdown">
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['timeframe'] == 'last24hours' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', timeframe='last24hours') }}">
|
||||
Last 24 Hours
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['timeframe'] == '7days' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', timeframe='7days') }}">
|
||||
Last 7 Days
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['timeframe'] == '30days' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', timeframe='30days') }}">
|
||||
Last 30 Days
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['timeframe'] == '365days' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', timeframe='365days') }}">
|
||||
Last 365 Days
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Filetype Dropdown -->
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-secondary dropdown-toggle"
|
||||
type="button" id="filetypeDropdown" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
{% if session['filetype'] == 'audio' %}
|
||||
Audio
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['filetype'] == 'video' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', filetype='video') }}">
|
||||
{% elif session['filetype'] == 'video' %}
|
||||
Video
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['filetype'] == 'photo' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', filetype='photo') }}">
|
||||
{% elif session['filetype'] == 'photo' %}
|
||||
Photo
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['filetype'] == 'other' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', filetype='other') }}">
|
||||
{% elif session['filetype'] == 'other' %}
|
||||
Other
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Summary Cards -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-3">
|
||||
<div class="card text-white bg-info">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Alle Downloads</h5>
|
||||
<p class="card-text">{{ total_accesses }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card text-white bg-success">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">eindeutige Dateien</h5>
|
||||
<p class="card-text">{{ unique_files }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card text-white bg-warning">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">eindeutige Nutzer</h5>
|
||||
<p class="card-text">{{ unique_user }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="card text-white bg-secondary">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">beschleunigte Downloads</h5>
|
||||
<p class="card-text">{{ cached_percentage }} %</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Charts Section -->
|
||||
<div class="row">
|
||||
<!-- Access Trend Chart -->
|
||||
<div class="col-md-6 mb-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">eindeutige Nutzer nach Zeit</h5>
|
||||
<canvas id="distinctDeviceChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Timeframe Breakdown Chart (Bar Chart) -->
|
||||
<div class="col-md-6 mb-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Downloads nach Zeit</h5>
|
||||
<canvas id="downloadTimeframeChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- User Agent Distribution Chart -->
|
||||
<div class="col-md-6 mb-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Verwendete Endgeräte</h5>
|
||||
<canvas id="userAgentChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Folder Distribution Chart -->
|
||||
<div class="col-md-6 mb-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Verteilung auf Ordner</h5>
|
||||
<canvas id="folderChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- New Section: IP Address Access Data -->
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Verteilung der Zugriffe
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Anzahl Downloads</th>
|
||||
<th>Stadt</th>
|
||||
<th>Land</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for loc in location_data %}
|
||||
<tr>
|
||||
<td>{{ loc.count }}</td>
|
||||
<td>{{ loc.city }}</td>
|
||||
<td>{{ loc.country }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="4">No access data available for the selected timeframe.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
Select File Type
|
||||
{% endif %}
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="filetypeDropdown">
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['filetype'] == 'audio' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', filetype='audio') }}">
|
||||
Audio
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['filetype'] == 'video' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', filetype='video') }}">
|
||||
Video
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['filetype'] == 'photo' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', filetype='photo') }}">
|
||||
Photo
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item {% if session['filetype'] == 'other' %}active{% endif %}"
|
||||
href="{{ url_for('dashboard', filetype='other') }}">
|
||||
Other
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Summary Cards -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-3 mb-3">
|
||||
<div class="card bg-info text-white">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Alle Downloads</h5>
|
||||
<p class="card-text display-6">{{ total_accesses }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 mb-3">
|
||||
<div class="card bg-success text-white">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">unterschiedliche Dateien</h5>
|
||||
<p class="card-text display-6">{{ unique_files }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 mb-3">
|
||||
<div class="card bg-warning text-white">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">unterschiedliche Nutzer</h5>
|
||||
<p class="card-text display-6">{{ unique_user }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3 mb-3">
|
||||
<div class="card bg-secondary text-white">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">beschleunigte Downloads</h5>
|
||||
<p class="card-text display-6">{{ cached_percentage }} %</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Charts Section -->
|
||||
<div class="row mb-4">
|
||||
<!-- Access Trend Chart -->
|
||||
<div class="col-md-6 mb-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Anzahl Nutzer</h5>
|
||||
<canvas id="distinctDeviceChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Timeframe Breakdown Chart -->
|
||||
<div class="col-md-6 mb-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Anzahl Downloads</h5>
|
||||
<canvas id="downloadTimeframeChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- User Agent Distribution Chart -->
|
||||
<div class="col-md-6 mb-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Endgeräte der Nutzer</h5>
|
||||
<canvas id="userAgentChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Folder Distribution Chart -->
|
||||
<div class="col-md-6 mb-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Verteilung auf Ordner</h5>
|
||||
<canvas id="folderChart"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- IP Address Access Data -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
Verteilung der Zugriffe
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Anzahl Downloads</th>
|
||||
<th>Stadt</th>
|
||||
<th>Land</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for loc in location_data %}
|
||||
<tr>
|
||||
<td>{{ loc.count }}</td>
|
||||
<td>{{ loc.city }}</td>
|
||||
<td>{{ loc.country }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="3">No access data available for the selected timeframe.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Detailed Table of Top File Accesses -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
Detaillierte Dateizugriffe (Top 20)
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>File Path</th>
|
||||
<th>Access Count</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in rows %}
|
||||
<tr>
|
||||
<td>{{ row.rel_path }}</td>
|
||||
<td>{{ row.access_count }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="2">No data available for the selected timeframe.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Detailed Table of Top File Accesses -->
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
Detailierte Dateizugriffe (Top 20)
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>File Path</th>
|
||||
<th>Access Count</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for row in rows %}
|
||||
<tr>
|
||||
<td>{{ row.rel_path }}</td>
|
||||
<td>{{ row.access_count }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="2">No data available for the selected timeframe.</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Scripts -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
// Data passed from the backend as JSON
|
||||
let distinctDeviceData = {{ distinct_device_data|tojson }};
|
||||
let timeframeData = {{ timeframe_data|tojson }};
|
||||
const userAgentData = {{ user_agent_data|tojson }};
|
||||
const folderData = {{ folder_data|tojson }};
|
||||
|
||||
</div>
|
||||
// Remove the first (incomplete) bucket from the arrays
|
||||
distinctDeviceData = distinctDeviceData.slice(1);
|
||||
timeframeData = timeframeData.slice(1);
|
||||
|
||||
<!-- Load Chart.js from CDN -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script>
|
||||
// Data passed from the backend as JSON
|
||||
let distinctDeviceData = {{ distinct_device_data|tojson }};
|
||||
let timeframeData = {{ timeframe_data|tojson }};
|
||||
const userAgentData = {{ user_agent_data|tojson }};
|
||||
const folderData = {{ folder_data|tojson }};
|
||||
// Shift the labels to local time zone
|
||||
const timeframe = "{{ timeframe }}"; // e.g., 'last24hours', '7days', '30days', or '365days'
|
||||
const shiftedLabels = timeframeData.map((item) => {
|
||||
if (timeframe === 'last24hours') {
|
||||
const bucketDate = new Date(item.bucket);
|
||||
const now = new Date();
|
||||
const isCurrentHour =
|
||||
bucketDate.getFullYear() === now.getFullYear() &&
|
||||
bucketDate.getMonth() === now.getMonth() &&
|
||||
bucketDate.getDate() === now.getDate() &&
|
||||
bucketDate.getHours() === now.getHours();
|
||||
const bucketEnd = isCurrentHour ? now : new Date(bucketDate.getTime() + 3600 * 1000);
|
||||
return `${bucketDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} - ${bucketEnd.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`;
|
||||
} else if (timeframe === '7days' || timeframe === '30days') {
|
||||
const localDate = new Date(item.bucket);
|
||||
return localDate.toLocaleDateString();
|
||||
} else if (timeframe === '365days') {
|
||||
const [year, month] = item.bucket.split('-');
|
||||
const dateObj = new Date(year, month - 1, 1);
|
||||
return dateObj.toLocaleString([], { month: 'short', year: 'numeric' });
|
||||
} else {
|
||||
return item.bucket;
|
||||
}
|
||||
});
|
||||
|
||||
// Remove the first (incomplete) bucket from the arrays
|
||||
distinctDeviceData = distinctDeviceData.slice(1);
|
||||
timeframeData = timeframeData.slice(1);
|
||||
|
||||
// shift the labels to local time zone
|
||||
const timeframe = "{{ timeframe }}"; // e.g., 'last24hours', '7days', '30days', or '365days'
|
||||
const shiftedLabels = timeframeData.map((item, index) => {
|
||||
if (timeframe === 'last24hours') {
|
||||
|
||||
// item.bucket is now in the format "YYYY-MM-DDTHH:00:00Z"
|
||||
const bucketDate = new Date(item.bucket);
|
||||
const now = new Date();
|
||||
|
||||
// Check if this bucket corresponds to the current hour (in client's local time)
|
||||
const isCurrentHour =
|
||||
bucketDate.getFullYear() === now.getFullYear() &&
|
||||
bucketDate.getMonth() === now.getMonth() &&
|
||||
bucketDate.getDate() === now.getDate() &&
|
||||
bucketDate.getHours() === now.getHours();
|
||||
|
||||
// For the current hour, use the current time as the bucket end.
|
||||
const bucketEnd = isCurrentHour ? now : new Date(bucketDate.getTime() + 3600 * 1000);
|
||||
|
||||
return `${bucketDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} - ${bucketEnd.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`;
|
||||
} else if (timeframe === '7days' || timeframe === '30days') {
|
||||
const localDate = new Date(item.bucket);
|
||||
return localDate.toLocaleDateString();
|
||||
} else if (timeframe === '365days') {
|
||||
const [year, month] = item.bucket.split('-');
|
||||
const dateObj = new Date(year, month - 1, 1);
|
||||
return dateObj.toLocaleString([], { month: 'short', year: 'numeric' });
|
||||
} else {
|
||||
return item.bucket;
|
||||
}
|
||||
});
|
||||
|
||||
// Distinct Device Chart
|
||||
const ctxDistinctDevice = document.getElementById('distinctDeviceChart').getContext('2d');
|
||||
new Chart(ctxDistinctDevice, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: shiftedLabels,
|
||||
datasets: [{
|
||||
label: 'Device Count',
|
||||
data: distinctDeviceData.map(item => item.count),
|
||||
borderWidth: 2
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
plugins: { legend: { display: false } },
|
||||
scales: {
|
||||
x: { title: { display: true, text: 'Time Range' } },
|
||||
y: {
|
||||
title: { display: true, text: 'Device Count' },
|
||||
beginAtZero: true,
|
||||
ticks: {
|
||||
stepSize: 1
|
||||
// Distinct Device Chart
|
||||
const ctxDistinctDevice = document.getElementById('distinctDeviceChart').getContext('2d');
|
||||
new Chart(ctxDistinctDevice, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: shiftedLabels,
|
||||
datasets: [{
|
||||
label: 'Device Count',
|
||||
data: distinctDeviceData.map(item => item.count),
|
||||
borderWidth: 2
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
plugins: { legend: { display: false } },
|
||||
scales: {
|
||||
x: { title: { display: true, text: 'Time Range' } },
|
||||
y: {
|
||||
title: { display: true, text: 'Device Count' },
|
||||
beginAtZero: true,
|
||||
ticks: { stepSize: 1 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Timeframe Breakdown Chart - Bar Chart (for 'last24hours' timeframe)
|
||||
const ctxTimeframe = document.getElementById('downloadTimeframeChart').getContext('2d');
|
||||
new Chart(ctxTimeframe, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: shiftedLabels,
|
||||
datasets: [{
|
||||
label: 'Download Count',
|
||||
data: timeframeData.map(item => item.count),
|
||||
borderWidth: 2
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
plugins: { legend: { display: false } },
|
||||
scales: {
|
||||
x: { title: { display: true, text: 'Time Range' } },
|
||||
y: {
|
||||
title: { display: true, text: 'Download Count' },
|
||||
beginAtZero: true,
|
||||
ticks: {
|
||||
stepSize: 1
|
||||
// Timeframe Breakdown Chart
|
||||
const ctxTimeframe = document.getElementById('downloadTimeframeChart').getContext('2d');
|
||||
new Chart(ctxTimeframe, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: shiftedLabels,
|
||||
datasets: [{
|
||||
label: 'Download Count',
|
||||
data: timeframeData.map(item => item.count),
|
||||
borderWidth: 2
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
plugins: { legend: { display: false } },
|
||||
scales: {
|
||||
x: { title: { display: true, text: 'Time Range' } },
|
||||
y: {
|
||||
title: { display: true, text: 'Download Count' },
|
||||
beginAtZero: true,
|
||||
ticks: { stepSize: 1 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// User Agent Distribution - Pie Chart (using aggregated device data)
|
||||
const ctxUserAgent = document.getElementById('userAgentChart').getContext('2d');
|
||||
new Chart(ctxUserAgent, {
|
||||
type: 'pie',
|
||||
data: {
|
||||
labels: userAgentData.map(item => item.device),
|
||||
datasets: [{
|
||||
data: userAgentData.map(item => item.count)
|
||||
}]
|
||||
},
|
||||
options: { responsive: true }
|
||||
});
|
||||
// User Agent Distribution Chart - Pie Chart
|
||||
const ctxUserAgent = document.getElementById('userAgentChart').getContext('2d');
|
||||
new Chart(ctxUserAgent, {
|
||||
type: 'pie',
|
||||
data: {
|
||||
labels: userAgentData.map(item => item.device),
|
||||
datasets: [{
|
||||
data: userAgentData.map(item => item.count)
|
||||
}]
|
||||
},
|
||||
options: { responsive: true }
|
||||
});
|
||||
|
||||
// folder Distribution - Pie Chart (with shortened folders)
|
||||
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 }
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
// 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 }
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,17 +1,16 @@
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Meine Links</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<title>Meine Links</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
html, body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
/* Use full width */
|
||||
.container-fluid {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
@ -25,14 +24,22 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<h1 class="mb-4">Übersicht deiner gültigen Links</h1>
|
||||
<div class="mb-3">
|
||||
<a href="{{ url_for('index') }}" class="btn btn-primary mt-1">App</a>
|
||||
<a href="{{ url_for('mylinks') }}" class="btn btn-primary mt-1">Meine Links</a>
|
||||
<a href="{{ url_for('connections') }}" class="btn btn-primary mt-1">Verbindungen</a>
|
||||
<a href="{{ url_for('dashboard') }}" class="btn btn-primary mt-1">Auswertung</a>
|
||||
<!-- Navigation Bar -->
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-secondary mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="#">Übersicht deiner gültigen Links</a>
|
||||
<div class="navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<li class="nav-item"><a href="{{ url_for('index') }}" class="nav-link">App</a></li>
|
||||
<li class="nav-item"><a href="{{ url_for('mylinks') }}" class="nav-link">Meine Links</a></li>
|
||||
<li class="nav-item"><a href="{{ url_for('connections') }}" class="nav-link">Verbindungen</a></li>
|
||||
<li class="nav-item"><a href="{{ url_for('dashboard') }}" class="nav-link">Auswertung</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container-fluid">
|
||||
{% if allowed_secrets %}
|
||||
<div class="row">
|
||||
{% for secret in allowed_secrets %}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user