Add user quota by instance

This commit is contained in:
Chocobozzz 2018-03-28 14:40:42 +02:00
parent 9683df8656
commit 980bb45bb0
No known key found for this signature in database
GPG key ID: 583A612D890159BE
2 changed files with 24 additions and 1 deletions

View file

@ -7,5 +7,5 @@ Homepage of [joinpeertube.org](https://joinpeertube.org) based on [Hugo](https:/
To see your changes in action, run : To see your changes in action, run :
hugo server -D -b "http://localhost:1313/" $ make serve

View file

@ -76,6 +76,13 @@ $(function () {
rightDiv.append(li) rightDiv.append(li)
} }
if (instance.userVideoQuota) {
const li = $('<li>', {
text: bytes(instance.userVideoQuota) + ' per user'
})
rightDiv.append(li)
}
a.append(leftDiv, rightDiv) a.append(leftDiv, rightDiv)
return a return a
@ -90,4 +97,20 @@ $(function () {
return a 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
}
}) })