2021-08-18 00:01:11 +02:00
|
|
|
<template>
|
2021-08-25 03:24:40 +02:00
|
|
|
<div v-show="isScanning" class="fixed bottom-4 left-0 right-0 mx-auto z-20 max-w-lg">
|
2021-08-18 00:01:11 +02:00
|
|
|
<div class="w-full my-1 rounded-lg drop-shadow-lg px-4 py-2 flex items-center justify-center text-center transition-all border border-white border-opacity-40 shadow-md bg-warning">
|
|
|
|
<p class="text-lg font-sans" v-html="text" />
|
|
|
|
</div>
|
2021-08-25 03:24:40 +02:00
|
|
|
<div v-show="!hasCanceled" class="absolute right-0 top-3 bottom-0 px-2">
|
|
|
|
<ui-btn color="red-600" small :padding-x="1" @click="cancelScan">Cancel</ui-btn>
|
|
|
|
</div>
|
2021-08-18 00:01:11 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
2021-08-25 03:24:40 +02:00
|
|
|
return {
|
|
|
|
hasCanceled: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
isScanning(newVal) {
|
|
|
|
if (newVal) {
|
|
|
|
this.hasCanceled = false
|
|
|
|
}
|
|
|
|
}
|
2021-08-18 00:01:11 +02:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
text() {
|
2021-08-25 03:24:40 +02:00
|
|
|
var scanText = this.isScanningFiles ? 'Scanning...' : 'Scanning Covers...'
|
|
|
|
return `${scanText} <span class="font-mono">${this.scanNum}</span> of <span class="font-mono">${this.scanTotal}</span> <strong class='font-mono px-2'>${this.scanPercent}</strong>`
|
2021-08-18 00:01:11 +02:00
|
|
|
},
|
|
|
|
isScanning() {
|
2021-08-25 03:24:40 +02:00
|
|
|
return this.isScanningFiles || this.isScanningCovers
|
|
|
|
},
|
|
|
|
isScanningFiles() {
|
2021-08-18 00:01:11 +02:00
|
|
|
return this.$store.state.isScanning
|
|
|
|
},
|
2021-08-25 03:24:40 +02:00
|
|
|
isScanningCovers() {
|
|
|
|
return this.$store.state.isScanningCovers
|
|
|
|
},
|
|
|
|
scanProgressKey() {
|
|
|
|
return this.isScanningFiles ? 'scanProgress' : 'coverScanProgress'
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
scanProgress() {
|
2021-08-25 03:24:40 +02:00
|
|
|
return this.$store.state[this.scanProgressKey]
|
2021-08-18 00:01:11 +02:00
|
|
|
},
|
|
|
|
scanPercent() {
|
|
|
|
return this.scanProgress ? this.scanProgress.progress + '%' : '0%'
|
|
|
|
},
|
|
|
|
scanNum() {
|
|
|
|
return this.scanProgress ? this.scanProgress.done : 0
|
|
|
|
},
|
|
|
|
scanTotal() {
|
|
|
|
return this.scanProgress ? this.scanProgress.total : 0
|
|
|
|
}
|
|
|
|
},
|
2021-08-25 03:24:40 +02:00
|
|
|
methods: {
|
|
|
|
cancelScan() {
|
|
|
|
this.hasCanceled = true
|
|
|
|
this.$root.socket.emit('cancel_scan')
|
|
|
|
}
|
|
|
|
},
|
2021-08-18 00:01:11 +02:00
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|