From f5e3755c510eff091933bd4a22c85244817d3f7c Mon Sep 17 00:00:00 2001 From: Moritz Schmidt Date: Sun, 1 Oct 2017 17:24:06 +0200 Subject: [PATCH] add file size to log file view --- lib/logs.js | 2 ++ public/js/app/models/log.js | 4 +++- public/js/tpl/logs/list.html | 3 ++- public/js/tpl/logs/list_item.html | 5 ++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/logs.js b/lib/logs.js index 3d5da90..71ecf35 100644 --- a/lib/logs.js +++ b/lib/logs.js @@ -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()) }) diff --git a/public/js/app/models/log.js b/public/js/app/models/log.js index a096958..41dc7a0 100644 --- a/public/js/app/models/log.js +++ b/public/js/app/models/log.js @@ -8,7 +8,9 @@ define(function (require) { return Backbone.Model.extend({ defaults: { - name: '' + name: '', + formattedSize: '0 B', + size: 0, } }); diff --git a/public/js/tpl/logs/list.html b/public/js/tpl/logs/list.html index ae1989d..0b1861e 100644 --- a/public/js/tpl/logs/list.html +++ b/public/js/tpl/logs/list.html @@ -1,7 +1,8 @@ - + + diff --git a/public/js/tpl/logs/list_item.html b/public/js/tpl/logs/list_item.html index 503c93c..e0987ce 100644 --- a/public/js/tpl/logs/list_item.html +++ b/public/js/tpl/logs/list_item.html @@ -1,3 +1,6 @@ - +
LogFilenameSize
+ <%-name%> + <%-formattedSize%> +