2015-07-28 15:54:29 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var UserLogin = React.createClass({
|
2015-08-11 00:25:25 +00:00
|
|
|
authorizeId(id) {
|
2015-07-28 15:54:29 +00:00
|
|
|
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");
|
2015-08-08 19:14:16 +00:00
|
|
|
}, 1000);
|
2015-07-28 15:54:29 +00:00
|
|
|
},
|
2015-08-11 00:25:25 +00:00
|
|
|
|
|
|
|
handleSubmit(e) {
|
2015-07-28 15:54:29 +00:00
|
|
|
e.preventDefault();
|
2015-08-11 00:31:03 +00:00
|
|
|
let id = React.findDOMNode(this.refs.authorize_id).value.trim();
|
2015-07-28 15:54:29 +00:00
|
|
|
if (!id) return;
|
|
|
|
React.findDOMNode(this.refs.authorize_id).value = '';
|
|
|
|
this.authorizeId(id);
|
|
|
|
},
|
2015-08-11 00:25:25 +00:00
|
|
|
|
|
|
|
render() {
|
2015-07-28 15:54:29 +00:00
|
|
|
return (
|
|
|
|
<form onSubmit={this.handleSubmit} >
|
|
|
|
<div className="input-group signin">
|
|
|
|
<input
|
|
|
|
id="btn-input"
|
|
|
|
type="text"
|
|
|
|
className="form-control"
|
|
|
|
ref="authorize_id"
|
2015-08-18 09:56:35 +00:00
|
|
|
placeholder="Change user" />
|
2015-07-28 15:54:29 +00:00
|
|
|
<span className="input-group-btn">
|
|
|
|
<input
|
|
|
|
type="submit"
|
|
|
|
className="btn btn-primary"
|
|
|
|
id="btn-chat"
|
2015-08-18 09:56:35 +00:00
|
|
|
value="Assume ID" />
|
2015-07-28 15:54:29 +00:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
var UserMenu = React.createClass({
|
2015-08-11 00:25:25 +00:00
|
|
|
getDefaultProps() {
|
2015-07-28 15:54:29 +00:00
|
|
|
return {
|
|
|
|
users: []
|
|
|
|
};
|
|
|
|
},
|
2015-08-11 00:25:25 +00:00
|
|
|
|
|
|
|
componentDidMount() {
|
2015-08-11 00:31:03 +00:00
|
|
|
let self = this;
|
2015-08-11 00:25:25 +00:00
|
|
|
socket.on('users:update', data => self.setProps({users: data.users}));
|
2015-07-28 15:54:29 +00:00
|
|
|
},
|
2015-08-11 00:25:25 +00:00
|
|
|
|
|
|
|
render() {
|
2015-08-11 00:31:03 +00:00
|
|
|
let users = this.props.users.map(user => {
|
2015-07-28 15:54:29 +00:00
|
|
|
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}
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-07-29 14:35:58 +00:00
|
|
|
var AdminPanel = React.createClass({
|
2015-08-11 00:25:25 +00:00
|
|
|
handleGatherReset() {
|
2015-07-29 14:35:58 +00:00
|
|
|
socket.emit("gather:reset");
|
|
|
|
},
|
2015-08-11 00:25:25 +00:00
|
|
|
|
|
|
|
render() {
|
2015-07-29 14:35:58 +00:00
|
|
|
return (
|
2015-08-18 11:02:27 +00:00
|
|
|
<div>
|
|
|
|
<h5>Swap Into a Different Account</h5>
|
|
|
|
<UserLogin />
|
|
|
|
<h5>Gather Options</h5>
|
|
|
|
<div>
|
|
|
|
<button
|
|
|
|
className="btn btn-danger max-width"
|
|
|
|
onClick={this.handleGatherReset}>
|
|
|
|
Reset Gather</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2015-07-29 14:35:58 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-07-28 15:54:29 +00:00
|
|
|
var CurrentUser = React.createClass({
|
2015-08-11 00:25:25 +00:00
|
|
|
componentDidMount() {
|
2015-08-11 00:31:03 +00:00
|
|
|
let self = this;
|
2015-08-11 00:25:25 +00:00
|
|
|
socket.on("users:update", 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
|
|
|
},
|
2015-08-11 00:25:25 +00:00
|
|
|
|
|
|
|
render() {
|
2015-07-28 15:54:29 +00:00
|
|
|
if (this.props.user) {
|
2015-08-18 11:02:27 +00:00
|
|
|
var adminOptions;
|
|
|
|
if (this.props.user.admin) {
|
|
|
|
adminOptions = (
|
|
|
|
<li>
|
|
|
|
<a href="#" data-toggle="modal" data-target="#adminmodal">Administration</a>
|
|
|
|
</li>
|
|
|
|
)
|
|
|
|
}
|
2015-07-28 15:54:29 +00:00
|
|
|
return (
|
2015-08-08 19:14:16 +00:00
|
|
|
<li className="dropdown">
|
2015-07-31 16:20:52 +00:00
|
|
|
<a className="dropdown-toggle" data-toggle="dropdown" href="#">
|
|
|
|
{this.props.user.username} <img src={this.props.user.avatar}
|
|
|
|
alt="User Avatar"
|
|
|
|
height="20"
|
|
|
|
width="20" /> <i className="fa fa-caret-down"></i>
|
|
|
|
</a>
|
|
|
|
<ul className="dropdown-menu dropdown-user">
|
|
|
|
<li>
|
|
|
|
<a href="#"><i className="fa fa-gear fa-fw"></i> Profile</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href="#"><i className="fa fa-flag fa-fw"></i> Notifications</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href="#"><i className="fa fa-music fa-fw"></i> Sounds</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href="#" data-toggle="modal" data-target="#designmodal">Design Goals</a>
|
|
|
|
</li>
|
2015-08-18 11:02:27 +00:00
|
|
|
{adminOptions}
|
2015-07-31 16:20:52 +00:00
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
|
2015-07-28 15:54:29 +00:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2015-08-11 00:37:43 +00:00
|
|
|
|