From c9c6d6122af9a4e17d5812994ff69c076561d5ce Mon Sep 17 00:00:00 2001 From: Georgios Lignos Date: Thu, 21 Jan 2021 15:01:50 +0100 Subject: [PATCH] deposit-ui: makes the displayed size limit dynamic * Changes display file size measurement unit to ^10 instead of ^2 * Adds additional support link in the footer --- .../static/js/zenodo_deposit/filters.js | 33 ++++++++++++++++++- .../static/templates/zenodo_deposit/list.html | 10 ++++-- .../templates/zenodo_deposit/edit.html | 3 +- .../theme/templates/zenodo_theme/footer.html | 1 + 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/zenodo/modules/deposit/static/js/zenodo_deposit/filters.js b/zenodo/modules/deposit/static/js/zenodo_deposit/filters.js index fe3e48724..e2180ef74 100644 --- a/zenodo/modules/deposit/static/js/zenodo_deposit/filters.js +++ b/zenodo/modules/deposit/static/js/zenodo_deposit/filters.js @@ -120,6 +120,36 @@ function formatOpenAIRECommunities() { }; } +function fileSizeFormat() { + + function filter(size) { + function round(num, precision) { + return Math.round( + num * Math.pow(10, precision)) / Math.pow(10, precision + ); + } + var limit = Math.pow(1000, 4); + if (size > limit) { + return round(size / limit, 1) + ' TB'; + } else if (size > (limit/=1000)) { + return round(size / limit, 1) + ' GB'; + } else if (size > (limit/=1000)) { + return round(size / limit, 1) + ' MB'; + } else if (size > 1000) { + return Math.round(size / 1000) + ' kB'; + } + if (size === 1) { + return "1 Byte" + } + return size + ' Bytes'; + } + + //////////// + + return filter; +} + + angular.module('invenioRecords') .filter('fieldtitle', fieldtitle) .filter('notIn', notIn) @@ -128,4 +158,5 @@ angular.module('invenioRecords') .filter('striptags', striptags) .filter('stable', stable) .filter('checkAllFilesUploaded',checkAllFilesUploaded) - .filter('formatOpenAIRECommunities', formatOpenAIRECommunities); + .filter('formatOpenAIRECommunities', formatOpenAIRECommunities) + .filter('fileSizeFormat', fileSizeFormat); diff --git a/zenodo/modules/deposit/static/templates/zenodo_deposit/list.html b/zenodo/modules/deposit/static/templates/zenodo_deposit/list.html index b8641fbc9..3a19dcadf 100644 --- a/zenodo/modules/deposit/static/templates/zenodo_deposit/list.html +++ b/zenodo/modules/deposit/static/templates/zenodo_deposit/list.html @@ -56,7 +56,7 @@ {{ f.key | limitTo:50 }} ...
{{f.checksum}}
- {{ f.size | bytesToHumanReadable }} + {{ f.size | fileSizeFormat }} {{ f.progress }} % Processing... @@ -98,9 +98,13 @@

- (minimum 1 file required, max 50 GB per dataset - contact us for larger datasets) + (minimum 1 file required, max {{ recordsVM.invenioRecordsArgs.templateParams.max_bucket_size | fileSizeFormat }} per dataset - contact us for larger datasets)

+

+ + If you're experiencing issues with uploading larger files, read our FAQ section on file upload issues. +

{{ f.key | limitTo:50 }} ... {{ f.key | limitTo:50 }} ... - {{ f.size | bytesToHumanReadable }} + {{ f.size | fileSizeFormat }} {{ f.checksum }} diff --git a/zenodo/modules/deposit/templates/zenodo_deposit/edit.html b/zenodo/modules/deposit/templates/zenodo_deposit/edit.html index fd8082d81..ed5f70d51 100644 --- a/zenodo/modules/deposit/templates/zenodo_deposit/edit.html +++ b/zenodo/modules/deposit/templates/zenodo_deposit/edit.html @@ -88,7 +88,8 @@ 'has_versioning_permissions': has_versioning_permissions or False, 'has_new_version_deposit': has_new_version_deposit or False, 'newversionmodal_template': url_for('static', filename='templates/zenodo_deposit/neweversionmodal.html'), - 'upgradeversioningmodal_template': url_for('static', filename='templates/zenodo_deposit/upgradeversioningmodal.html') + 'upgradeversioningmodal_template': url_for('static', filename='templates/zenodo_deposit/upgradeversioningmodal.html'), + 'max_bucket_size': record.files.bucket.quota_size if record.files else 50000000000 } %} diff --git a/zenodo/modules/theme/templates/zenodo_theme/footer.html b/zenodo/modules/theme/templates/zenodo_theme/footer.html index d58e7aff7..e27157019 100644 --- a/zenodo/modules/theme/templates/zenodo_theme/footer.html +++ b/zenodo/modules/theme/templates/zenodo_theme/footer.html @@ -48,6 +48,7 @@
{{_('Help')}}