Attachment size, changed calculation to npm filesize (Version Info)

This commit is contained in:
Martin Filser 2022-04-29 12:02:51 +02:00
parent 464bc2f87b
commit 20c2679dc8
2 changed files with 18 additions and 21 deletions

View file

@ -58,38 +58,38 @@ template(name='statistics')
td {{numFormat statistics.os.loadavg.[0]}}, {{numFormat statistics.os.loadavg.[1]}}, {{numFormat statistics.os.loadavg.[2]}}
tr
th {{_ 'OS_Totalmem'}}
td {{bytesToSize statistics.os.totalmem}}
td {{fileSize statistics.os.totalmem}}
tr
th {{_ 'OS_Freemem'}}
td {{bytesToSize statistics.os.freemem}}
td {{fileSize statistics.os.freemem}}
tr
th {{_ 'OS_Cpus'}}
td {{statistics.os.cpus.length}}
unless isSandstorm
tr
th {{_ 'Node_heap_total_heap_size'}}
td {{bytesToSize statistics.nodeHeapStats.totalHeapSize}}
td {{fileSize statistics.nodeHeapStats.totalHeapSize}}
tr
th {{_ 'Node_heap_total_heap_size_executable'}}
td {{bytesToSize statistics.nodeHeapStats.totalHeapSizeExecutable}}
td {{fileSize statistics.nodeHeapStats.totalHeapSizeExecutable}}
tr
th {{_ 'Node_heap_total_physical_size'}}
td {{bytesToSize statistics.nodeHeapStats.totalPhysicalSize}}
td {{fileSize statistics.nodeHeapStats.totalPhysicalSize}}
tr
th {{_ 'Node_heap_total_available_size'}}
td {{bytesToSize statistics.nodeHeapStats.totalAvailableSize}}
td {{fileSize statistics.nodeHeapStats.totalAvailableSize}}
tr
th {{_ 'Node_heap_used_heap_size'}}
td {{bytesToSize statistics.nodeHeapStats.usedHeapSize}}
td {{fileSize statistics.nodeHeapStats.usedHeapSize}}
tr
th {{_ 'Node_heap_heap_size_limit'}}
td {{bytesToSize statistics.nodeHeapStats.heapSizeLimit}}
td {{fileSize statistics.nodeHeapStats.heapSizeLimit}}
tr
th {{_ 'Node_heap_malloced_memory'}}
td {{bytesToSize statistics.nodeHeapStats.mallocedMemory}}
td {{fileSize statistics.nodeHeapStats.mallocedMemory}}
tr
th {{_ 'Node_heap_peak_malloced_memory'}}
td {{bytesToSize statistics.nodeHeapStats.peakMallocedMemory}}
td {{fileSize statistics.nodeHeapStats.peakMallocedMemory}}
tr
th {{_ 'Node_heap_does_zap_garbage'}}
td {{statistics.nodeHeapStats.doesZapGarbage}}
@ -101,13 +101,13 @@ template(name='statistics')
td {{statistics.nodeHeapStats.numberOfDetachedContexts}}
tr
th {{_ 'Node_memory_usage_rss'}}
td {{bytesToSize statistics.nodeMemoryUsage.rss}}
td {{fileSize statistics.nodeMemoryUsage.rss}}
tr
th {{_ 'Node_memory_usage_heap_total'}}
td {{bytesToSize statistics.nodeMemoryUsage.heapTotal}}
td {{fileSize statistics.nodeMemoryUsage.heapTotal}}
tr
th {{_ 'Node_memory_usage_heap_used'}}
td {{bytesToSize statistics.nodeMemoryUsage.heapUsed}}
td {{fileSize statistics.nodeMemoryUsage.heapUsed}}
tr
th {{_ 'Node_memory_usage_external'}}
td {{bytesToSize statistics.nodeMemoryUsage.external}}
td {{fileSize statistics.nodeMemoryUsage.external}}

View file

@ -1,4 +1,5 @@
import { TAPi18n } from '/imports/i18n';
const filesize = require('filesize');
BlazeComponent.extendComponent({
onCreated() {
@ -39,12 +40,8 @@ BlazeComponent.extendComponent({
return parseFloat(number).toFixed(2);
},
bytesToSize(bytes) {
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes === 0) {
return '0 Byte';
}
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10);
return `${Math.round(bytes / Math.pow(1024, i), 2)} ${sizes[i]}`;
fileSize(size) {
const ret = filesize(size);
return ret;
},
}).register('statistics');