2015-07-28 15:54:29 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var UserLogin = React.createClass({
|
|
|
|
authorizeId: function (id) {
|
|
|
|
socket.emit("users:authorize", {
|
2015-07-31 11:21:25 +00:00
|
|
|
id: parseInt(id, 10)
|
2015-07-28 15:54:29 +00:00
|
|
|
});
|
2015-07-28 23:32:50 +00:00
|
|
|
setTimeout(function () {
|
|
|
|
socket.emit("gather:refresh");
|
|
|
|
}, 5000);
|
2015-07-28 15:54:29 +00:00
|
|
|
},
|
|
|
|
handleSubmit: function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var id = React.findDOMNode(this.refs.authorize_id).value.trim();
|
|
|
|
if (!id) return;
|
|
|
|
React.findDOMNode(this.refs.authorize_id).value = '';
|
|
|
|
this.authorizeId(id);
|
|
|
|
},
|
|
|
|
render: function () {
|
|
|
|
return (
|
|
|
|
<form onSubmit={this.handleSubmit} >
|
|
|
|
<div className="input-group signin">
|
|
|
|
<input
|
|
|
|
id="btn-input"
|
|
|
|
type="text"
|
|
|
|
className="form-control"
|
|
|
|
ref="authorize_id"
|
|
|
|
placeholder="Choose an ID..." />
|
|
|
|
<span className="input-group-btn">
|
|
|
|
<input
|
|
|
|
type="submit"
|
|
|
|
className="btn btn-primary"
|
|
|
|
id="btn-chat"
|
|
|
|
value="Login" />
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div className="signin">
|
|
|
|
<p className="text-center"><small>Just a temporary measure until genuine authentication is implemented</small></p>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
var UserMenu = React.createClass({
|
|
|
|
getDefaultProps: function () {
|
|
|
|
return {
|
|
|
|
users: []
|
|
|
|
};
|
|
|
|
},
|
|
|
|
componentDidMount: function () {
|
2015-07-31 10:49:39 +00:00
|
|
|
var self = this;
|
|
|
|
socket.on('users:update', function (data) {
|
|
|
|
self.setProps({
|
|
|
|
users: data.users
|
|
|
|
});
|
2015-07-28 15:54:29 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
render: function () {
|
|
|
|
var users = this.props.users.map(function (user) {
|
|
|
|
return (
|
|
|
|
<li key={user.id}><a href="#">{user.username}</a></li>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
return (
|
|
|
|
<ul className="nav" id="side-menu">
|
2015-07-31 10:49:39 +00:00
|
|
|
<li>
|
|
|
|
<a href="#">
|
|
|
|
<i className="fa fa-users fa-fw"></i> Online
|
|
|
|
<span className="badge add-left"> {this.props.users.length} </span>
|
|
|
|
</a>
|
|
|
|
</li>
|
2015-07-28 15:54:29 +00:00
|
|
|
{users}
|
|
|
|
<li><br /><UserLogin /><br /></li>
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-07-29 14:35:58 +00:00
|
|
|
var AdminPanel = React.createClass({
|
|
|
|
handleGatherReset: function () {
|
|
|
|
socket.emit("gather:reset");
|
|
|
|
},
|
|
|
|
render: function () {
|
|
|
|
return (
|
|
|
|
<ul className="nav" id="admin-menu">
|
|
|
|
<li>
|
|
|
|
<div className="admin-panel">
|
|
|
|
<h5>Admin</h5>
|
|
|
|
<button
|
|
|
|
className="btn btn-danger"
|
|
|
|
onClick={this.handleGatherReset}>
|
|
|
|
Reset Gather</button>
|
|
|
|
<p className="text-center"><small>Only responds for admins on staging.ensl.org</small></p>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-07-28 15:54:29 +00:00
|
|
|
var CurrentUser = React.createClass({
|
|
|
|
componentDidMount: function () {
|
|
|
|
var self = this;
|
|
|
|
socket.on("users:update", function (data) {
|
|
|
|
self.setProps({
|
|
|
|
user: data.currentUser
|
|
|
|
});
|
|
|
|
});
|
2015-07-31 10:51:38 +00:00
|
|
|
socket.emit("users:refresh");
|
2015-07-28 15:54:29 +00:00
|
|
|
},
|
|
|
|
render: function () {
|
|
|
|
if (this.props.user) {
|
|
|
|
return (
|
|
|
|
<a href="#">{this.props.user.username} <img src={this.props.user.avatar}
|
|
|
|
alt="User Avatar"
|
|
|
|
height="20"
|
|
|
|
width="20" /></a>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|