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