Can upload new track
This commit is contained in:
parent
46e8d1a1d2
commit
f0967f3b9d
4 changed files with 114 additions and 4 deletions
|
|
@ -1,3 +1,45 @@
|
|||
<h2>
|
||||
Nouvelle musique
|
||||
</h2>
|
||||
<script>
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
import {
|
||||
Button,
|
||||
Container,
|
||||
Form,
|
||||
Icon,
|
||||
Input,
|
||||
ListGroup,
|
||||
ListGroupItem,
|
||||
Spinner,
|
||||
} from 'sveltestrap';
|
||||
|
||||
import { tracks } from '$lib/stores/tracks';
|
||||
import { uploadTrack } from '$lib/track';
|
||||
|
||||
function submitTrack() {
|
||||
if (files.length == 0) {
|
||||
alert("Vous n'avez sélectionné aucun fichier !")
|
||||
return false;
|
||||
}
|
||||
|
||||
uploadTrack(files).then((track) => {
|
||||
tracks.refresh();
|
||||
goto('musiks/tracks/' + track.id);
|
||||
})
|
||||
}
|
||||
|
||||
export let files = [];
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<h2>
|
||||
Nouvelle musique
|
||||
</h2>
|
||||
|
||||
<form on:submit|preventDefault={submitTrack}>
|
||||
<Input type="file" bind:files />
|
||||
|
||||
<Button type="submit" color="primary" class="mt-2" disabled={files.length == 0}>
|
||||
Ajouter cette musique
|
||||
</Button>
|
||||
</form>
|
||||
</Container>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue