diff --git a/app/Http/Controllers/SlipDownloadController.php b/app/Http/Controllers/SlipDownloadController.php new file mode 100644 index 0000000..5ccd251 --- /dev/null +++ b/app/Http/Controllers/SlipDownloadController.php @@ -0,0 +1,16 @@ +download($slip->mediable->localPath); + } +} diff --git a/resources/js/Components/Dashboard/VideoCard.vue b/resources/js/Components/Dashboard/VideoCard.vue index c684d28..7646663 100644 --- a/resources/js/Components/Dashboard/VideoCard.vue +++ b/resources/js/Components/Dashboard/VideoCard.vue @@ -13,6 +13,7 @@ import Download from '~icons/ion/download' import Trash from '~icons/mdi/trash' import PrimaryButton from '@/Components/UI/PrimaryButton.vue' import WarningButton from '@/Components/UI/WarningButton.vue' +import Loading from '@/Components/UI/Loading.vue' const hoverEffect = ref(false) const hover = ref(false) @@ -55,6 +56,35 @@ const deleteJob = () => { router.delete(route('job.destroy', props.slip)) } +const downloading = ref(false) +const download = () => { + downloading.value = true + status.value = 'Downloading' + axios({ + url: 'http://localhost/download/' + props.slip.token, + method: 'GET', + responseType: 'blob', + onDownloadProgress: (progress) => { + percentage.value = (progress.progress * 100).toFixed(0) + console.log(percentage.value) + }, + }).then((response) => { + const url = window.URL.createObjectURL(new Blob([response.data])) + console.log(response) + const link = document.createElement('a') + link.href = url + alert(props.slip.title) + link.setAttribute('download', '.mp5') + alert(link) + document.body.appendChild(link) + link.click() + link.remove() + downloading.value = false + status.value = null + percentage.value = 0 + }) +} +