I am building a web app that can show system information on a website. It shows the hardware information (temps, ram, cpu, fan speeds and so on) of the pc the "server" is running on. It opens a web server showing this information which is accessible over the network. I am using meteor, blazejs and systeminformation ( https://github.com/sebhildebrandt/systeminformation ) to do this. System information shows the information it gets from the server as long numbers. This is my html:
<template name="main">
{{#if subscriptionsReady}}
<p>cpu manufacturer: {{get (static) 'data.cpu.manufacturer'}}</p>
<p>cpu brand: {{get (static) 'data.cpu.brand'}}</p>
<p>cpu model: {{get (static) 'data.cpu.model'}}</p>
<p>cpu speed: {{get (static) 'data.cpu.speed'}}</p>
<p>cpu cores: {{get (static) 'data.cpu.cores'}}</p>
<p>total memory: {{get (dynamic) 'data.mem.total'}}</p>
<p>free memory: {{get (dynamic) 'data.mem.free'}}</p>
<p>used memory: {{get (dynamic) 'data.mem.used'}}</p>
<p>active memory: {{get (dynamic) 'data.mem.active'}}</p>
{{/if}}
which shows this on the website
I would like to format the long numbers to look like "total memory X.yz GB" and similar for different data. Is there any easy to use library out there I could use for this?
Also here is my server javascript file
Meteor.startup(() => {
si.getStaticData(Meteor.bindEnvironment(function(data){
Data.update({type: 'static'}, {data: data, type: 'static'}, {upsert: true})
}))
setInterval(Meteor.bindEnvironment(function() {
si.getDynamicData(Meteor.bindEnvironment(function(data){
Data.update({type: 'dynamic'}, {data: data, type: 'dynamic'}, {upsert: true})
}))
}), 1000)
Meteor.publish('data', function(){
return Data.find({})
})
});
and my client javascript
let subscriptions = [
Meteor.subscribe('data')
]
Template.main.helpers({
get: function(obj, what) {
console.log(obj)
return _.get(obj, what)
},
dynamic: function() {
return Data.findOne({type: 'dynamic'})
},
static: function() {
return Data.findOne({type: 'static'})
},
subscriptionsReady: function() {
for (let sub of subscriptions){
if (!sub.ready()) return false
}
return true
}
})