* Add new method for getting online/active node information
* Use new online method for whos online
This commit is contained in:
@@ -3,7 +3,11 @@
|
||||
|
||||
var logger = require('./logger.js');
|
||||
|
||||
var _ = require('lodash');
|
||||
var moment = require('moment');
|
||||
|
||||
exports.getActiveConnections = getActiveConnections;
|
||||
exports.getActiveNodeList = getActiveNodeList;
|
||||
exports.addNewClient = addNewClient;
|
||||
exports.removeClient = removeClient;
|
||||
|
||||
@@ -14,6 +18,33 @@ function getActiveConnections() {
|
||||
return clientConnections;
|
||||
}
|
||||
|
||||
function getActiveNodeList() {
|
||||
const now = moment();
|
||||
|
||||
return _.map(getActiveConnections(), ac => {
|
||||
let entry = {
|
||||
node : ac.node,
|
||||
authenticated : ac.user.isAuthenticated(),
|
||||
userId : ac.user.userId,
|
||||
action : _.has(ac, 'currentMenuModule.menuConfig.desc') ? ac.currentMenuModule.menuConfig.desc : 'Unknown',
|
||||
};
|
||||
|
||||
//
|
||||
// There may be a connection, but not a logged in user as of yet
|
||||
//
|
||||
if(ac.user.isAuthenticated()) {
|
||||
entry.userName = ac.user.username;
|
||||
entry.realName = ac.user.properties.real_name;
|
||||
entry.location = ac.user.properties.location;
|
||||
entry.affils = ac.user.properties.affiliation;
|
||||
|
||||
const diff = now.diff(moment(ac.user.properties.last_login_timestamp), 'minutes');
|
||||
entry.timeOn = moment.duration(diff, 'minutes');
|
||||
}
|
||||
return entry;
|
||||
});
|
||||
}
|
||||
|
||||
function addNewClient(client, clientSock) {
|
||||
var id = client.session.id = clientConnections.push(client) - 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user