mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Format network bit rates.
This commit is contained in:
parent
82ff9624dc
commit
bc21f5d261
2 changed files with 12 additions and 5 deletions
|
@ -16,6 +16,13 @@ app = Sammy('#main', function (sam) {
|
|||
Handlebars.registerHelper('humanTime', function(time) {
|
||||
return Math.round(time) + 's';
|
||||
});
|
||||
Handlebars.registerHelper('bitRate', function(bytes, time) {
|
||||
var sizes = ['b', 'Kb', 'Mb', 'Gb', 'Tb'];
|
||||
if (time == 0) return 'n/a';
|
||||
var bps = bytes / time * 8;
|
||||
var i = parseInt(Math.floor(Math.log(bps) / Math.log(1024)));
|
||||
return Math.round(bps / Math.pow(1024, i), 2) + ' ' + sizes[[i]] + '/s';
|
||||
});
|
||||
|
||||
|
||||
// Look for supported type of storage to use
|
||||
|
|
|
@ -149,17 +149,17 @@
|
|||
<table class="table table-condensed">
|
||||
<tr>
|
||||
<td><span class="glyphicon glyphicon-cloud-download"> Rx</span></td>
|
||||
<td>{{humanSize rx}}</td>
|
||||
<td>{{bitRate rx time_since_update}}</td>
|
||||
<td>{{humanSize cumulative_rx}} (cumulative)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="glyphicon glyphicon-cloud-upload"> Tx</td>
|
||||
<td>{{humanSize tx}}</td>
|
||||
<td>{{bitRate tx time_since_update}}</td>
|
||||
<td>{{humanSize cumulative_tx}} (cumulative)</td>
|
||||
</tr>
|
||||
<tr class="active">
|
||||
<td>Cx</td>
|
||||
<td>{{humanSize cx}}</td>
|
||||
<td>Rx + Tx</td>
|
||||
<td>{{bitRate cx time_since_update}}</td>
|
||||
<td>{{humanSize cumulative_cx}} (cumulative)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -229,4 +229,4 @@
|
|||
Check <a href="/#/services/glances">glances</a> service status.
|
||||
</div>
|
||||
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
Loading…
Add table
Reference in a new issue