aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/components/eventlog.jsx.js
blob: df212177f6a4493261313bd8f4c7f66a0c0fcd52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/** @jsx React.DOM */

var EventLog = React.createClass({
    mixins:[AutoScrollMixin],
    getInitialState: function () {
        return {
            log: []
        };
    },
    componentDidMount: function () {
        this.log = EventLogStore.getView();
        this.log.addListener("change", this.onEventLogChange);
    },
    componentWillUnmount: function () {
        this.log.removeListener("change", this.onEventLogChange);
        this.log.close();
    },
    onEventLogChange: function () {
        this.setState({
            log: this.log.getAll()
        });
    },
    close: function () {
        SettingsActions.update({
            showEventLog: false
        });
    },
    render: function () {
        var messages = this.state.log.map(function(row) {
            var indicator = null;
            if(row.source === "ui"){
                indicator = <i className="fa fa-html5"></i>;
            }
            return (
                <div key={row.id}>
                    { indicator } {row.message}
                </div>);
        });
        return <pre className="eventlog">{messages}</pre>;
    }
});