Merge
This commit is contained in:
@@ -41,12 +41,15 @@ function getActiveConnectionList(authUsersOnly) {
|
||||
authenticated : ac.user.isAuthenticated(),
|
||||
userId : ac.user.userId,
|
||||
action : _.get(ac, 'currentMenuModule.menuConfig.desc', 'Unknown'),
|
||||
serverName : ac.session.serverName,
|
||||
isSecure : ac.session.isSecure,
|
||||
};
|
||||
|
||||
//
|
||||
// There may be a connection, but not a logged in user as of yet
|
||||
//
|
||||
if(ac.user.isAuthenticated()) {
|
||||
entry.text = ac.user.username;
|
||||
entry.userName = ac.user.username;
|
||||
entry.realName = ac.user.properties[UserProps.RealName];
|
||||
entry.location = ac.user.properties[UserProps.Location];
|
||||
|
||||
@@ -109,6 +109,10 @@ class StatLog {
|
||||
|
||||
getSystemStat(statName) { return this.systemStats[statName]; }
|
||||
|
||||
getFriendlySystemStat(statName, defaultValue) {
|
||||
return (this.getSystemStat(statName) || defaultValue).toLocaleString();
|
||||
}
|
||||
|
||||
getSystemStatNum(statName) {
|
||||
return parseInt(this.getSystemStat(statName)) || 0;
|
||||
}
|
||||
@@ -220,7 +224,7 @@ class StatLog {
|
||||
sysDb.run(
|
||||
`DELETE FROM system_event_log
|
||||
WHERE id IN(
|
||||
SELECT id
|
||||
SELECT id
|
||||
FROM system_event_log
|
||||
WHERE log_name = ?
|
||||
ORDER BY id DESC
|
||||
|
||||
67
core/wfc.js
67
core/wfc.js
@@ -1,6 +1,13 @@
|
||||
// ENiGMA½
|
||||
const { MenuModule } = require('./menu_module');
|
||||
|
||||
const { getActiveConnectionList } = require('./client_connections');
|
||||
const StatLog = require('./stat_log');
|
||||
const SysProps = require('./system_property');
|
||||
const {
|
||||
formatByteSize, formatByteSizeAbbr,
|
||||
} = require('./string_util');
|
||||
|
||||
// deps
|
||||
const async = require('async');
|
||||
const _ = require('lodash');
|
||||
@@ -17,8 +24,8 @@ const FormIds = {
|
||||
|
||||
const MciViewIds = {
|
||||
main : {
|
||||
nodeStatus : 0,
|
||||
quickLogView : 1,
|
||||
nodeStatus : 1,
|
||||
quickLogView : 2,
|
||||
|
||||
customRangeStart : 10,
|
||||
}
|
||||
@@ -35,7 +42,7 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||
|
||||
this.config.acs = this.config.acs || DefaultACS;
|
||||
if (!this.config.acs.includes('SC')) {
|
||||
this.config.acs = 'SC' + this.config.acs; // secure connection at the very, very least
|
||||
this.config.acs = 'SC' + this.config.acs; // secure connection at the very least
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,6 +63,9 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||
// return this.validateMCIByViewIds('main', requiredCodes, callback);
|
||||
return callback(null);
|
||||
},
|
||||
(callback) => {
|
||||
return this._refreshNodeStatus(callback);
|
||||
}
|
||||
],
|
||||
err => {
|
||||
return cb(err);
|
||||
@@ -63,5 +73,56 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
_refreshStats(cb) {
|
||||
const fileAreaStats = StatLog.getSystemStat(SysProps.FileBaseAreaStats);
|
||||
const totalFiles = fileAreaStats.totalFiles || 0;
|
||||
const totalFileBytes = fileAreaStats.totalBytes || 0;
|
||||
|
||||
this.stats = {
|
||||
// Totals
|
||||
totalCalls : StatLog.getFriendlySystemStat(SysProps.LoginCount, 0),
|
||||
totalPosts : StatLog.getFriendlySystemStat(SysProps.MessageTotalCount, 0),
|
||||
//totalUsers :
|
||||
totalFiles : totalFiles.toLocaleString(),
|
||||
totalFileBytes : formatByteSize(totalFileBytes, false),
|
||||
totalFileBytesAbbr : formatByteSizeAbbr(totalFileBytes),
|
||||
// :TODO: date, time - formatted as per config.dateTimeFormat and such
|
||||
// :TODO: Most/All current user status should be predefined MCI
|
||||
// :TODO: lastCaller
|
||||
// :TODO: totalMemoryBytes, freeMemoryBytes
|
||||
// :TODO: CPU info/averages/load
|
||||
// :TODO: processUptime
|
||||
// :TODO: 24 HOUR stats -
|
||||
// calls24Hour, posts24Hour, uploadBytes24Hour, downloadBytes24Hour, ...
|
||||
// :TODO: totals - most avail from MCI
|
||||
};
|
||||
|
||||
return cb(null);
|
||||
}
|
||||
|
||||
_refreshNodeStatus(cb) {
|
||||
const nodeStatusView = this.getView('main', MciViewIds.main.nodeStatus);
|
||||
if (!nodeStatusView) {
|
||||
return cb(null);
|
||||
}
|
||||
|
||||
const nodeStatusItems = getActiveConnectionList(false).slice(0, nodeStatusView.height).map(ac => {
|
||||
// Handle pre-authenticated
|
||||
if (!ac.authenticated) {
|
||||
ac.text = ac.username = 'Pre Auth';
|
||||
ac.action = 'Logging In';
|
||||
}
|
||||
|
||||
return Object.assign(ac, {
|
||||
timeOn : _.upperFirst(ac.timeOn.humanize()), // make friendly
|
||||
});
|
||||
});
|
||||
|
||||
nodeStatusView.setItems(nodeStatusItems);
|
||||
nodeStatusView.redraw();
|
||||
|
||||
return cb(null);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user