migrate to WebSocket for frontend and backend communication

This commit is contained in:
2024-09-09 21:38:10 +07:00
parent b46915e46d
commit b23bf8898b
16 changed files with 309 additions and 202 deletions

View File

@ -3,7 +3,7 @@ package uploadView
import "github.com/fossyy/filekeeper/view/client/layout"
templ content(title string) {
@layout.Base(title){
@layout.BaseAuth(title){
<div class="flex items-center min-h-screen p-4 sm:p-6 bg-gray-900 text-white">
<div class="mx-auto w-full max-w-md space-y-8">
<div class="rounded-lg border bg-card text-card-foreground shadow-sm w-full max-w-md" data-v0-t="card">
@ -43,7 +43,23 @@ templ content(title string) {
</div>
</div>
</div>
<script src="/public/upload.js" />
<script type="text/javascript">
document.addEventListener("dragover", function (event) {
event.preventDefault();
});
document.addEventListener("drop", async function (event) {
event.preventDefault();
const file = event.dataTransfer.files[0]
await handleFile(file)
});
document.getElementById('dropzone-file').addEventListener('change', async function(event) {
event.preventDefault();
const file = event.target.files[0]
await handleFile(file)
});
</script>
}
}