Fix toast notifications and add Webtorrent to project dependencies
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Jack Hadrill 2021-01-03 16:52:21 +00:00
parent 0bd5ee89a0
commit 25fe4735a4
5 changed files with 2630 additions and 114 deletions

2706
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,8 @@
"primeicons": "^4.1.0", "primeicons": "^4.1.0",
"primevue": "^3.1.1", "primevue": "^3.1.1",
"vue": "^3.0.0", "vue": "^3.0.0",
"vue-router": "^4.0.2" "vue-router": "^4.0.2",
"webtorrent": "^0.112.0"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-babel": "~4.5.0",

View File

@ -2,6 +2,7 @@
<MenuBar :model="items"> <MenuBar :model="items">
</MenuBar> </MenuBar>
<router-view /> <router-view />
<Toast position="top-right" />
</template> </template>
<script> <script>

View File

@ -1,35 +1,45 @@
<template> <template>
<div class="p-card p-component" v-cloak @drop.prevent="droppedFile" @dragover.prevent> <Card class="upload" v-cloak @drop.prevent="fileDropped" @dragover.prevent>
<div class="p-card-body"> <template #content>
<div class="p-card-content"> <div class="p-text-center">
Hello <i class="pi pi-upload"></i>
</div> <h2>Drag a H.264 encoded MP4 here to start a screen.</h2>
</div>
</div> </div>
</template> </template>
</Card>
</template>
<script> <script>
import { useToast } from 'primevue/usetoast'
export default { export default {
setup () { setup () {
function droppedFile (e) { const toast = useToast()
function fileDropped (e) {
if (e.dataTransfer.files.length !== 1) { if (e.dataTransfer.files.length !== 1) {
alert('You may only host a single video.') toast.add({ severity: 'error', summary: 'Bad file', detail: 'Please select only a single file.', life: 3000 })
return return
} }
const file = e.dataTransfer.files[0] const file = e.dataTransfer.files[0]
if (!file.name.endsWith('.mp4') || !file.type === 'video/mp4') { if (!file.name.endsWith('.mp4') || !file.type === 'video/mp4') {
alert('You may only host an H.264 encoded MP4.') toast.add({ severity: 'error', summary: 'Bad file', detail: 'File must be a H.264 encoded MP4.', life: 3000 })
} }
} }
return { return {
droppedFile fileDropped
} }
} }
} }
</script> </script>
<style> <style>
.upload {
color: rgba(0,0,0,0.4)
}
i.pi.pi-upload {
font-size: 5em;
}
</style> </style>

View File

@ -12,6 +12,8 @@ import Card from 'primevue/card'
import FileUpload from 'primevue/fileupload' import FileUpload from 'primevue/fileupload'
import InputText from 'primevue/inputtext' import InputText from 'primevue/inputtext'
import MenuBar from 'primevue/menubar' import MenuBar from 'primevue/menubar'
import Toast from 'primevue/toast'
import ToastService from 'primevue/toastservice'
import 'primeflex/primeflex.css' import 'primeflex/primeflex.css'
import 'primeicons/primeicons.css' import 'primeicons/primeicons.css'
import 'primevue/resources/primevue.min.css' import 'primevue/resources/primevue.min.css'
@ -21,6 +23,7 @@ const app = createApp(App)
app.use(Router) app.use(Router)
app.use(PrimeVue) app.use(PrimeVue)
app.use(ToastService)
app.component('Button', Button) app.component('Button', Button)
app.component('Card', Card) app.component('Card', Card)
@ -28,6 +31,7 @@ app.component('FileUpload', FileUpload)
app.component('InputText', InputText) app.component('InputText', InputText)
app.component('MenuBar', MenuBar) app.component('MenuBar', MenuBar)
app.component('Upload', Upload) app.component('Upload', Upload)
app.component('Toast', Toast)
// Render to DOM. // Render to DOM.
app.mount('#app') app.mount('#app')