From 2861d99de4d329bcba0a3c2193523398a22673c0 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 23 Dec 2014 20:33:42 +0100 Subject: web: intercept feature --- web/src/js/components/flowtable.jsx.js | 9 ++++ web/src/js/components/footer.jsx.js | 3 ++ web/src/js/components/header.jsx.js | 91 +++++++++++++++++++--------------- web/src/js/components/mainview.jsx.js | 11 +++- web/src/js/components/utils.jsx.js | 2 +- 5 files changed, 72 insertions(+), 44 deletions(-) (limited to 'web/src/js/components') diff --git a/web/src/js/components/flowtable.jsx.js b/web/src/js/components/flowtable.jsx.js index efc975a6..a3a37c40 100644 --- a/web/src/js/components/flowtable.jsx.js +++ b/web/src/js/components/flowtable.jsx.js @@ -11,6 +11,15 @@ var FlowRow = React.createClass({ if (this.props.highlighted) { className += " highlighted"; } + if (flow.intercepted) { + className += " intercepted"; + } + if (flow.request) { + className += " has-request"; + } + if (flow.response) { + className += " has-response"; + } return ( diff --git a/web/src/js/components/footer.jsx.js b/web/src/js/components/footer.jsx.js index 73fadef2..52d52e0f 100644 --- a/web/src/js/components/footer.jsx.js +++ b/web/src/js/components/footer.jsx.js @@ -1,9 +1,12 @@ var Footer = React.createClass({ render: function () { var mode = this.props.settings.mode; + var intercept = this.props.settings.intercept; return ( ); } diff --git a/web/src/js/components/header.jsx.js b/web/src/js/components/header.jsx.js index 9e090770..cb9cd149 100644 --- a/web/src/js/components/header.jsx.js +++ b/web/src/js/components/header.jsx.js @@ -1,9 +1,8 @@ var FilterInput = React.createClass({ getInitialState: function () { - // Focus: Show popover - // Mousefocus: Mouse over Tooltip - // onBlur is triggered before click on tooltip, - // hiding the tooltip before link is clicked. + // Consider both focus and mouseover for showing/hiding the tooltip, + // because onBlur of the input is triggered before the click on the tooltip + // finalized, hiding the tooltip just as the user clicks on it. return { value: this.props.value, focus: false, @@ -18,16 +17,14 @@ var FilterInput = React.createClass({ this.setState({ value: nextValue }); - try { - Filt.parse(nextValue); - } catch (err) { - return; + // Only propagate valid filters upwards. + if (this.isValid(nextValue)) { + this.props.onChange(nextValue); } - this.props.onChange(nextValue); }, - isValid: function () { + isValid: function (filt) { try { - Filt.parse(this.state.value); + Filt.parse(filt || this.state.value); return true; } catch (e) { return false; @@ -64,16 +61,14 @@ var FilterInput = React.createClass({ this.setState({mousefocus: false}); }, onKeyDown: function (e) { - if (e.target.value === "" && - e.keyCode === Key.BACKSPACE) { - e.preventDefault(); - this.remove(); + if (e.keyCode === Key.ESC || e.keyCode === Key.ENTER) { + this.blur(); + // If closed using ESC/ENTER, hide the tooltip. + this.setState({mousefocus: false}); } }, - remove: function () { - if (this.props.onRemove) { - this.props.onRemove(); - } + blur: function () { + this.refs.input.getDOMNode().blur(); }, focus: function () { this.refs.input.getDOMNode().select(); @@ -100,7 +95,7 @@ var FilterInput = React.createClass({ - -   + -   +
- -   - + + + + + ); diff --git a/web/src/js/components/mainview.jsx.js b/web/src/js/components/mainview.jsx.js index 113b0896..046d6af0 100644 --- a/web/src/js/components/mainview.jsx.js +++ b/web/src/js/components/mainview.jsx.js @@ -16,12 +16,12 @@ var MainView = React.createClass({ var filt = Filt.parse(this.getQuery()[Query.FILTER] || ""); var highlightStr = this.getQuery()[Query.HIGHLIGHT]; var highlight = highlightStr ? Filt.parse(highlightStr) : false; - } catch(e){ + } catch (e) { console.error("Error when processing filter: " + e); } return function filter_and_highlight(flow) { - if(!this._highlight){ + if (!this._highlight) { this._highlight = {}; } this._highlight[flow.id] = highlight && highlight(flow); @@ -143,6 +143,13 @@ var MainView = React.createClass({ this.refs.flowDetails.nextTab(+1); } break; + case Key.A: + if (e.shiftKey) { + $.post("/flows/accept"); + } else if(this.getSelected()) { + $.post("/flows/" + this.getSelected().id + "/accept"); + } + break; default: console.debug("keydown", e.keyCode); return; diff --git a/web/src/js/components/utils.jsx.js b/web/src/js/components/utils.jsx.js index 81ba6b4d..20dbda94 100644 --- a/web/src/js/components/utils.jsx.js +++ b/web/src/js/components/utils.jsx.js @@ -113,7 +113,7 @@ var xsrf = $.param({_xsrf: getCookie("_xsrf")}); //Tornado XSRF Protection. $.ajaxPrefilter(function (options) { - if (options.type === "post" && options.url[0] === "/") { + if (["post","put","delete"].indexOf(options.type.toLowerCase()) >= 0 && options.url[0] === "/") { if (options.data) { options.data += ("&" + xsrf); } else { -- cgit v1.2.3