mirror of
https://github.com/mitmproxy/mitmproxy.git
synced 2024-11-29 16:20:34 +00:00
web: move eventlog state out of settings
This commit is contained in:
parent
4767b83726
commit
b1311faa68
@ -67,7 +67,6 @@ class Settings(tornado.web.RequestHandler):
|
|||||||
def get(self):
|
def get(self):
|
||||||
self.write(dict(
|
self.write(dict(
|
||||||
data=dict(
|
data=dict(
|
||||||
showEventLog=True,
|
|
||||||
intercept=self.application.state.intercept_txt
|
intercept=self.application.state.intercept_txt
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
|
@ -164,10 +164,10 @@ header .menu {
|
|||||||
background-color: rgba(193, 215, 235, 0.5) !important;
|
background-color: rgba(193, 215, 235, 0.5) !important;
|
||||||
}
|
}
|
||||||
.flow-table tr.highlighted {
|
.flow-table tr.highlighted {
|
||||||
background-color: rgba(255, 204, 0, 0.4) !important;
|
background-color: rgba(255, 204, 0, 0.4);
|
||||||
}
|
}
|
||||||
.flow-table tr.highlighted:nth-child(even) {
|
.flow-table tr.highlighted:nth-child(even) {
|
||||||
background-color: rgba(255, 204, 0, 0.5) !important;
|
background-color: rgba(255, 204, 0, 0.5);
|
||||||
}
|
}
|
||||||
.flow-table td {
|
.flow-table td {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -239,12 +239,14 @@ var SettingsActions = {
|
|||||||
data: settings
|
data: settings
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
//Facebook Flux: We do an optimistic update on the client already.
|
//Facebook Flux: We do an optimistic update on the client already.
|
||||||
AppDispatcher.dispatchViewAction({
|
AppDispatcher.dispatchViewAction({
|
||||||
type: ActionTypes.SETTINGS_STORE,
|
type: ActionTypes.SETTINGS_STORE,
|
||||||
cmd: StoreCmds.UPDATE,
|
cmd: StoreCmds.UPDATE,
|
||||||
data: settings
|
data: settings
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -263,9 +265,30 @@ var EventLogActions = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var FlowActions = {
|
||||||
|
accept: function (flow) {
|
||||||
|
jQuery.post("/flows/" + flow.id + "/accept");
|
||||||
|
},
|
||||||
|
accept_all: function(){
|
||||||
|
jQuery.post("/flows/accept");
|
||||||
|
},
|
||||||
|
|
||||||
|
update: function (flow) {
|
||||||
|
AppDispatcher.dispatchViewAction({
|
||||||
|
type: ActionTypes.FLOW_STORE,
|
||||||
|
cmd: StoreCmds.UPDATE,
|
||||||
|
data: flow
|
||||||
|
});
|
||||||
|
},
|
||||||
|
clear: function(){
|
||||||
|
jQuery.post("/clear");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Query = {
|
Query = {
|
||||||
FILTER: "f",
|
FILTER: "f",
|
||||||
HIGHLIGHT: "h"
|
HIGHLIGHT: "h",
|
||||||
|
SHOW_EVENTLOG: "e"
|
||||||
};
|
};
|
||||||
Filt = (function() {
|
Filt = (function() {
|
||||||
/*
|
/*
|
||||||
@ -2704,12 +2727,18 @@ var MainMenu = React.createClass({displayName: 'MainMenu',
|
|||||||
route: "flows"
|
route: "flows"
|
||||||
},
|
},
|
||||||
toggleEventLog: function () {
|
toggleEventLog: function () {
|
||||||
SettingsActions.update({
|
var d = {};
|
||||||
showEventLog: !this.props.settings.showEventLog
|
|
||||||
});
|
if(this.getQuery()[Query.SHOW_EVENTLOG]){
|
||||||
|
d[Query.SHOW_EVENTLOG] = undefined;
|
||||||
|
} else {
|
||||||
|
d[Query.SHOW_EVENTLOG] = "t"; // any non-false value will do it, keep it short
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setQuery(d);
|
||||||
},
|
},
|
||||||
clearFlows: function () {
|
clearFlows: function () {
|
||||||
jQuery.post("/clear");
|
FlowActions.clear();
|
||||||
},
|
},
|
||||||
onFilterChange: function (val) {
|
onFilterChange: function (val) {
|
||||||
var d = {};
|
var d = {};
|
||||||
@ -2728,10 +2757,13 @@ var MainMenu = React.createClass({displayName: 'MainMenu',
|
|||||||
var filter = this.getQuery()[Query.FILTER] || "";
|
var filter = this.getQuery()[Query.FILTER] || "";
|
||||||
var highlight = this.getQuery()[Query.HIGHLIGHT] || "";
|
var highlight = this.getQuery()[Query.HIGHLIGHT] || "";
|
||||||
var intercept = this.props.settings.intercept || "";
|
var intercept = this.props.settings.intercept || "";
|
||||||
|
var showEventLog = this.getQuery()[Query.SHOW_EVENTLOG];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
React.createElement("div", null,
|
React.createElement("div", null,
|
||||||
React.createElement("button", {className: "btn " + (this.props.settings.showEventLog ? "btn-primary" : "btn-default"), onClick: this.toggleEventLog},
|
React.createElement("button", {
|
||||||
|
className: "btn " + (showEventLog ? "btn-primary" : "btn-default"),
|
||||||
|
onClick: this.toggleEventLog},
|
||||||
React.createElement("i", {className: "fa fa-database"}),
|
React.createElement("i", {className: "fa fa-database"}),
|
||||||
" Display Event Log"
|
" Display Event Log"
|
||||||
),
|
),
|
||||||
@ -3694,9 +3726,9 @@ var MainView = React.createClass({displayName: 'MainView',
|
|||||||
break;
|
break;
|
||||||
case Key.A:
|
case Key.A:
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
$.post("/flows/accept");
|
FlowActions.accept_all();
|
||||||
} else if(this.getSelected()) {
|
} else if(this.getSelected()) {
|
||||||
$.post("/flows/" + this.getSelected().id + "/accept");
|
FlowActions.accept(this.getSelected());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -3853,9 +3885,9 @@ var EventLog = React.createClass({displayName: 'EventLog',
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
close: function () {
|
close: function () {
|
||||||
SettingsActions.update({
|
var d = {};
|
||||||
showEventLog: false
|
d[Query.SHOW_EVENTLOG] = undefined;
|
||||||
});
|
this.setQuery(d);
|
||||||
},
|
},
|
||||||
toggleLevel: function (level) {
|
toggleLevel: function (level) {
|
||||||
var filter = _.extend({}, this.state.filter);
|
var filter = _.extend({}, this.state.filter);
|
||||||
@ -3903,6 +3935,7 @@ var Reports = React.createClass({displayName: 'Reports',
|
|||||||
|
|
||||||
|
|
||||||
var ProxyAppMain = React.createClass({displayName: 'ProxyAppMain',
|
var ProxyAppMain = React.createClass({displayName: 'ProxyAppMain',
|
||||||
|
mixins: [State],
|
||||||
getInitialState: function () {
|
getInitialState: function () {
|
||||||
var eventStore = new EventLogStore();
|
var eventStore = new EventLogStore();
|
||||||
var flowStore = new FlowStore();
|
var flowStore = new FlowStore();
|
||||||
@ -3910,7 +3943,6 @@ var ProxyAppMain = React.createClass({displayName: 'ProxyAppMain',
|
|||||||
|
|
||||||
// Default Settings before fetch
|
// Default Settings before fetch
|
||||||
_.extend(settings.dict,{
|
_.extend(settings.dict,{
|
||||||
showEventLog: true
|
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
settings: settings,
|
settings: settings,
|
||||||
@ -3933,7 +3965,7 @@ var ProxyAppMain = React.createClass({displayName: 'ProxyAppMain',
|
|||||||
render: function () {
|
render: function () {
|
||||||
|
|
||||||
var eventlog;
|
var eventlog;
|
||||||
if (this.state.settings.dict.showEventLog) {
|
if (this.getQuery()[Query.SHOW_EVENTLOG]) {
|
||||||
eventlog = [
|
eventlog = [
|
||||||
React.createElement(Splitter, {key: "splitter", axis: "y"}),
|
React.createElement(Splitter, {key: "splitter", axis: "y"}),
|
||||||
React.createElement(EventLog, {key: "eventlog", eventStore: this.state.eventStore})
|
React.createElement(EventLog, {key: "eventlog", eventStore: this.state.eventStore})
|
||||||
|
@ -27,10 +27,10 @@
|
|||||||
background-color: hsla(209, 52%, 84%, 0.5) !important;
|
background-color: hsla(209, 52%, 84%, 0.5) !important;
|
||||||
}
|
}
|
||||||
&.highlighted {
|
&.highlighted {
|
||||||
background-color: hsla(48, 100%, 50%, 0.4) !important;
|
background-color: hsla(48, 100%, 50%, 0.4);
|
||||||
}
|
}
|
||||||
&.highlighted:nth-child(even) {
|
&.highlighted:nth-child(even) {
|
||||||
background-color: hsla(48, 100%, 50%, 0.5) !important;
|
background-color: hsla(48, 100%, 50%, 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,12 +44,14 @@ var SettingsActions = {
|
|||||||
data: settings
|
data: settings
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
//Facebook Flux: We do an optimistic update on the client already.
|
//Facebook Flux: We do an optimistic update on the client already.
|
||||||
AppDispatcher.dispatchViewAction({
|
AppDispatcher.dispatchViewAction({
|
||||||
type: ActionTypes.SETTINGS_STORE,
|
type: ActionTypes.SETTINGS_STORE,
|
||||||
cmd: StoreCmds.UPDATE,
|
cmd: StoreCmds.UPDATE,
|
||||||
data: settings
|
data: settings
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -68,7 +70,28 @@ var EventLogActions = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var FlowActions = {
|
||||||
|
accept: function (flow) {
|
||||||
|
jQuery.post("/flows/" + flow.id + "/accept");
|
||||||
|
},
|
||||||
|
accept_all: function(){
|
||||||
|
jQuery.post("/flows/accept");
|
||||||
|
},
|
||||||
|
|
||||||
|
update: function (flow) {
|
||||||
|
AppDispatcher.dispatchViewAction({
|
||||||
|
type: ActionTypes.FLOW_STORE,
|
||||||
|
cmd: StoreCmds.UPDATE,
|
||||||
|
data: flow
|
||||||
|
});
|
||||||
|
},
|
||||||
|
clear: function(){
|
||||||
|
jQuery.post("/clear");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Query = {
|
Query = {
|
||||||
FILTER: "f",
|
FILTER: "f",
|
||||||
HIGHLIGHT: "h"
|
HIGHLIGHT: "h",
|
||||||
|
SHOW_EVENTLOG: "e"
|
||||||
};
|
};
|
@ -119,9 +119,9 @@ var EventLog = React.createClass({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
close: function () {
|
close: function () {
|
||||||
SettingsActions.update({
|
var d = {};
|
||||||
showEventLog: false
|
d[Query.SHOW_EVENTLOG] = undefined;
|
||||||
});
|
this.setQuery(d);
|
||||||
},
|
},
|
||||||
toggleLevel: function (level) {
|
toggleLevel: function (level) {
|
||||||
var filter = _.extend({}, this.state.filter);
|
var filter = _.extend({}, this.state.filter);
|
||||||
|
@ -115,12 +115,18 @@ var MainMenu = React.createClass({
|
|||||||
route: "flows"
|
route: "flows"
|
||||||
},
|
},
|
||||||
toggleEventLog: function () {
|
toggleEventLog: function () {
|
||||||
SettingsActions.update({
|
var d = {};
|
||||||
showEventLog: !this.props.settings.showEventLog
|
|
||||||
});
|
if(this.getQuery()[Query.SHOW_EVENTLOG]){
|
||||||
|
d[Query.SHOW_EVENTLOG] = undefined;
|
||||||
|
} else {
|
||||||
|
d[Query.SHOW_EVENTLOG] = "t"; // any non-false value will do it, keep it short
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setQuery(d);
|
||||||
},
|
},
|
||||||
clearFlows: function () {
|
clearFlows: function () {
|
||||||
jQuery.post("/clear");
|
FlowActions.clear();
|
||||||
},
|
},
|
||||||
onFilterChange: function (val) {
|
onFilterChange: function (val) {
|
||||||
var d = {};
|
var d = {};
|
||||||
@ -139,10 +145,13 @@ var MainMenu = React.createClass({
|
|||||||
var filter = this.getQuery()[Query.FILTER] || "";
|
var filter = this.getQuery()[Query.FILTER] || "";
|
||||||
var highlight = this.getQuery()[Query.HIGHLIGHT] || "";
|
var highlight = this.getQuery()[Query.HIGHLIGHT] || "";
|
||||||
var intercept = this.props.settings.intercept || "";
|
var intercept = this.props.settings.intercept || "";
|
||||||
|
var showEventLog = this.getQuery()[Query.SHOW_EVENTLOG];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<button className={"btn " + (this.props.settings.showEventLog ? "btn-primary" : "btn-default")} onClick={this.toggleEventLog}>
|
<button
|
||||||
|
className={"btn " + (showEventLog ? "btn-primary" : "btn-default")}
|
||||||
|
onClick={this.toggleEventLog}>
|
||||||
<i className="fa fa-database"></i>
|
<i className="fa fa-database"></i>
|
||||||
Display Event Log
|
Display Event Log
|
||||||
</button>
|
</button>
|
||||||
|
@ -145,9 +145,9 @@ var MainView = React.createClass({
|
|||||||
break;
|
break;
|
||||||
case Key.A:
|
case Key.A:
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
$.post("/flows/accept");
|
FlowActions.accept_all();
|
||||||
} else if(this.getSelected()) {
|
} else if(this.getSelected()) {
|
||||||
$.post("/flows/" + this.getSelected().id + "/accept");
|
FlowActions.accept(this.getSelected());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -7,6 +7,7 @@ var Reports = React.createClass({
|
|||||||
|
|
||||||
|
|
||||||
var ProxyAppMain = React.createClass({
|
var ProxyAppMain = React.createClass({
|
||||||
|
mixins: [State],
|
||||||
getInitialState: function () {
|
getInitialState: function () {
|
||||||
var eventStore = new EventLogStore();
|
var eventStore = new EventLogStore();
|
||||||
var flowStore = new FlowStore();
|
var flowStore = new FlowStore();
|
||||||
@ -14,7 +15,6 @@ var ProxyAppMain = React.createClass({
|
|||||||
|
|
||||||
// Default Settings before fetch
|
// Default Settings before fetch
|
||||||
_.extend(settings.dict,{
|
_.extend(settings.dict,{
|
||||||
showEventLog: true
|
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
settings: settings,
|
settings: settings,
|
||||||
@ -37,7 +37,7 @@ var ProxyAppMain = React.createClass({
|
|||||||
render: function () {
|
render: function () {
|
||||||
|
|
||||||
var eventlog;
|
var eventlog;
|
||||||
if (this.state.settings.dict.showEventLog) {
|
if (this.getQuery()[Query.SHOW_EVENTLOG]) {
|
||||||
eventlog = [
|
eventlog = [
|
||||||
<Splitter key="splitter" axis="y"/>,
|
<Splitter key="splitter" axis="y"/>,
|
||||||
<EventLog key="eventlog" eventStore={this.state.eventStore}/>
|
<EventLog key="eventlog" eventStore={this.state.eventStore}/>
|
||||||
|
Loading…
Reference in New Issue
Block a user