mirror of https://github.com/wekan/wekan
Add display Wekan version number and runtime environment. Thanks to nztqa! Closes #963 #356reviewable/pr1161/r1
commit
6a7d7d04b1
@ -0,0 +1,51 @@ |
||||
template(name='information') |
||||
.setting-content |
||||
unless currentUser.isAdmin |
||||
| {{_ 'error-notAuthorized'}} |
||||
else |
||||
.content-title |
||||
span {{_ 'info'}} |
||||
.content-body |
||||
.side-menu |
||||
ul |
||||
li.active |
||||
a.js-setting-menu(data-id="information-display") {{_ 'info'}} |
||||
.main-body |
||||
+statistics |
||||
|
||||
template(name='statistics') |
||||
table |
||||
tbody |
||||
tr |
||||
th {{_ 'Wekan_version'}} |
||||
td {{statistics.version}} |
||||
tr |
||||
th {{_ 'Node_version'}} |
||||
td {{statistics.process.nodeVersion}} |
||||
tr |
||||
th {{_ 'OS_Type'}} |
||||
td {{statistics.os.type}} |
||||
tr |
||||
th {{_ 'OS_Platform'}} |
||||
td {{statistics.os.platform}} |
||||
tr |
||||
th {{_ 'OS_Arch'}} |
||||
td {{statistics.os.arch}} |
||||
tr |
||||
th {{_ 'OS_Release'}} |
||||
td {{statistics.os.release}} |
||||
tr |
||||
th {{_ 'OS_Uptime'}} |
||||
td {{humanReadableTime statistics.os.uptime}} |
||||
tr |
||||
th {{_ 'OS_Loadavg'}} |
||||
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}} |
||||
tr |
||||
th {{_ 'OS_Freemem'}} |
||||
td {{bytesToSize statistics.os.freemem}} |
||||
tr |
||||
th {{_ 'OS_Cpus'}} |
||||
td {{statistics.os.cpus.length}} |
@ -0,0 +1,48 @@ |
||||
BlazeComponent.extendComponent({ |
||||
onCreated() { |
||||
this.info = new ReactiveVar({}); |
||||
Meteor.call('getStatistics', (error, ret) => { |
||||
if (!error && ret) { |
||||
this.info.set(ret); |
||||
} |
||||
}); |
||||
}, |
||||
|
||||
statistics() { |
||||
return this.info.get(); |
||||
}, |
||||
|
||||
humanReadableTime(time) { |
||||
const days = Math.floor(time / 86400); |
||||
const hours = Math.floor((time % 86400) / 3600); |
||||
const minutes = Math.floor(((time % 86400) % 3600) / 60); |
||||
const seconds = Math.floor(((time % 86400) % 3600) % 60); |
||||
let out = ''; |
||||
if (days > 0) { |
||||
out += `${days} ${TAPi18n.__('days')}, `; |
||||
} |
||||
if (hours > 0) { |
||||
out += `${hours} ${TAPi18n.__('hours')}, `; |
||||
} |
||||
if (minutes > 0) { |
||||
out += `${minutes} ${TAPi18n.__('minutes')}, `; |
||||
} |
||||
if (seconds > 0) { |
||||
out += `${seconds} ${TAPi18n.__('seconds')}`; |
||||
} |
||||
return out; |
||||
}, |
||||
|
||||
numFormat(number) { |
||||
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]}`; |
||||
}, |
||||
}).register('statistics'); |
@ -0,0 +1,26 @@ |
||||
Meteor.methods({ |
||||
getStatistics() { |
||||
const os = require('os'); |
||||
const pjson = require('/package.json'); |
||||
const statistics = {}; |
||||
statistics.version = pjson.version; |
||||
statistics.os = { |
||||
type: os.type(), |
||||
platform: os.platform(), |
||||
arch: os.arch(), |
||||
release: os.release(), |
||||
uptime: os.uptime(), |
||||
loadavg: os.loadavg(), |
||||
totalmem: os.totalmem(), |
||||
freemem: os.freemem(), |
||||
cpus: os.cpus(), |
||||
}; |
||||
statistics.process = { |
||||
nodeVersion: process.version, |
||||
pid: process.pid, |
||||
uptime: process.uptime(), |
||||
}; |
||||
|
||||
return statistics; |
||||
}, |
||||
}); |
Loading…
Reference in new issue