@ -5,13 +5,29 @@
< template >
< NcEmptyContent class = "file-drop-empty-content"
data - cy - files - sharing - file - drop
: name = "t('files_sharing', 'File drop') " >
: name = "name " >
< template # icon >
< NcIconSvgWrapper :svg ="svgCloudUpload" / >
< / template >
< template # description >
{ { t ( 'files_sharing' , 'Upload files to {foldername}.' , { foldername } ) } }
{ { disclaimer === '' ? '' : t ( 'files_sharing' , 'By uploading files, you agree to the terms of service.' ) } }
< p >
{ { shareNote || t ( 'files_sharing' , 'Upload files to {foldername}.' , { foldername } ) } }
< / p >
< p v-if ="disclaimer" >
{ { t ( 'files_sharing' , 'By uploading files, you agree to the terms of service.' ) } }
< / p >
< NcNoteCard v -if = " getSortedUploads ( ) .length "
class = "file-drop-empty-content__note-card"
type = "success" >
< h2 id = "file-drop-empty-content__heading" >
{ { t ( 'files_sharing' , 'Successfully uploaded files' ) } }
< / h2 >
< ul aria -labelledby = " file -drop -empty -content__heading " class = "file-drop-empty-content__list" >
< li v-for ="file in getSortedUploads()" :key ="file" >
{ { file } }
< / li >
< / ul >
< / NcNoteCard >
< / template >
< template # action >
< template v-if ="disclaimer" >
@ -34,16 +50,24 @@
< / NcEmptyContent >
< / template >
< script lang = "ts" >
/* eslint-disable import/first */
/ / W e n e e d t h i s o n m o d u l e l e v e l r a t h e r t h a n o n t h e i n s t a n c e a s v i e w w i l l b e r e f r e s h e d b y t h e f i l e s a p p a f t e r u p l o a d i n g
const uploads = new Set < string > ( )
< / script >
< script setup lang = "ts" >
import { loadState } from '@nextcloud/initial-state'
import { translate as t } from '@nextcloud/l10n'
import { getUploader , UploadPicker } from '@nextcloud/upload'
import { getUploader , UploadPicker , UploadStatus } from '@nextcloud/upload'
import { ref } from 'vue'
import NcButton from '@nextcloud/vue/components/NcButton'
import NcDialog from '@nextcloud/vue/components/NcDialog'
import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent'
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
import svgCloudUpload from '@mdi/svg/svg/cloud-upload.svg?raw'
defineProps < {
@ -51,17 +75,62 @@ defineProps<{
} > ( )
const disclaimer = loadState < string > ( 'files_sharing' , 'disclaimer' , '' )
const shareLabel = loadState < string > ( 'files_sharing' , 'label' , '' )
const shareNote = loadState < string > ( 'files_sharing' , 'note' , '' )
const name = shareLabel || t ( 'files_sharing' , 'File drop' )
const showDialog = ref ( false )
const uploadDestination = getUploader ( ) . destination
< / script >
< style scoped >
: deep ( . terms - of - service - dialog ) {
min - height : min ( 100 px , 20 vh ) ;
getUploader ( )
. addNotifier ( ( upload ) => {
if ( upload . status === UploadStatus . FINISHED && upload . file . name ) {
/ / i f a u p l o a d i s f i n i s h e d a n d i s n o t a m e t a u p l o a d ( n a m e i s s e t )
/ / t h e n w e a d d t h e u p l o a d t o t h e l i s t o f f i n i s h e d u p l o a d s t o b e s h o w n t o t h e u s e r
uploads . add ( upload . file . name )
}
} )
/ * *
* Get the previous uploads as sorted list
* /
function getSortedUploads ( ) {
return [ ... uploads ] . sort ( ( a , b ) => a . localeCompare ( b ) )
}
/* TODO fix in library */
. file - drop - empty - content : deep ( . empty - content__action ) {
display : flex ;
gap : var ( -- default - grid - baseline ) ;
< / script >
< style scoped lang = "scss" >
. file - drop - empty - content {
margin : auto ;
max - width : max ( 50 vw , 300 px ) ;
. file - drop - empty - content__note - card {
width : fit - content ;
margin - inline : auto ;
}
# file - drop - empty - content__heading {
margin - block : 0 10 px ;
font - weight : bold ;
font - size : 20 px ;
}
. file - drop - empty - content__list {
list - style : inside ;
max - height : min ( 350 px , 33 vh ) ;
overflow - y : scroll ;
padding - inline - end : calc ( 2 * var ( -- default - grid - baseline ) ) ;
}
: deep ( . terms - of - service - dialog ) {
min - height : min ( 100 px , 20 vh ) ;
}
/* TODO fix in library */
: deep ( . empty - content__action ) {
display : flex ;
gap : var ( -- default - grid - baseline ) ;
}
}
< / style >