var MainMenu = React.createClass({ mixins: [Navigation, State], getInitialState: function(){ this.onQueryChange(Query.FILTER, function(oldVal, nextVal){ this.setState({filter: nextVal}); }.bind(this)); return { filter: this.getQuery()[Query.FILTER] }; }, statics: { title: "Traffic", route: "flows" }, toggleEventLog: function () { SettingsActions.update({ showEventLog: !this.props.settings.showEventLog }); }, clearFlows: function () { $.post("/flows/clear"); }, setFilter: function(e){ e.preventDefault(); this.setQuery(Query.FILTER, this.state.filter); }, onFilterChange: function(e){ this.setState({filter: e.target.value}); }, render: function () { return (
   
); } }); var ToolsMenu = React.createClass({ statics: { title: "Tools", route: "flows" }, render: function () { return
Tools Menu
; } }); var ReportsMenu = React.createClass({ statics: { title: "Visualization", route: "reports" }, render: function () { return
Reports Menu
; } }); var FileMenu = React.createClass({ getInitialState: function () { return { showFileMenu: false }; }, handleFileClick: function (e) { e.preventDefault(); if (!this.state.showFileMenu) { var close = function () { this.setState({showFileMenu: false}); document.removeEventListener("click", close); }.bind(this); document.addEventListener("click", close); this.setState({ showFileMenu: true }); } }, handleNewClick: function (e) { e.preventDefault(); console.error("unimplemented: handleNewClick"); }, handleOpenClick: function (e) { e.preventDefault(); console.error("unimplemented: handleOpenClick"); }, handleSaveClick: function (e) { e.preventDefault(); console.error("unimplemented: handleSaveClick"); }, handleShutdownClick: function (e) { e.preventDefault(); console.error("unimplemented: handleShutdownClick"); }, render: function () { var fileMenuClass = "dropdown pull-left" + (this.state.showFileMenu ? " open" : ""); return (
File
); } }); var header_entries = [MainMenu, ToolsMenu, ReportsMenu]; var Header = React.createClass({ mixins: [Navigation], getInitialState: function () { return { active: header_entries[0] }; }, handleClick: function (active, e) { e.preventDefault(); this.replaceWith(active.route); this.setState({active: active}); }, render: function () { var header = header_entries.map(function (entry, i) { var classes = React.addons.classSet({ active: entry == this.state.active }); return ( { entry.title} ); }.bind(this)); return (
mitmproxy { this.props.settings.version }
); } });