2020-07-14 20:27:48 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
id="download_tab_container"
|
|
|
|
class="tab_hidden"
|
|
|
|
@transitionend="$refs.container.style.transition = ''"
|
|
|
|
ref="container"
|
2020-07-21 09:09:47 +00:00
|
|
|
:data-label="$t('downloads')"
|
2020-07-14 20:27:48 +00:00
|
|
|
>
|
|
|
|
<div id="download_tab_drag_handler" @mousedown.prevent="startDrag" ref="dragHandler"></div>
|
|
|
|
<i
|
|
|
|
id="toggle_download_tab"
|
|
|
|
class="material-icons download_bar_icon"
|
|
|
|
@click.prevent="toggleDownloadTab"
|
|
|
|
ref="toggler"
|
2020-07-25 13:51:36 +00:00
|
|
|
:title="$t('globals.toggle_download_tab_hint')"
|
2020-07-14 20:27:48 +00:00
|
|
|
></i>
|
|
|
|
<div id="queue_buttons">
|
2020-09-15 20:44:29 +00:00
|
|
|
<i
|
|
|
|
id="open_downloads_folder"
|
2020-09-17 21:55:57 +00:00
|
|
|
v-if="clientMode"
|
|
|
|
class="material-icons download_bar_icon"
|
2020-09-15 20:44:29 +00:00
|
|
|
:title="$t('globals.open_downloads_folder')"
|
|
|
|
@click="openDownloadsFolder"
|
|
|
|
>
|
|
|
|
folder_open
|
|
|
|
</i>
|
|
|
|
<i
|
|
|
|
id="clean_queue"
|
|
|
|
class="material-icons download_bar_icon"
|
|
|
|
@click="cleanQueue"
|
|
|
|
:title="$t('globals.clean_queue_hint')"
|
|
|
|
>
|
|
|
|
clear_all
|
|
|
|
</i>
|
|
|
|
<i
|
|
|
|
id="cancel_queue"
|
|
|
|
class="material-icons download_bar_icon"
|
|
|
|
@click="cancelQueue"
|
|
|
|
:title="$t('globals.cancel_queue_hint')"
|
|
|
|
>
|
|
|
|
delete_sweep
|
|
|
|
</i>
|
2020-07-14 20:27:48 +00:00
|
|
|
</div>
|
2020-09-19 15:07:28 +00:00
|
|
|
<div id="download_list" @click="handleListClick" ref="list">
|
|
|
|
<QueueItem v-for="item in queueList" :queue-item="item" :key="item.uuid" />
|
|
|
|
</div>
|
2020-07-14 20:27:48 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2020-09-15 20:44:29 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
#download_tab_container {
|
|
|
|
height: 100vh;
|
|
|
|
}
|
|
|
|
</style>
|
2020-09-19 13:11:06 +00:00
|
|
|
|
2020-07-14 20:27:48 +00:00
|
|
|
<script>
|
2020-07-16 20:20:13 +00:00
|
|
|
import $ from 'jquery'
|
2020-07-16 22:11:28 +00:00
|
|
|
import { socket } from '@/utils/socket'
|
|
|
|
import { toast } from '@/utils/toasts'
|
2020-09-19 13:11:06 +00:00
|
|
|
import { mapActions } from 'vuex'
|
2020-07-14 20:27:48 +00:00
|
|
|
|
2020-09-19 15:07:28 +00:00
|
|
|
import QueueItem from '@components/downloads/QueueItem.vue'
|
|
|
|
|
2020-07-14 20:27:48 +00:00
|
|
|
const tabMinWidth = 250
|
|
|
|
const tabMaxWidth = 500
|
|
|
|
|
|
|
|
export default {
|
2020-09-19 15:07:28 +00:00
|
|
|
components: {
|
|
|
|
QueueItem
|
|
|
|
},
|
2020-09-17 21:55:57 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
cachedTabWidth: parseInt(localStorage.getItem('downloadTabWidth')) || 300,
|
|
|
|
queue: [],
|
|
|
|
queueList: {},
|
|
|
|
queueComplete: [],
|
|
|
|
clientMode: window.clientMode
|
|
|
|
}
|
|
|
|
},
|
2020-07-14 20:27:48 +00:00
|
|
|
mounted() {
|
2020-07-16 20:20:13 +00:00
|
|
|
socket.on('startDownload', this.startDownload)
|
2020-08-14 17:49:36 +00:00
|
|
|
socket.on('startConversion', this.startConversion)
|
2020-07-16 20:20:13 +00:00
|
|
|
socket.on('init_downloadQueue', this.initQueue)
|
|
|
|
socket.on('addedToQueue', this.addToQueue)
|
|
|
|
socket.on('updateQueue', this.updateQueue)
|
|
|
|
socket.on('removedFromQueue', this.removeFromQueue)
|
|
|
|
socket.on('finishDownload', this.finishDownload)
|
|
|
|
socket.on('removedAllDownloads', this.removeAllDownloads)
|
|
|
|
socket.on('removedFinishedDownloads', this.removedFinishedDownloads)
|
|
|
|
|
2020-07-14 20:27:48 +00:00
|
|
|
// Check if download tab has slim entries
|
|
|
|
if ('true' === localStorage.getItem('slimDownloads')) {
|
|
|
|
this.$refs.list.classList.add('slim')
|
|
|
|
}
|
|
|
|
|
|
|
|
if ('true' === localStorage.getItem('downloadTabOpen')) {
|
|
|
|
this.$refs.container.classList.remove('tab_hidden')
|
|
|
|
|
|
|
|
this.setTabWidth(this.cachedTabWidth)
|
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener('mouseup', () => {
|
|
|
|
document.removeEventListener('mousemove', this.handleDrag)
|
|
|
|
})
|
|
|
|
|
|
|
|
window.addEventListener('beforeunload', () => {
|
|
|
|
localStorage.setItem('downloadTabWidth', this.cachedTabWidth)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
methods: {
|
2020-09-19 13:11:06 +00:00
|
|
|
...mapActions(['setErrors']),
|
2020-07-14 20:27:48 +00:00
|
|
|
setTabWidth(newWidth) {
|
|
|
|
if (undefined === newWidth) {
|
|
|
|
this.$refs.container.style.width = ''
|
|
|
|
this.$refs.list.style.width = ''
|
|
|
|
} else {
|
|
|
|
this.$refs.container.style.width = newWidth + 'px'
|
|
|
|
this.$refs.list.style.width = newWidth + 'px'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
handleListClick(event) {
|
2020-09-19 15:07:28 +00:00
|
|
|
console.log('this.handleListClick')
|
2020-07-14 20:27:48 +00:00
|
|
|
const { target } = event
|
|
|
|
|
|
|
|
if (!target.matches('.queue_icon[data-uuid]')) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
let icon = target.innerText
|
|
|
|
let uuid = $(target).data('uuid')
|
|
|
|
|
|
|
|
switch (icon) {
|
|
|
|
case 'remove':
|
|
|
|
socket.emit('removeFromQueue', uuid)
|
2020-09-19 15:07:28 +00:00
|
|
|
|
2020-09-15 20:44:29 +00:00
|
|
|
if ($(`#bar_${uuid}`).hasClass('indeterminate')) {
|
2020-09-15 15:37:17 +00:00
|
|
|
$(`#download_${uuid}`).remove()
|
2020-09-15 20:44:29 +00:00
|
|
|
} else {
|
2020-09-15 15:37:17 +00:00
|
|
|
target.innerHTML = `<div class="circle-loader"></div>`
|
|
|
|
}
|
2020-07-14 20:27:48 +00:00
|
|
|
break
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
},
|
2020-07-16 20:20:13 +00:00
|
|
|
initQueue(data) {
|
2020-09-19 15:07:28 +00:00
|
|
|
console.log('this.initQueue')
|
2020-09-15 20:44:29 +00:00
|
|
|
const {
|
|
|
|
queue: initQueue,
|
|
|
|
queueComplete: initQueueComplete,
|
|
|
|
currentItem,
|
|
|
|
queueList: initQueueList,
|
|
|
|
restored
|
|
|
|
} = data
|
2020-07-16 20:20:13 +00:00
|
|
|
|
|
|
|
if (initQueueComplete.length) {
|
|
|
|
initQueueComplete.forEach(item => {
|
2020-08-17 09:06:24 +00:00
|
|
|
initQueueList[item].silent = true
|
2020-07-16 20:20:13 +00:00
|
|
|
this.addToQueue(initQueueList[item])
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentItem) {
|
2020-08-17 09:06:24 +00:00
|
|
|
initQueueList[currentItem].silent = true
|
2020-07-16 20:20:13 +00:00
|
|
|
this.addToQueue(initQueueList[currentItem], true)
|
|
|
|
}
|
|
|
|
|
|
|
|
initQueue.forEach(item => {
|
2020-08-17 09:06:24 +00:00
|
|
|
initQueueList[item].silent = true
|
2020-07-16 20:20:13 +00:00
|
|
|
this.addToQueue(initQueueList[item])
|
|
|
|
})
|
2020-08-15 23:34:55 +00:00
|
|
|
|
2020-09-15 20:44:29 +00:00
|
|
|
if (restored) {
|
2020-08-16 10:29:08 +00:00
|
|
|
toast(this.$t('toasts.queueRestored'), 'done', true, 'restoring_queue')
|
|
|
|
socket.emit('queueRestored')
|
|
|
|
}
|
2020-07-16 20:20:13 +00:00
|
|
|
},
|
|
|
|
addToQueue(queueItem, current = false) {
|
2020-09-19 15:07:28 +00:00
|
|
|
console.log('this.addToQueue')
|
2020-09-15 20:44:29 +00:00
|
|
|
if (Array.isArray(queueItem)) {
|
|
|
|
if (queueItem.length > 1) {
|
2020-08-17 09:06:24 +00:00
|
|
|
queueItem.forEach((item, i) => {
|
|
|
|
item.silent = true
|
|
|
|
this.addToQueue(item)
|
2020-09-15 20:44:29 +00:00
|
|
|
})
|
|
|
|
toast(this.$t('toasts.addedMoreToQueue', { n: queueItem.length }), 'playlist_add_check')
|
2020-08-17 09:06:24 +00:00
|
|
|
return
|
2020-09-15 20:44:29 +00:00
|
|
|
} else {
|
2020-08-17 09:06:24 +00:00
|
|
|
queueItem = queueItem[0]
|
|
|
|
}
|
|
|
|
}
|
2020-07-16 20:20:13 +00:00
|
|
|
|
2020-09-19 15:07:28 +00:00
|
|
|
// * Here we have only objects
|
|
|
|
this.$set(this.queueList, queueItem.uuid, queueItem)
|
|
|
|
// this.queueList[queueItem.uuid] = queueItem
|
|
|
|
|
|
|
|
// * Used when opening the app in another tab
|
|
|
|
let itemIsAlreadyDownloaded = queueItem.downloaded + queueItem.failed == queueItem.size
|
|
|
|
|
|
|
|
if (itemIsAlreadyDownloaded) {
|
|
|
|
let itemIsNotInCompletedQueue = this.queueComplete.indexOf(queueItem.uuid) == -1
|
|
|
|
|
|
|
|
if (itemIsNotInCompletedQueue) {
|
|
|
|
// * Add it
|
2020-07-16 20:20:13 +00:00
|
|
|
this.queueComplete.push(queueItem.uuid)
|
|
|
|
}
|
|
|
|
} else {
|
2020-09-19 15:07:28 +00:00
|
|
|
let itemIsNotInQueue = this.queue.indexOf(queueItem.uuid) == -1
|
|
|
|
|
|
|
|
if (itemIsNotInQueue) {
|
2020-07-16 20:20:13 +00:00
|
|
|
this.queue.push(queueItem.uuid)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let queueDOM = document.getElementById('download_' + queueItem.uuid)
|
2020-09-19 15:07:28 +00:00
|
|
|
let noItemInQueueDOM = typeof queueDOM == 'undefined' || queueDOM == null
|
2020-07-16 20:20:13 +00:00
|
|
|
|
2020-09-19 15:07:28 +00:00
|
|
|
if (noItemInQueueDOM) {
|
|
|
|
this.appendItem(queueItem)
|
2020-07-16 20:20:13 +00:00
|
|
|
}
|
|
|
|
|
2020-09-19 15:07:28 +00:00
|
|
|
let needToStartDownload = queueItem.progress > 0 || current
|
|
|
|
|
|
|
|
if (needToStartDownload) {
|
2020-07-16 20:20:13 +00:00
|
|
|
this.startDownload(queueItem.uuid)
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#bar_' + queueItem.uuid).css('width', queueItem.progress + '%')
|
|
|
|
|
|
|
|
if (queueItem.failed >= 1 && $('#download_' + queueItem.uuid + ' .queue_failed').length == 0) {
|
|
|
|
$('#download_' + queueItem.uuid + ' .download_info_status').append(
|
|
|
|
`<span class="secondary-text inline-flex"><span class="download_slim_separator">(</span><span class="queue_failed_button inline-flex"><span class="queue_failed">${queueItem.failed}</span><i class="material-icons">error_outline</i></span><span class="download_slim_separator">)</span></span>`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (queueItem.downloaded + queueItem.failed == queueItem.size) {
|
|
|
|
let resultIcon = $('#download_' + queueItem.uuid).find('.queue_icon')
|
|
|
|
|
|
|
|
if (queueItem.failed == 0) {
|
|
|
|
resultIcon.text('done')
|
|
|
|
} else {
|
|
|
|
let failedButton = $('#download_' + queueItem.uuid).find('.queue_failed_button')
|
|
|
|
|
|
|
|
resultIcon.addClass('clickable')
|
|
|
|
failedButton.addClass('clickable')
|
|
|
|
|
|
|
|
resultIcon.bind('click', { item: queueItem }, this.showErrorsTab)
|
|
|
|
failedButton.bind('click', { item: queueItem }, this.showErrorsTab)
|
|
|
|
|
|
|
|
if (queueItem.failed >= queueItem.size) {
|
|
|
|
resultIcon.text('error')
|
|
|
|
} else {
|
|
|
|
resultIcon.text('warning')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-17 09:06:24 +00:00
|
|
|
if (!queueItem.silent) {
|
2020-09-15 20:44:29 +00:00
|
|
|
toast(this.$t('toasts.addedToQueue', { item: queueItem.title }), 'playlist_add_check')
|
2020-07-16 20:20:13 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
updateQueue(update) {
|
|
|
|
// downloaded and failed default to false?
|
2020-08-14 17:49:36 +00:00
|
|
|
const { uuid, downloaded, failed, progress, conversion, error, data, errid } = update
|
2020-09-19 15:07:28 +00:00
|
|
|
console.log('this.updateQueue', !!this.queueList[uuid])
|
2020-07-16 20:20:13 +00:00
|
|
|
|
|
|
|
if (uuid && this.queue.indexOf(uuid) > -1) {
|
|
|
|
if (downloaded) {
|
|
|
|
this.queueList[uuid].downloaded++
|
2020-09-19 15:07:28 +00:00
|
|
|
|
2020-07-16 20:20:13 +00:00
|
|
|
$('#download_' + uuid + ' .queue_downloaded').text(
|
|
|
|
this.queueList[uuid].downloaded + this.queueList[uuid].failed
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (failed) {
|
|
|
|
this.queueList[uuid].failed++
|
2020-09-19 15:07:28 +00:00
|
|
|
|
2020-07-16 20:20:13 +00:00
|
|
|
$('#download_' + uuid + ' .queue_downloaded').text(
|
|
|
|
this.queueList[uuid].downloaded + this.queueList[uuid].failed
|
|
|
|
)
|
2020-09-19 15:07:28 +00:00
|
|
|
|
2020-07-16 20:20:13 +00:00
|
|
|
if (this.queueList[uuid].failed == 1 && $('#download_' + uuid + ' .queue_failed').length == 0) {
|
|
|
|
$('#download_' + uuid + ' .download_info_status').append(
|
|
|
|
`<span class="secondary-text inline-flex"><span class="download_slim_separator">(</span><span class="queue_failed_button inline-flex"><span class="queue_failed">1</span> <i class="material-icons">error_outline</i></span><span class="download_slim_separator">)</span></span>`
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
$('#download_' + uuid + ' .queue_failed').text(this.queueList[uuid].failed)
|
|
|
|
}
|
|
|
|
|
2020-07-23 14:18:28 +00:00
|
|
|
this.queueList[uuid].errors.push({ message: error, data: data, errid: errid })
|
2020-07-16 20:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (progress) {
|
|
|
|
this.queueList[uuid].progress = progress
|
|
|
|
$('#bar_' + uuid).css('width', progress + '%')
|
|
|
|
}
|
2020-08-14 17:49:36 +00:00
|
|
|
|
|
|
|
if (conversion) {
|
2020-09-15 20:44:29 +00:00
|
|
|
$('#bar_' + uuid).css('width', 100 - conversion + '%')
|
2020-08-14 17:49:36 +00:00
|
|
|
}
|
2020-07-16 20:20:13 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
removeFromQueue(uuid) {
|
2020-09-19 15:07:28 +00:00
|
|
|
console.log('this.removeFromQueue')
|
2020-07-16 20:20:13 +00:00
|
|
|
let index = this.queue.indexOf(uuid)
|
|
|
|
|
|
|
|
if (index > -1) {
|
2020-09-19 15:07:28 +00:00
|
|
|
this.$delete(this.queue, index)
|
|
|
|
|
2020-09-15 15:37:17 +00:00
|
|
|
$(`#download_${uuid}`).remove()
|
2020-09-19 15:07:28 +00:00
|
|
|
|
|
|
|
this.$delete(this.queueList, uuid)
|
2020-07-16 20:20:13 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
removeAllDownloads(currentItem) {
|
2020-09-19 15:07:28 +00:00
|
|
|
console.log('this.removeFromQueue')
|
2020-07-16 20:20:13 +00:00
|
|
|
this.queueComplete = []
|
|
|
|
|
2020-09-19 15:07:28 +00:00
|
|
|
let currentItemIsEmpty = currentItem === ''
|
|
|
|
|
|
|
|
if (currentItemIsEmpty) {
|
2020-07-16 20:20:13 +00:00
|
|
|
this.queue = []
|
|
|
|
this.queueList = {}
|
2020-09-19 15:07:28 +00:00
|
|
|
|
2020-07-16 20:20:13 +00:00
|
|
|
$(listEl).html('')
|
|
|
|
} else {
|
|
|
|
this.queue = [currentItem]
|
2020-09-19 15:07:28 +00:00
|
|
|
|
2020-07-16 20:20:13 +00:00
|
|
|
let tempQueueItem = this.queueList[currentItem]
|
2020-09-19 15:07:28 +00:00
|
|
|
|
2020-07-16 20:20:13 +00:00
|
|
|
this.queueList = {}
|
|
|
|
this.queueList[currentItem] = tempQueueItem
|
|
|
|
|
2020-09-15 20:44:29 +00:00
|
|
|
$('.download_object').each(function (index) {
|
2020-09-19 15:07:28 +00:00
|
|
|
if ($(this).attr('id') != 'download_' + currentItem) {
|
|
|
|
$(this).remove()
|
|
|
|
}
|
2020-07-16 20:20:13 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
removedFinishedDownloads() {
|
2020-09-19 15:07:28 +00:00
|
|
|
console.log('this.removedFinishedDownloads')
|
2020-07-16 20:20:13 +00:00
|
|
|
this.queueComplete.forEach(item => {
|
|
|
|
$('#download_' + item).remove()
|
|
|
|
})
|
|
|
|
|
|
|
|
this.queueComplete = []
|
|
|
|
},
|
2020-07-14 20:27:48 +00:00
|
|
|
toggleDownloadTab(clickEvent) {
|
|
|
|
this.setTabWidth()
|
|
|
|
|
|
|
|
this.$refs.container.style.transition = 'all 250ms ease-in-out'
|
|
|
|
|
|
|
|
// Toggle returns a Boolean based on the action it performed
|
|
|
|
let isHidden = this.$refs.container.classList.toggle('tab_hidden')
|
|
|
|
|
|
|
|
if (!isHidden) {
|
|
|
|
this.setTabWidth(this.cachedTabWidth)
|
|
|
|
}
|
|
|
|
|
|
|
|
localStorage.setItem('downloadTabOpen', !isHidden)
|
|
|
|
},
|
|
|
|
cleanQueue() {
|
2020-09-19 15:07:28 +00:00
|
|
|
console.log('this.cleanQueue')
|
2020-07-14 20:27:48 +00:00
|
|
|
socket.emit('removeFinishedDownloads')
|
|
|
|
},
|
|
|
|
cancelQueue() {
|
2020-09-19 15:07:28 +00:00
|
|
|
console.log('this.cancelQueue')
|
2020-07-14 20:27:48 +00:00
|
|
|
socket.emit('cancelAllDownloads')
|
|
|
|
},
|
2020-07-16 20:20:13 +00:00
|
|
|
finishDownload(uuid) {
|
2020-09-19 15:07:28 +00:00
|
|
|
console.log('this.finishDownload')
|
2020-07-16 20:20:13 +00:00
|
|
|
|
2020-09-19 15:07:28 +00:00
|
|
|
let isInQueue = this.queue.indexOf(uuid) > -1
|
2020-07-16 20:20:13 +00:00
|
|
|
|
2020-09-19 15:07:28 +00:00
|
|
|
if (!isInQueue) return
|
2020-07-16 20:20:13 +00:00
|
|
|
|
2020-09-19 15:07:28 +00:00
|
|
|
const resultIcon = $('#download_' + uuid).find('.queue_icon')
|
|
|
|
const noFailedDownloads = this.queueList[uuid].failed == 0
|
2020-07-16 20:20:13 +00:00
|
|
|
|
2020-09-19 15:07:28 +00:00
|
|
|
toast(this.$t('toasts.finishDownload', { item: this.queueList[uuid].title }), 'done')
|
2020-07-16 20:20:13 +00:00
|
|
|
|
2020-09-19 15:07:28 +00:00
|
|
|
$('#bar_' + uuid).css('width', '100%')
|
2020-07-16 20:20:13 +00:00
|
|
|
|
2020-09-19 15:07:28 +00:00
|
|
|
if (noFailedDownloads) {
|
|
|
|
resultIcon.text('done')
|
|
|
|
} else {
|
|
|
|
const failedButton = $('#download_' + uuid).find('.queue_failed_button')
|
2020-07-16 20:20:13 +00:00
|
|
|
|
2020-09-19 15:07:28 +00:00
|
|
|
resultIcon.addClass('clickable')
|
|
|
|
resultIcon.bind('click', { item: this.queueList[uuid] }, this.showErrorsTab)
|
|
|
|
|
|
|
|
failedButton.addClass('clickable')
|
|
|
|
failedButton.bind('click', { item: this.queueList[uuid] }, this.showErrorsTab)
|
2020-07-16 20:20:13 +00:00
|
|
|
|
2020-09-19 15:07:28 +00:00
|
|
|
if (this.queueList[uuid].failed >= this.queueList[uuid].size) {
|
|
|
|
resultIcon.text('error')
|
|
|
|
} else {
|
|
|
|
resultIcon.text('warning')
|
2020-07-16 20:20:13 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-19 15:07:28 +00:00
|
|
|
|
|
|
|
let index = this.queue.indexOf(uuid)
|
|
|
|
|
|
|
|
if (index > -1) {
|
|
|
|
this.queue.splice(index, 1)
|
|
|
|
this.queueComplete.push(uuid)
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.queue.length <= 0) {
|
|
|
|
toast(this.$t('toasts.allDownloaded'), 'done_all')
|
|
|
|
}
|
2020-07-16 20:20:13 +00:00
|
|
|
},
|
2020-07-14 20:27:48 +00:00
|
|
|
openDownloadsFolder() {
|
2020-09-17 21:55:57 +00:00
|
|
|
// if (this.clientMode) {
|
|
|
|
socket.emit('openDownloadsFolder')
|
|
|
|
// }
|
2020-07-14 20:27:48 +00:00
|
|
|
},
|
|
|
|
handleDrag(event) {
|
|
|
|
let newWidth = window.innerWidth - event.pageX + 2
|
|
|
|
|
|
|
|
if (newWidth < tabMinWidth) {
|
|
|
|
newWidth = tabMinWidth
|
|
|
|
} else if (newWidth > tabMaxWidth) {
|
|
|
|
newWidth = tabMaxWidth
|
|
|
|
}
|
|
|
|
|
|
|
|
this.cachedTabWidth = newWidth
|
|
|
|
this.setTabWidth(newWidth)
|
|
|
|
},
|
|
|
|
startDrag() {
|
|
|
|
document.addEventListener('mousemove', this.handleDrag)
|
2020-07-16 20:20:13 +00:00
|
|
|
},
|
|
|
|
startDownload(uuid) {
|
2020-09-19 15:07:28 +00:00
|
|
|
console.log('this.startDownload')
|
2020-07-16 20:20:13 +00:00
|
|
|
$('#bar_' + uuid)
|
2020-08-14 17:49:36 +00:00
|
|
|
.removeClass('converting')
|
|
|
|
.removeClass('indeterminate')
|
|
|
|
.addClass('determinate')
|
|
|
|
},
|
|
|
|
startConversion(uuid) {
|
2020-09-19 15:07:28 +00:00
|
|
|
console.log('this.startConversion')
|
2020-08-14 17:49:36 +00:00
|
|
|
$('#bar_' + uuid)
|
|
|
|
.addClass('converting')
|
2020-07-16 20:20:13 +00:00
|
|
|
.removeClass('indeterminate')
|
|
|
|
.addClass('determinate')
|
2020-08-19 15:40:33 +00:00
|
|
|
.css('width', '100%')
|
2020-07-16 20:20:13 +00:00
|
|
|
},
|
2020-09-19 15:07:28 +00:00
|
|
|
appendItem(queueItem) {
|
|
|
|
return
|
|
|
|
console.log('this.appendItem')
|
|
|
|
$(this.$refs.list).append(
|
|
|
|
`<div class="download_object" id="download_${queueItem.uuid}" data-deezerid="${queueItem.id}">
|
|
|
|
<div class="download_info">
|
|
|
|
<img width="75px" class="rounded coverart" src="${queueItem.cover}" alt="Cover ${queueItem.title}"/>
|
|
|
|
<div class="download_info_data">
|
|
|
|
<span class="download_line">${queueItem.title}</span> <span class="download_slim_separator"> - </span>
|
|
|
|
<span class="secondary-text">${queueItem.artist}</span>
|
|
|
|
</div>
|
|
|
|
<div class="download_info_status">
|
|
|
|
<span class="download_line"><span class="queue_downloaded">${queueItem.downloaded + queueItem.failed}</span>/${
|
|
|
|
queueItem.size
|
|
|
|
}</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="download_bar">
|
|
|
|
<div class="progress"><div id="bar_${queueItem.uuid}" class="indeterminate"></div></div>
|
|
|
|
<i class="material-icons queue_icon" data-uuid="${queueItem.uuid}">remove</i>
|
|
|
|
</div>
|
|
|
|
</div>`
|
|
|
|
)
|
|
|
|
},
|
2020-09-19 13:11:06 +00:00
|
|
|
async showErrorsTab(clickEvent) {
|
|
|
|
await this.setErrors(clickEvent.data.item)
|
|
|
|
|
|
|
|
this.$router.push({ name: 'Errors' })
|
2020-07-14 20:27:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|