diff --git a/cds/modules/theme/assets/bootstrap3/js/cds/module.js b/cds/modules/theme/assets/bootstrap3/js/cds/module.js index 3d6493724..c1ccb069d 100644 --- a/cds/modules/theme/assets/bootstrap3/js/cds/module.js +++ b/cds/modules/theme/assets/bootstrap3/js/cds/module.js @@ -193,6 +193,28 @@ app.filter("toMinutes", function () { }; }); +app.filter("bytesToHumanReadable", function () { + function filter(size) { + function round(num, precision) { + return Math.round( + num * Math.pow(10, precision)) / Math.pow(10, precision + ); + } + var limit = Math.pow(1024, 4); + if (size > limit) { + return round(size / limit, 1) + ' TB'; + } else if (size > (limit/=1024)) { + return round(size / limit, 1) + ' GB'; + } else if (size > (limit/=1024)) { + return round(size / limit, 1) + ' MB'; + } else if (size > 1024) { + return Math.round(size / 1024) + ' KB'; + } + return size + ' B'; + } + return filter; +}); + app.filter("findBy", function () { return function (data, key, value) { if (!_.isEmpty(data)) { diff --git a/cds/modules/theme/assets/bootstrap3/js/cds_deposit/avc/avc.module.js b/cds/modules/theme/assets/bootstrap3/js/cds_deposit/avc/avc.module.js index 61836cdc6..ff8abe6ea 100644 --- a/cds/modules/theme/assets/bootstrap3/js/cds_deposit/avc/avc.module.js +++ b/cds/modules/theme/assets/bootstrap3/js/cds_deposit/avc/avc.module.js @@ -285,7 +285,6 @@ angular.module("cdsDeposit", [ "mgcrea.ngStrap.tooltip", "ngFileUpload", "monospaced.elastic", - "invenioFiles.filters", "afkl.lazyImage", "hl.sticky", "duScroll", diff --git a/cds/modules/theme/assets/bootstrap3/js/cds_records/app.js b/cds/modules/theme/assets/bootstrap3/js/cds_records/app.js index e71424057..d89ede1e0 100644 --- a/cds/modules/theme/assets/bootstrap3/js/cds_records/app.js +++ b/cds/modules/theme/assets/bootstrap3/js/cds_records/app.js @@ -40,7 +40,6 @@ angular.element(document).ready(function () { "cds", "ngModal", "ngclipboard", - "invenioFiles.filters", "ngSanitize", ], { strictDi: true } diff --git a/cds/modules/theme/webpack.py b/cds/modules/theme/webpack.py index 420a08ca9..d38315938 100644 --- a/cds/modules/theme/webpack.py +++ b/cds/modules/theme/webpack.py @@ -77,6 +77,7 @@ "invenio-search-js": "^1.5.4", "invenio-charts-js": "^0.2.7", "invenio-records-js": "~0.0.8", + # TODO: check if we can remove invenio-files-js "invenio-files-js": "~0.0.2", "ng-file-upload": "~12.0.4", "jquery": "~3.2.1",