mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 10:16:27 +00:00
web: fight against react-router
This commit is contained in:
parent
cb45296377
commit
5ccae48b92
@ -206,6 +206,8 @@ header .menu {
|
|||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
|
max-height: 100px;
|
||||||
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
.flow-detail table {
|
.flow-detail table {
|
||||||
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -24,6 +24,8 @@
|
|||||||
padding: 4px 8px;
|
padding: 4px 8px;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
|
max-height: 100px;
|
||||||
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,3 +63,7 @@ var EventLogActions = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Query = {
|
||||||
|
FILTER: "f"
|
||||||
|
};
|
@ -294,7 +294,7 @@ var allTabs = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var FlowDetail = React.createClass({
|
var FlowDetail = React.createClass({
|
||||||
mixins: [StickyHeadMixin, ReactRouter.Navigation, ReactRouter.State],
|
mixins: [StickyHeadMixin, Navigation, State],
|
||||||
getTabs: function (flow) {
|
getTabs: function (flow) {
|
||||||
var tabs = [];
|
var tabs = [];
|
||||||
["request", "response", "error"].forEach(function (e) {
|
["request", "response", "error"].forEach(function (e) {
|
||||||
|
@ -1,4 +1,13 @@
|
|||||||
var MainMenu = React.createClass({
|
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: {
|
statics: {
|
||||||
title: "Traffic",
|
title: "Traffic",
|
||||||
route: "flows"
|
route: "flows"
|
||||||
@ -11,6 +20,13 @@ var MainMenu = React.createClass({
|
|||||||
clearFlows: function () {
|
clearFlows: function () {
|
||||||
$.post("/flows/clear");
|
$.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 () {
|
render: function () {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@ -23,6 +39,14 @@ var MainMenu = React.createClass({
|
|||||||
<i className="fa fa-eraser"></i>
|
<i className="fa fa-eraser"></i>
|
||||||
Clear Flows
|
Clear Flows
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<form className="form-inline" onSubmit={this.setFilter} style={{display:"inline-block"}}>
|
||||||
|
<input type="text" placeholder="filter expression"
|
||||||
|
onChange={this.onFilterChange} value={this.state.filter}
|
||||||
|
className="form-control"
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -70,19 +94,19 @@ var FileMenu = React.createClass({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleNewClick: function(e){
|
handleNewClick: function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.error("unimplemented: handleNewClick");
|
console.error("unimplemented: handleNewClick");
|
||||||
},
|
},
|
||||||
handleOpenClick: function(e){
|
handleOpenClick: function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.error("unimplemented: handleOpenClick");
|
console.error("unimplemented: handleOpenClick");
|
||||||
},
|
},
|
||||||
handleSaveClick: function(e){
|
handleSaveClick: function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.error("unimplemented: handleSaveClick");
|
console.error("unimplemented: handleSaveClick");
|
||||||
},
|
},
|
||||||
handleShutdownClick: function(e){
|
handleShutdownClick: function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
console.error("unimplemented: handleShutdownClick");
|
console.error("unimplemented: handleShutdownClick");
|
||||||
},
|
},
|
||||||
@ -129,7 +153,7 @@ var header_entries = [MainMenu, ToolsMenu, ReportsMenu];
|
|||||||
|
|
||||||
|
|
||||||
var Header = React.createClass({
|
var Header = React.createClass({
|
||||||
mixins: [ReactRouter.Navigation],
|
mixins: [Navigation],
|
||||||
getInitialState: function () {
|
getInitialState: function () {
|
||||||
return {
|
return {
|
||||||
active: header_entries[0]
|
active: header_entries[0]
|
||||||
@ -137,7 +161,7 @@ var Header = React.createClass({
|
|||||||
},
|
},
|
||||||
handleClick: function (active, e) {
|
handleClick: function (active, e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.transitionTo(active.route);
|
this.replaceWith(active.route);
|
||||||
this.setState({active: active});
|
this.setState({active: active});
|
||||||
},
|
},
|
||||||
render: function () {
|
render: function () {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
var MainView = React.createClass({
|
var MainView = React.createClass({
|
||||||
mixins: [ReactRouter.Navigation, ReactRouter.State],
|
mixins: [Navigation, State],
|
||||||
getInitialState: function () {
|
getInitialState: function () {
|
||||||
return {
|
return {
|
||||||
flows: []
|
flows: []
|
||||||
@ -52,7 +52,7 @@ var MainView = React.createClass({
|
|||||||
);
|
);
|
||||||
this.refs.flowTable.scrollIntoView(flow);
|
this.refs.flowTable.scrollIntoView(flow);
|
||||||
} else {
|
} else {
|
||||||
this.replaceWith("flows");
|
this.replaceWith("flows", {});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectFlowRelative: function (shift) {
|
selectFlowRelative: function (shift) {
|
||||||
|
@ -23,6 +23,50 @@ var StickyHeadMixin = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var Navigation = _.extend({}, ReactRouter.Navigation, {
|
||||||
|
setQuery: function (k, v) {
|
||||||
|
var q = this.context.getCurrentQuery();
|
||||||
|
q[k] = v;
|
||||||
|
this.replaceWith(this.context.getCurrentPath(), this.context.getCurrentParams(), q);
|
||||||
|
},
|
||||||
|
replaceWith: function(routeNameOrPath, params, query) {
|
||||||
|
if(routeNameOrPath === undefined){
|
||||||
|
routeNameOrPath = this.context.getCurrentPath();
|
||||||
|
}
|
||||||
|
if(params === undefined){
|
||||||
|
params = this.context.getCurrentParams();
|
||||||
|
}
|
||||||
|
if(query === undefined){
|
||||||
|
query = this.context.getCurrentQuery();
|
||||||
|
}
|
||||||
|
ReactRouter.Navigation.replaceWith.call(this, routeNameOrPath, params, query);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var State = _.extend({}, ReactRouter.State, {
|
||||||
|
getInitialState: function () {
|
||||||
|
this._query = this.context.getCurrentQuery();
|
||||||
|
this._queryWatches = [];
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
onQueryChange: function (key, callback) {
|
||||||
|
this._queryWatches.push({
|
||||||
|
key: key,
|
||||||
|
callback: callback
|
||||||
|
});
|
||||||
|
},
|
||||||
|
componentWillReceiveProps: function (nextProps, nextState) {
|
||||||
|
var q = this.context.getCurrentQuery();
|
||||||
|
for (var i = 0; i < this._queryWatches.length; i++) {
|
||||||
|
var watch = this._queryWatches[i];
|
||||||
|
if (this._query[watch.key] !== q[watch.key]) {
|
||||||
|
watch.callback(this._query[watch.key], q[watch.key], watch.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this._query = q;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var Key = {
|
var Key = {
|
||||||
UP: 38,
|
UP: 38,
|
||||||
DOWN: 40,
|
DOWN: 40,
|
||||||
|
Loading…
Reference in New Issue
Block a user