Styled gatherer names with italics if they are no longer on the gather (#127)

page.
Displays a somewhat inaccurate (but in the afk gatherers favour) idle
timer in the gatherer info panel.
This commit is contained in:
ArturPhilibin 2019-01-10 17:15:14 +00:00 committed by Absurdon
parent 39c64072c0
commit 4553d8aee0
4 changed files with 45 additions and 11 deletions

View file

@ -873,14 +873,28 @@ const GathererListItem = React.createClass({
</dd> </dd>
] ]
} }
const lastSeenInMinutes = (gatherer) => {
return parseInt((Date.now() - gatherer.user.lastSeen) / (1000 * 60));
};
let idleStatus;
if (!gatherer.user.online) {
const mins = lastSeenInMinutes(gatherer);
idleStatus = [
<dt>Last Seen</dt>,
<dd>{mins} mins ago</dd>
]
}
let tabColor = gatherer.team !== "lobby" ? `panel-${gatherer.team}` : "panel-info"; let tabColor = gatherer.team !== "lobby" ? `panel-${gatherer.team}` : "panel-info";
let onlineStatus = gatherer.user.online ? "" : "font-italic"
return ( return (
<div className={`panel ${tabColor} gatherer-panel`} <div className={`panel ${tabColor} gatherer-panel`}
key={gatherer.user.id} data-userid={gatherer.user.id}> key={gatherer.user.id} data-userid={gatherer.user.id}>
<div className="panel-heading"> <div className="panel-heading">
<h4 className="panel-title"> <h4 className="panel-title">
{country} {gatherer.user.username} {country} <span className={onlineStatus}>{gatherer.user.username}</span>
<span className="pull-right"> <span className="pull-right">
<a href="#" className="btn btn-xs btn-primary add-right" <a href="#" className="btn btn-xs btn-primary add-right"
onClick={this.toggleCollapse}> onClick={this.toggleCollapse}>
@ -894,6 +908,7 @@ const GathererListItem = React.createClass({
className={this.collapseState()} > className={this.collapseState()} >
<div className="panel-body"> <div className="panel-body">
<dl> <dl>
{idleStatus}
<dt>Skill Level</dt> <dt>Skill Level</dt>
<dd>{skill}</dd> <dd>{skill}</dd>
<dt>Team</dt> <dt>Team</dt>

View file

@ -6,6 +6,10 @@ html, body {
margin-top: 1em; margin-top: 1em;
} }
.font-italic {
font-style: italic;
}
/*Chat*/ /*Chat*/
.wordwrap { .wordwrap {

View file

@ -26,15 +26,17 @@ const Event = mongoose.model("Event");
const _ = require("lodash"); const _ = require("lodash");
const winston = require("winston"); const winston = require("winston");
const emitGather = (socket, gather) => {
socket.emit("gather:refresh", {
gather: gather ? gather.toJson() : null,
type: gather ? gather.type : null,
maps: Map.list,
});
}
module.exports = function (namespace) { module.exports = function (namespace) {
const emitGather = (socket, gather) => {
const onlineIds = Object.values(namespace.sockets).map(s => s._user.id);
socket.emit("gather:refresh", {
gather: gather ? gather.toJson(onlineIds) : null,
type: gather ? gather.type : null,
maps: Map.list,
});
}
const refreshArchive = () => { const refreshArchive = () => {
ArchivedGather.recent((error, recentGathers) => { ArchivedGather.recent((error, recentGathers) => {
if (error) return winston.error(error); if (error) return winston.error(error);
@ -78,8 +80,10 @@ module.exports = function (namespace) {
gatherManager.onArchiveUpdate(refreshArchive); gatherManager.onArchiveUpdate(refreshArchive);
gatherRefreshers[type] = _.debounce(function () { gatherRefreshers[type] = _.debounce(function () {
const onlineIds = Object.values(namespace.sockets).map(s => s._user.id);
namespace.emit("gather:refresh", { namespace.emit("gather:refresh", {
gather: gatherManager.current ? gatherManager.current.toJson() : null, gather: gatherManager.current ? gatherManager.current.toJson(onlineIds) : null,
type: gatherManager.current ? gatherManager.current.type : null, type: gatherManager.current ? gatherManager.current.type : null,
maps: Map.list, maps: Map.list,
}); });

View file

@ -337,7 +337,18 @@ Gather.prototype.electionStartTime = function () {
null : this.election.startTime.toISOString(); null : this.election.startTime.toISOString();
}; };
Gather.prototype.toJson = function () { Gather.prototype.toJson = function (onlineIds) {
if (onlineIds) {
const now = Date.now();
for (var gatherer of this.gatherers) {
if (gatherer.user.online) {
gatherer.user.lastSeen = now;
}
gatherer.user.online = onlineIds.indexOf(gatherer.id) !== -1;
}
}
return { return {
name: this.name, name: this.name,
description: this.description, description: this.description,