Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions cds/modules/theme/assets/bootstrap3/js/cds/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ angular.module("cdsDeposit", [
"mgcrea.ngStrap.tooltip",
"ngFileUpload",
"monospaced.elastic",
"invenioFiles.filters",
"afkl.lazyImage",
"hl.sticky",
"duScroll",
Expand Down
1 change: 0 additions & 1 deletion cds/modules/theme/assets/bootstrap3/js/cds_records/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ angular.element(document).ready(function () {
"cds",
"ngModal",
"ngclipboard",
"invenioFiles.filters",
"ngSanitize",
],
{ strictDi: true }
Expand Down
1 change: 1 addition & 0 deletions cds/modules/theme/webpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down