/*** @jsx React.DOM */ var possible_events = [ 'unhandled_packet', 'exception', 'unauthorized_pcbid', 'jubeat_league_course', 'jubeat_fc_challenge_charts', 'jubeat_random_course_charts', 'iidx_daily_charts', 'pcbevent', 'paseli_transaction', 'pnm_course', 'ddr_profile_purge', ]; var event_names = { 'unhandled_packet': 'Unhandled Packets', 'exception': 'Exceptions', 'unauthorized_pcbid': 'Unauthorized PCBIDs', 'jubeat_league_course': 'Jubeat League Courses', 'jubeat_fc_challenge_charts': 'Jubeat Full Combo Challenge Charts', 'jubeat_random_course_charts': 'Jubeat Random 10s Course Charts', 'iidx_daily_charts': 'IIDX Daily Charts', 'pnm_course': 'Pop\'n Music Course', 'pcbevent': 'PCB Events', 'paseli_transaction': 'PASELI Transactions', 'ddr_profile_purge': 'DDR Ace Profile Purge', }; var mergehandler = new MergeManager(function(evt) { return evt.id; }, MergeManager.MERGE_POLICY_DROP); var audit_events = createReactClass({ getInitialState: function(props) { return { events: mergehandler.add(window.events), users: window.users, arcades: window.arcades, iidxsongs: window.iidxsongs, jubeatsongs: window.jubeatsongs, pnmsongs: window.pnmsongs, iidxversions: window.iidxversions, jubeatversions: window.jubeatversions, pnmversions: window.pnmversions, filtering: window.possible_events, offset: 0, limit: 10, }; }, componentDidMount: function() { this.loadOldEvents(); this.refreshEvents(); }, loadOldEvents: function() { // If there's no events on the network, don't try loading old ones if (this.state.events.length == 0) { return; } var min_id = this.state.events.reduce(function(a, b) { return a < b.id ? a : b.id; }, this.state.events[0].id); AJAX.get( Link.get('backfill', min_id), function(response) { this.setState({ events: mergehandler.add(response.events), }); // Keep loading until we grab all events if (response.events.length > 0) { setTimeout(this.loadOldEvents, 1); } }.bind(this) ); }, refreshEvents: function() { var max_id = this.state.events.reduce(function(a, b) { if (!a) { return b.id; } return a > b.id ? a : b.id; }, 0); AJAX.get( Link.get('refresh', max_id), function(response) { this.setState({ events: mergehandler.add(response.events), users: response.users, arcades: response.arcades, }); // Refresh every 15 seconds setTimeout(this.refreshEvents, 5000); }.bind(this) ); }, getEvents: function() { return this.state.events.filter(function(event) { return this.state.filtering.indexOf(event.type) >= 0; }.bind(this)); }, renderFilters: function() { return (
{window.possible_events.map(function(event_id) { return ( = 0} onChange={function(event) { var filtering = this.state.filtering; if (event.target.checked) { filtering.push(event_id); } else { filtering = filtering.filter(function(f) { return f != event_id; }.bind(this)); } this.setState({filtering: filtering, offset: 0}); }.bind(this)} /> ); }.bind(this))}
); }, render: function() { var events = this.getEvents().sort(function(a, b) { return b.id - a.id; }); if (events.length == 0) { return (
{this.renderFilters()}
No events to display!
); } return (
{this.renderFilters()}
{events.map(function(event, index) { if (index < this.state.offset || index >= this.state.offset + this.state.limit) { return null; } if (event.type == 'unhandled_packet') { return ; } else if(event.type == 'exception') { return ; } else if(event.type == 'unauthorized_pcbid') { return ; } else if(event.type == 'jubeat_league_course') { return ; } else if(event.type == 'jubeat_fc_challenge_charts') { return ; } else if(event.type == 'jubeat_random_course_charts') { return ; } else if(event.type == 'iidx_daily_charts') { return ; } else if(event.type == 'pcbevent') { return ; } else if(event.type == 'paseli_transaction') { return ; } else if(event.type == 'pnm_course') { return ; } else if(event.type == 'ddr_profile_purge') { return ; } else { return ; } }.bind(this))}
Timestamp Event Details
{ this.state.offset > 0 ? : null } { (this.state.offset + this.state.limit) < events.length ? = events.length) { return } this.setState({offset: page}); }.bind(this)}/> : null }
); }, }); ReactDOM.render( React.createElement(audit_events, null), document.getElementById('content') );