implemented remote upload progress counter

This commit is contained in:
Čarodej
2022-04-25 10:13:10 +02:00
parent 6a9fa9ceec
commit 954f0e3361
10 changed files with 155 additions and 39 deletions

View File

@@ -46,6 +46,7 @@ import AppInputText from '../Forms/Layouts/AppInputText'
import { required } from 'vee-validate/dist/rules'
import ButtonBase from '../UI/Buttons/ButtonBase'
import { events } from '../../bus'
import i18n from "../../i18n";
export default {
name: 'RemoteUploadPopup',
@@ -75,6 +76,21 @@ export default {
this.loading = true
this.urls = this.links
.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm, "")
.split(/\r?\n/)
// If broadcasting
if (this.$store.getters.isBroadcasting) {
this.$store.commit('UPDATE_REMOTE_UPLOAD_QUEUE', {
progress: {
total: this.urls.length,
processed: 0,
failed: 0,
}
})
}
// Get route
let route = {
RequestUpload: `/api/upload-request/${this.$router.currentRoute.params.token}/upload/remote`,
@@ -87,24 +103,19 @@ export default {
axios
.post(route, {
urls: this.links
.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm, "")
.split(/\r?\n/),
urls: this.urls,
parent_id: parentId,
})
.then(() => {
// If broadcasting
if (this.$store.getters.isBroadcasting) {
events.$emit('toaster', {
type: 'success',
message: this.$t('remote_download_processed'),
})
}
// If broadcasting is not set
if (!this.$store.getters.isBroadcasting) {
// Reload data
this.$getDataByLocation()
events.$emit('toaster', {
type: 'success',
message: i18n.t('remote_download_finished'),
})
}
events.$emit('popup:close')
@@ -135,8 +146,6 @@ export default {
this.$nextTick(() => {
setTimeout(() => this.$refs.textarea.focus(), 100)
})
console.log(this.$store.getters.isBroadcasting);
})
},
}

View File

@@ -0,0 +1,54 @@
<template>
<transition name="popup">
<div v-if="remoteUploadQueue" class="fixed left-0 right-0 bottom-8 text-center select-none pointer-events-none z-10">
<div class="relative inline-block rounded-lg overflow-hidden bg-theme shadow-[#ff8200]/40 shadow-lg px-3 py-2">
<div class="flex items-center">
<RefreshCwIcon size="14" class="vue-feather text-white animate-[spin_2s_linear_infinite] z-10 relative" />
<span class="text-xs font-bold text-white z-10 relative ml-2 dark:text-black">
{{ this.$t('remote_upload_progress', {processed: remoteUploadQueue.processed, total: remoteUploadQueue.total}) }}{{ remoteUploadQueue.failed > 0 ? ", " + this.$t('remote_upload_failed_count', {count: remoteUploadQueue.failed}) : '' }}
</span>
</div>
<span class="absolute w-full h-full top-0 bottom-0 left-0 right-0 block bg-theme brightness-125 animate-[pulse_3s_ease-in-out_infinite] z-[5]"></span>
<span class="absolute w-full h-full top-0 bottom-0 left-0 right-0 block bg-theme z-0"></span>
</div>
</div>
</transition>
</template>
<script>
import {RefreshCwIcon} from "vue-feather-icons";
import {mapGetters} from "vuex";
export default {
name: 'RemoteUploadProgress',
components: {
RefreshCwIcon,
},
computed: {
...mapGetters([
'remoteUploadQueue'
]),
},
}
</script>
<style lang="scss">
.popup-leave-active {
animation: popup-slide-in 0.15s ease reverse;
}
.popup-enter-active {
animation: popup-slide-in 0.25s 0.1s ease both;
}
@keyframes popup-slide-in {
0% {
opacity: 0;
transform: translateY(100px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
</style>