feat: add download size on modal download button
This commit is contained in:
parent
822bf92a47
commit
47e44bdaf5
@ -40,6 +40,7 @@
|
|||||||
:image="modalEpisode.image"
|
:image="modalEpisode.image"
|
||||||
:link="modalEpisode.link"
|
:link="modalEpisode.link"
|
||||||
:name="modalEpisode.name"
|
:name="modalEpisode.name"
|
||||||
|
:size="modalEpisode.size"
|
||||||
:title="title"
|
:title="title"
|
||||||
:url="modalEpisode.url" />
|
:url="modalEpisode.url" />
|
||||||
</NcModal>
|
</NcModal>
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
<template #icon>
|
<template #icon>
|
||||||
<Download :size="20" />
|
<Download :size="20" />
|
||||||
</template>
|
</template>
|
||||||
{{ t('repod', 'Download') }}
|
{{ t('repod', 'Download') }} {{ size ? `(${humanFileSize(size)})` : '' }}
|
||||||
</NcButton>
|
</NcButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -32,6 +32,7 @@
|
|||||||
import { NcAvatar, NcButton } from '@nextcloud/vue'
|
import { NcAvatar, NcButton } from '@nextcloud/vue'
|
||||||
import Download from 'vue-material-design-icons/Download.vue'
|
import Download from 'vue-material-design-icons/Download.vue'
|
||||||
import OpenInNew from 'vue-material-design-icons/OpenInNew.vue'
|
import OpenInNew from 'vue-material-design-icons/OpenInNew.vue'
|
||||||
|
import { humanFileSize } from '../../utils/size.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Modal',
|
name: 'Modal',
|
||||||
@ -66,6 +67,10 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
size: {
|
||||||
|
type: Number,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
strippedDescription() {
|
strippedDescription() {
|
||||||
@ -75,6 +80,9 @@ export default {
|
|||||||
return strippedDescription.replace(/\n/g, '<br>')
|
return strippedDescription.replace(/\n/g, '<br>')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
humanFileSize,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
// https://stackoverflow.com/a/53486112
|
// https://stackoverflow.com/a/53486112
|
||||||
|
|
||||||
export const debounce = (fn, delay) => {
|
export const debounce = (fn, delay) => {
|
||||||
let timeoutID = null
|
let timeoutID = null
|
||||||
return function() {
|
return function() {
|
||||||
|
5
src/utils/size.js
Normal file
5
src/utils/size.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// https://stackoverflow.com/a/20732091
|
||||||
|
export const humanFileSize = (size) => {
|
||||||
|
const i = size === 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024))
|
||||||
|
return (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user