Merge branch 'feature/fix-chocobozzz' into 'master'

Add user quota by instance

See merge request framasoft/joinpeertube!16
This commit is contained in:
Chocobozzz 2018-03-30 11:35:25 +02:00
commit 8e2d076e10
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 :
hugo server -D -b "http://localhost:1313/"
$ make serve

View file

@ -76,6 +76,13 @@ $(function () {
rightDiv.append(li)
}
if (instance.userVideoQuota) {
const li = $('<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
}
})