feat: admin: create subtask and upload file
This commit is contained in:
1 parent
36196a736a
commit
29ebab923d
5 files changed
+158
-31
No files matched your search
@@ -2,6 +2,43 @@
|
||||
{% block content %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style/admin.css') }}">
|
||||
|
||||
<h2>Unteraufgabe hinzufügen</h2>
|
||||
<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">
|
||||
|
||||
<label for="file">Datei</label>
|
||||
<div class="file-upload">
|
||||
<input id="file" name="file" type="file" accept="audio/*,.mp3,.wav,.flac,.ogg,.m4a" required>
|
||||
<label for="file" class="file-button">Audiodatei wählen</label>
|
||||
<span class="file-name" id="file-name">Keine Datei ausgewählt</span>
|
||||
</div>
|
||||
|
||||
<button type="submit">Erstellen</button>
|
||||
</form>
|
||||
|
||||
<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 %}
|
||||
Reference in new issue
Block a user