Compare commits

..
3 Commits
Author SHA1 Message Date
robin d026cc5470 feat: add table showing existing edits 2026-11-13 15:46:00 +01:00
robin 203bab6cf7 refactor: rename variable task to songId 2026-11-13 15:29:27 +01:00
robin 6595eed927 feat: create per song page
feat: add edit id
2026-11-13 15:23:49 +01:00
4 changed files with 78 additions and 2 deletions

No files matched your search

+2 -1
View File
@@ -13,7 +13,8 @@
{ {
"filename": "m004.mp3", "filename": "m004.mp3",
"sampling_rate": 22.1, "sampling_rate": 22.1,
"bitrate": 63 "bitrate": 63,
"id": "1"
} }
] ]
} }
+11
View File
@@ -322,6 +322,17 @@ def admin_list():
songs = load_songs_list() songs = load_songs_list()
return render_template("admin_tasksList.html", songs=songs) return render_template("admin_tasksList.html", songs=songs)
@bp.route("/admin/add/<songId>")
@admin_required
def admin_add_task(songId):
song = False
for s in load_songs_list():
if s["id"] == songId:
song = s
if not song:
return 404
return render_template("admin_add_task.html", song=song)
@bp.route("/api/admin/add", methods=["POST"]) @bp.route("/api/admin/add", methods=["POST"])
@admin_required @admin_required
def api_admin_add(): def api_admin_add():
+64
View File
@@ -0,0 +1,64 @@
{% extends "admin.html" %}
{% block admin_title %}Kopie erstellen{% endblock %}
{% block admin_content %}
{{ song }}
<form class="form" id="form">
<label for="titel">Titel</label>
<input id="title" name="title" type="text" autocomplete="off" required autofocus>
<label for="artist">Artist</label>
<input id="artist" name="artist" type="text" autocomplete="off">
<button type="submit">Erstellen</button>
</form>
<div class="table-wrap" style="margin-top: 2rem;">
<table>
<thead>
<th>ID</th>
<th>Bitrate</th>
<th>Abtastrate</th>
</thead>
<tbody>
<tr>
<td>Original</td>
<td>{{ song.original.bitrate }}</td>
<td>{{ song.original.sampling_rate }}</td>
</tr>
{% if song.edits %}
{% for e in song.edits %}
<tr>
<td>{{ e.id }}</td>
<td>{{ e.bitrate }} ({{ (e.bitrate / song.original.bitrate * 100) | round(1) }}%)</td>
<td>{{ e.sampling_rate }} ({{ (e.sampling_rate / song.original.sampling_rate * 100) | round(1) }}%)</td>
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
<script>
const form = document.getElementById("form");
form.addEventListener("submit", async (event) => {
event.preventDefault();
const res = await fetch("/api/admin/add", {
method: "POST",
body: new FormData(form),
});
const result = await res.json();
console.log(result);
});
const fileInput = document.getElementById("file");
const fileName = document.getElementById("file-name");
fileInput.addEventListener("change", () => {
fileName.textContent = fileInput.files.length
? fileInput.files[0].name
: "Keine Datei ausgewählt";
});
</script>
{% endblock %}
+1 -1
View File
@@ -25,7 +25,7 @@
{% for s in songs %} {% for s in songs %}
<tr> <tr>
<td class="toggle"> <td class="toggle">
<a>+</a> <a href="{{ url_for('main.admin_add_task', songId=s.id) }}">+</a>
</td> </td>
<td>{{ s.name }}</td> <td>{{ s.name }}</td>
<td>{{ s.artist }}</td> <td>{{ s.artist }}</td>