Restored admin panel on menubar

This commit is contained in:
Chris Blanchard 2016-02-12 23:22:46 +00:00
parent 9203e4294f
commit a9b58d55cc
6 changed files with 34 additions and 163 deletions

View file

@ -3,7 +3,7 @@ import {AssumeUserIdButton} from "javascripts/components/user";
const React = require("react");
const helper = require("javascripts/helper");
const enslUrl = helper.enslUrl;
const rankVotes = helper.rankeVotes;
const rankVotes = helper.rankVotes;
const hiveUrl = helper.hiveUrl;
const SelectPlayerButton = React.createClass({
@ -738,6 +738,7 @@ const Gatherers = React.createClass({
<span>
<span className="badge add-right">{votes + " votes"}</span>
<VoteButton
socket={this.props.socket}
thisGatherer={thisGatherer}
soundController={this.props.soundController}
candidate={gatherer} />

View file

@ -1,12 +1,13 @@
import {News} from "javascripts/components/news";
import {Events} from "javascripts/components/event";
import {InfoButton} from "javascripts/components/info";
import {AdminPanel} from "javascripts/components/admin";
import {Chatroom} from "javascripts/components/message";
import {SoundPanel} from "javascripts/components/sound";
import {SettingsPanel} from "javascripts/components/settings";
import {Gather, ArchivedGathers} from "javascripts/components/gather";
import {TeamSpeakButton, TeamSpeakModal} from "javascripts/components/teamspeak";
import {CurrentUser, AdminPanel, ProfileModal, UserMenu} from "javascripts/components/user";
import {CurrentUser, ProfileModal, UserMenu} from "javascripts/components/user";
const React = require("react");
const Sound = require("javascripts/components/sound");
@ -198,7 +199,7 @@ const App = React.createClass({
let events = self.state.events;
events.unshift(data);
self.setState({
events: events.slice(0, 20)
events: events.slice(0, 100)
});
});
@ -391,6 +392,9 @@ const App = React.createClass({
connectionStatus = <a href="#"><i className="fa fa-circle text-danger"></i> Disconnected</a>;
}
let adminPanel;
if (user && user.admin) adminPanel = <AdminPanel socket={socket} />;
return (
<div className={appClass.join(" ")}>
{this.modal()}
@ -405,6 +409,7 @@ const App = React.createClass({
</a>
<div className="navbar-custom-menu">
<ul className="nav navbar-nav">
{adminPanel}
<SoundPanel soundController={this.state.soundController} />
{profileLink}
<News />
@ -447,7 +452,25 @@ const App = React.createClass({
<h1>Gathers<small>beta</small></h1>
</section>
<section className="content">
<p>Foo</p>
<div className="row">
<div className="col-md-8">
<Gather
socket={socket}
maps={this.state.maps}
user={this.state.user}
gather={this.state.gather}
servers={this.state.servers}
thisGatherer={this.thisGatherer()}
previousGather={this.state.previousGather}
soundController={this.state.soundController} />
</div>
<div className="col-md-4">
{eventsPanel}
<ArchivedGathers archive={this.state.archive}
maps={this.state.maps}
servers={this.state.servers} />
</div>
</div>
</section>
</div>
<aside className="control-sidebar control-sidebar-dark" style={{"position": "fixed", "height": "auto"}}>
@ -458,53 +481,6 @@ const App = React.createClass({
<div className="control-sidebar-bg" style={{"position":"fixed", "height":"auto"}}></div>
</div>
);
// return (
// <div id="wrapper">
// <nav className="navbar navbar-default navbar-static-top"
// role="navigation"
// style={{marginBottom: "0"}}>
// <div className="navbar-header">
// <a className="navbar-brand" href="/">NSL Gathers <small><i>Alpha</i></small></a>
// </div>
// {currentUser}
// <ul className="nav navbar-top-links navbar-right" id="soundcontroller">
// <SoundPanel soundController={this.state.soundController} />
// </ul>
// </nav>
// <AdminPanel socket={socket} />
// <SettingsPanel
// toggleEventsPanel={this.toggleEventsPanel}
// showEventsPanel={this.state.showEventsPanel}
// toggleUpdateTitle={this.toggleUpdateTitle}
// updateTitle={this.state.updateTitle} />
// <div style={{minHeight: "750px"}}>
// <div className="container-fluid">
// <div className="row">
// <div className="col-md-4">
// {chatroom}
// </div>
// <div className="col-md-6">
// <Gather
// socket={socket}
// maps={this.state.maps}
// user={this.state.user}
// gather={this.state.gather}
// servers={this.state.servers}
// thisGatherer={this.thisGatherer()}
// previousGather={this.state.previousGather}
// soundController={this.state.soundController} />
// {eventsPanel}
// <hr />
// <ArchivedGathers archive={this.state.archive}
// maps={this.state.maps}
// servers={this.state.servers} />
// </div>
// </div>
// </div>
// </div>
// </div>
// );
}
});

View file

@ -2,11 +2,14 @@ const $ = require("jquery");
const React = require("react");
const helper = require("javascripts/helper");
const storageAvailable = helper.storageAvailable;
import {MenubarMixin} from "javascripts/components/menubar";
const READ_ARTICLES_STORAGE = "akuh098h209ufnw";
const HTML_ENTITY_REGEX = /&#\d+;/;
const News = exports.News = React.createClass({
mixins: [MenubarMixin],
getInitialState() {
let readArticles = {};
if (storageAvailable('localStorage')) {
@ -22,15 +25,10 @@ const News = exports.News = React.createClass({
return {
posts: [],
show: false,
readArticles: readArticles
};
},
toggleShow() {
this.setState({ show: !this.state.show });
},
updatePosts(data) {
this.setState({
posts: data.posts.slice(0,5).map(post => {
@ -67,12 +65,6 @@ const News = exports.News = React.createClass({
}
},
componentClass() {
let componentClass = ["dropdown", "messages-menu"];
if (this.state.show) componentClass.push("open");
return componentClass.join(" ");
},
hasBeenRead(post) {
return (this.state.readArticles[post.id] !== undefined);
},

View file

@ -3,6 +3,7 @@ const React = require("react");
const Howl = require("howler").Howl;
const Howler = require("howler").Howler;
const helper = require("javascripts/helper");
import {MenubarMixin} from "javascripts/components/menubar";
const storageAvailable = helper.storageAvailable;
class SoundController {
@ -195,15 +196,7 @@ var MusicSelector = React.createClass({
})
var SoundPanel = React.createClass({
getInitialState() {
return {
show: false
};
},
toggleShow() {
this.setState({ show: !this.state.show });
},
mixins: [MenubarMixin],
componentDidMount() {
let soundController = this.props.soundController;
@ -222,12 +215,6 @@ var SoundPanel = React.createClass({
}).slider('setValue', soundController.getVolume() * scale);
},
componentClass() {
let componentClass = ["dropdown", "messages-menu"];
if (this.state.show) componentClass.push("open");
return componentClass.join(" ");
},
mute() {
this.props.soundController.mute();
this.forceUpdate();

View file

@ -6,48 +6,6 @@ const hiveUrl = helper.hiveUrl;
const modalId = helper.modalId;
const Ps = require('perfect-scrollbar');
const UserLogin = React.createClass({
propTypes: {
socket: React.PropTypes.object.isRequired
},
authorizeId(id) {
this.props.socket.emit("users:authorize", {
id: parseInt(id, 10)
});
},
handleSubmit(e) {
e.preventDefault();
let id = React.findDOMNode(this.refs.authorize_id).value.trim();
if (!id) return;
React.findDOMNode(this.refs.authorize_id).value = '';
this.authorizeId(id);
},
render() {
return (
<form onSubmit={this.handleSubmit} >
<div className="input-group signin">
<input
id="btn-input"
type="text"
className="form-control"
ref="authorize_id"
placeholder="Change user" />
<span className="input-group-btn">
<input
type="submit"
className="btn btn-primary"
id="btn-chat"
value="Assume ID" />
</span>
</div>
</form>
);
}
});
const DisconnectUserButton = React.createClass({
propTypes: {
socket: React.PropTypes.object.isRequired,
@ -240,49 +198,6 @@ const UserMenu = exports.UserMenu = React.createClass({
}
});
const AdminPanel = exports.AdminPanel = React.createClass({
propTypes: {
socket: React.PropTypes.object.isRequired
},
handleGatherReset() {
this.props.socket.emit("gather:reset");
},
render() {
return (
<div className="modal fade" id="adminmodal">
<div className="modal-dialog">
<div className="modal-content">
<div className="modal-header">
<button type="button" className="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 className="modal-title">Administration Panel</h4>
</div>
<div className="modal-body" id="admin-menu">
<h5>Swap Into a Different Account (Only works for admins)</h5>
<UserLogin socket={this.props.socket} />
<h5>Gather Options</h5>
<div>
<button
className="btn btn-danger max-width"
onClick={this.handleGatherReset}>
Reset Gather</button>
</div>
</div>
<div className="modal-footer">
<button type="button" className="btn btn-default"
data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
);
}
});
const ProfileModal = exports.ProfileModal = React.createClass({
propTypes: {
user: React.PropTypes.object.isRequired,

View file

@ -1,7 +1,7 @@
.flag {
width: 16px;
height: 11px;
background:url(/images/flags.png) no-repeat
background:url(flags.png) no-repeat
}
.flag.flag-ad {background-position: -16px 0}