From 980bb45bb088121fd284d69d01d21d010bef0ed3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 28 Mar 2018 14:40:42 +0200 Subject: [PATCH] Add user quota by instance --- README.md | 2 +- .../static/js/instances.js | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4e6049a..d121efc 100644 --- a/README.md +++ b/README.md @@ -7,5 +7,5 @@ Homepage of [joinpeertube.org](https://joinpeertube.org) based on [Hugo](https:/ To see your changes in action, run : - hugo server -D -b "http://localhost:1313/" + $ make serve diff --git a/themes/hugo-bootstrap-premium/static/js/instances.js b/themes/hugo-bootstrap-premium/static/js/instances.js index 0ca65a6..81261ce 100644 --- a/themes/hugo-bootstrap-premium/static/js/instances.js +++ b/themes/hugo-bootstrap-premium/static/js/instances.js @@ -76,6 +76,13 @@ $(function () { rightDiv.append(li) } + if (instance.userVideoQuota) { + const li = $('
  • ', { + text: bytes(instance.userVideoQuota) + ' per user' + }) + rightDiv.append(li) + } + a.append(leftDiv, rightDiv) return a @@ -90,4 +97,20 @@ $(function () { return a } + + // https://github.com/danrevah/ngx-pipes/blob/master/src/pipes/math/bytes.ts + const dictionaryBytes = [ + { max: 1024, type: 'B' }, + { max: 1048576, type: 'KB' }, + { max: 1073741824, type: 'MB' }, + { max: 1.0995116e12, type: 'GB' } + ] + function bytes (value) { + if (value === -1) return 'No quota' + + const format = dictionaryBytes.find(function (d) { return value < d.max }) || dictionaryBytes[dictionaryBytes.length - 1] + const calc = Math.floor(value / (format.max / 1024)).toString() + + return calc + format.type + } })