|
|
@ -54,12 +54,12 @@ fileUpload = function(filesToUpload) { |
|
|
|
function consume() { |
|
|
|
function consume() { |
|
|
|
const file = files.pop(); |
|
|
|
const file = files.pop(); |
|
|
|
if ((file == null)) { |
|
|
|
if ((file == null)) { |
|
|
|
swal.close(); |
|
|
|
modal.close(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!RocketChat.fileUploadIsValidContentType(file.file.type)) { |
|
|
|
if (!RocketChat.fileUploadIsValidContentType(file.file.type)) { |
|
|
|
swal({ |
|
|
|
modal.open({ |
|
|
|
title: t('FileUpload_MediaType_NotAccepted'), |
|
|
|
title: t('FileUpload_MediaType_NotAccepted'), |
|
|
|
text: file.file.type || `*.${ s.strRightBack(file.file.name, '.') }`, |
|
|
|
text: file.file.type || `*.${ s.strRightBack(file.file.name, '.') }`, |
|
|
|
type: 'error', |
|
|
|
type: 'error', |
|
|
@ -69,7 +69,7 @@ fileUpload = function(filesToUpload) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (file.file.size === 0) { |
|
|
|
if (file.file.size === 0) { |
|
|
|
swal({ |
|
|
|
modal.open({ |
|
|
|
title: t('FileUpload_File_Empty'), |
|
|
|
title: t('FileUpload_File_Empty'), |
|
|
|
type: 'error', |
|
|
|
type: 'error', |
|
|
|
timer: 1000 |
|
|
|
timer: 1000 |
|
|
@ -89,8 +89,12 @@ fileUpload = function(filesToUpload) { |
|
|
|
</audio> |
|
|
|
</audio> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class='upload-preview-title'> |
|
|
|
<div class='upload-preview-title'> |
|
|
|
<input id='file-name' style='display: inherit;' value='${ Handlebars._escape(file.name) }' placeholder='${ t('Upload_file_name') }'> |
|
|
|
<div class="rc-input__wrapper"> |
|
|
|
<input id='file-description' style='display: inherit;' value='' placeholder='${ t('Upload_file_description') }'> |
|
|
|
<input class="rc-input__element" id='file-name' style='display: inherit;' value='${ Handlebars._escape(file.name) }' placeholder='${ t('Upload_file_name') }'> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="rc-input__wrapper"> |
|
|
|
|
|
|
|
<input class="rc-input__element" id='file-description' style='display: inherit;' value='' placeholder='${ t('Upload_file_description') }'> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div>`; |
|
|
|
</div>`; |
|
|
|
} else if (file.type === 'video') { |
|
|
|
} else if (file.type === 'video') { |
|
|
|
text = `\
|
|
|
|
text = `\
|
|
|
@ -101,8 +105,12 @@ fileUpload = function(filesToUpload) { |
|
|
|
</video> |
|
|
|
</video> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class='upload-preview-title'> |
|
|
|
<div class='upload-preview-title'> |
|
|
|
<input id='file-name' style='display: inherit;' value='${ Handlebars._escape(file.name) }' placeholder='${ t('Upload_file_name') }'> |
|
|
|
<div class="rc-input__wrapper"> |
|
|
|
<input id='file-description' style='display: inherit;' value='' placeholder='${ t('Upload_file_description') }'> |
|
|
|
<input class="rc-input__element" id='file-name' style='display: inherit;' value='${ Handlebars._escape(file.name) }' placeholder='${ t('Upload_file_name') }'> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="rc-input__wrapper"> |
|
|
|
|
|
|
|
<input class="rc-input__element" id='file-description' style='display: inherit;' value='' placeholder='${ t('Upload_file_description') }'> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div>`; |
|
|
|
</div>`; |
|
|
|
} else if (file.type === 'image') { |
|
|
|
} else if (file.type === 'image') { |
|
|
|
text = `\
|
|
|
|
text = `\
|
|
|
@ -110,8 +118,12 @@ fileUpload = function(filesToUpload) { |
|
|
|
<div class='upload-preview-file' style='background-image: url(${ preview })'></div> |
|
|
|
<div class='upload-preview-file' style='background-image: url(${ preview })'></div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class='upload-preview-title'> |
|
|
|
<div class='upload-preview-title'> |
|
|
|
<input id='file-name' style='display: inherit;' value='${ Handlebars._escape(file.name) }' placeholder='${ t('Upload_file_name') }'> |
|
|
|
<div class="rc-input__wrapper"> |
|
|
|
<input id='file-description' style='display: inherit;' value='' placeholder='${ t('Upload_file_description') }'> |
|
|
|
<input class="rc-input__element" id='file-name' style='display: inherit;' value='${ Handlebars._escape(file.name) }' placeholder='${ t('Upload_file_name') }'> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="rc-input__wrapper"> |
|
|
|
|
|
|
|
<input class="rc-input__element" id='file-description' style='display: inherit;' value='' placeholder='${ t('Upload_file_description') }'> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div>`; |
|
|
|
</div>`; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const fileSize = formatBytes(file.file.size); |
|
|
|
const fileSize = formatBytes(file.file.size); |
|
|
@ -121,12 +133,16 @@ fileUpload = function(filesToUpload) { |
|
|
|
<div>${ Handlebars._escape(file.name) } - ${ fileSize }</div> |
|
|
|
<div>${ Handlebars._escape(file.name) } - ${ fileSize }</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class='upload-preview-title'> |
|
|
|
<div class='upload-preview-title'> |
|
|
|
<input id='file-name' style='display: inherit;' value='${ Handlebars._escape(file.name) }' placeholder='${ t('Upload_file_name') }'> |
|
|
|
<div class="rc-input__wrapper"> |
|
|
|
<input id='file-description' style='display: inherit;' value='' placeholder='${ t('Upload_file_description') }'> |
|
|
|
<input class="rc-input__element" id='file-name' style='display: inherit;' value='${ Handlebars._escape(file.name) }' placeholder='${ t('Upload_file_name') }'> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="rc-input__wrapper"> |
|
|
|
|
|
|
|
<input class="rc-input__element" id='file-description' style='display: inherit;' value='' placeholder='${ t('Upload_file_description') }'> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div>`; |
|
|
|
</div>`; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return swal({ |
|
|
|
return modal.open({ |
|
|
|
title: t('Upload_file_question'), |
|
|
|
title: t('Upload_file_question'), |
|
|
|
text, |
|
|
|
text, |
|
|
|
showCancelButton: true, |
|
|
|
showCancelButton: true, |
|
|
@ -136,10 +152,6 @@ fileUpload = function(filesToUpload) { |
|
|
|
cancelButtonText: t('Cancel'), |
|
|
|
cancelButtonText: t('Cancel'), |
|
|
|
html: true |
|
|
|
html: true |
|
|
|
}, function(isConfirm) { |
|
|
|
}, function(isConfirm) { |
|
|
|
consume(); |
|
|
|
|
|
|
|
if (!isConfirm) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const record = { |
|
|
|
const record = { |
|
|
|
name: document.getElementById('file-name').value || file.name || file.file.name, |
|
|
|
name: document.getElementById('file-name').value || file.name || file.file.name, |
|
|
@ -149,6 +161,10 @@ fileUpload = function(filesToUpload) { |
|
|
|
description: document.getElementById('file-description').value |
|
|
|
description: document.getElementById('file-description').value |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
consume(); |
|
|
|
|
|
|
|
if (!isConfirm) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
const upload = fileUploadHandler('Uploads', record, file.file); |
|
|
|
const upload = fileUploadHandler('Uploads', record, file.file); |
|
|
|
|
|
|
|
|
|
|
|
let uploading = Session.get('uploading') || []; |
|
|
|
let uploading = Session.get('uploading') || []; |
|
|
|