2014-11-13 15:14:41 +01:00
|
|
|
var React = require('react'),
|
2014-11-14 07:29:55 +01:00
|
|
|
LogEntryList = require('./LogEntryList'),
|
2014-11-13 15:14:41 +01:00
|
|
|
eventStore = require('../../stores/EventStore'),
|
|
|
|
ErrorMessages = require('../ErrorMessages');
|
|
|
|
|
2014-11-14 07:29:55 +01:00
|
|
|
var LogEntriesComponent = React.createClass({
|
2014-11-13 15:14:41 +01:00
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
createView: false,
|
|
|
|
events: [],
|
|
|
|
errors: []
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount: function () {
|
|
|
|
eventStore.getEvents().then(function(res) {
|
|
|
|
this.setState({events: res.events});
|
|
|
|
}.bind(this), this.initError);
|
|
|
|
},
|
|
|
|
|
|
|
|
initError: function() {
|
|
|
|
this.onError("Could not load events from server");
|
|
|
|
},
|
|
|
|
|
|
|
|
clearErrors: function() {
|
|
|
|
this.setState({errors: []});
|
|
|
|
},
|
|
|
|
|
|
|
|
onError: function(error) {
|
|
|
|
var errors = this.state.errors.concat([error]);
|
|
|
|
this.setState({errors: errors});
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<ErrorMessages errors={this.state.errors} onClearErrors={this.clearErrors} />
|
|
|
|
|
|
|
|
<hr />
|
|
|
|
|
2014-11-14 07:29:55 +01:00
|
|
|
<LogEntryList events={this.state.events} />
|
2014-11-13 15:14:41 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2014-11-14 07:29:55 +01:00
|
|
|
module.exports = LogEntriesComponent;
|