add file size to log file view

This commit is contained in:
Moritz Schmidt 2017-10-01 17:24:06 +02:00 committed by Björn Dahlgren
parent b1bb295d57
commit f5e3755c51
4 changed files with 11 additions and 3 deletions

View File

@ -1,5 +1,6 @@
var async = require('async')
var fs = require('fs.extra')
var filesize = require('filesize')
var path = require('path')
var userhome = require('userhome')
@ -62,6 +63,7 @@ Logs.prototype.logFiles = function (callback) {
async.filter(files, function (file, cb) {
fs.stat(file.path, function (err, stat) {
file.formattedSize = filesize(stat.size)
file.size = stat.size
cb(!err && stat.isFile())
})

View File

@ -8,7 +8,9 @@ define(function (require) {
return Backbone.Model.extend({
defaults: {
name: ''
name: '',
formattedSize: '0 B',
size: 0,
}
});

View File

@ -1,7 +1,8 @@
<table class="table table-striped">
<thead>
<tr>
<th>Log</th>
<th width="100%">Filename</th>
<th>Size</th>
</tr>
</thead>

View File

@ -1,3 +1,6 @@
<td style="width: 100%;">
<td>
<a href='/api/logs/<%-name%>'><%-name%></a>
</td>
<td style="text-align: right; white-space: nowrap;">
<%-formattedSize%>
</td>