diff options
Diffstat (limited to 'libmproxy/web/static/js')
| -rw-r--r-- | libmproxy/web/static/js/app.js | 78 | 
1 files changed, 63 insertions, 15 deletions
| diff --git a/libmproxy/web/static/js/app.js b/libmproxy/web/static/js/app.js index e967af89..ea49db4d 100644 --- a/libmproxy/web/static/js/app.js +++ b/libmproxy/web/static/js/app.js @@ -269,13 +269,14 @@ _.extend(FlowView.prototype, EventEmitter.prototype, {          var updates = this.flows;          this.flows = flows;          updates.forEach(function(flow){ -            this.update(flow); +            this._update(flow);          }.bind(this)); +        this.emit("change");      }, -    update: function(flow){ +    _update: function(flow){          console.debug("FIXME: Use UUID");          var idx = _.findIndex(this.flows, function(f){ -            return flow.request.timestamp_start == f.request.timestamp_start +            return flow.request.timestamp_start == f.request.timestamp_start;          });          if(idx < 0){ @@ -283,6 +284,9 @@ _.extend(FlowView.prototype, EventEmitter.prototype, {          } else {              this.flows[idx] = flow;          } +    }, +    update: function(flow){ +        this._update(flow);          this.emit("change");      },  }); @@ -294,6 +298,11 @@ function _FlowStore() {  _.extend(_FlowStore.prototype, EventEmitter.prototype, {      getView: function (since) {          var view = new FlowView(this, !since); + +        $.getJSON("/static/flows.json", function(flows){ +           view.add_bulk(flows);  +        }); +          return view;      },      handle: function (action) { @@ -442,7 +451,10 @@ var FlowRow = React.createClass({displayName: 'FlowRow',      render: function(){          var flow = this.props.flow;          var columns = this.props.columns.map(function(column){ -            return column({flow: flow}); +            return column({ +                key: column.displayName, +                flow: flow +            });          }.bind(this));          return React.DOM.tr(null, columns);      } @@ -460,55 +472,89 @@ var FlowTableHead = React.createClass({displayName: 'FlowTableHead',  var FlowTableBody = React.createClass({displayName: 'FlowTableBody',      render: function(){          var rows = this.props.flows.map(function(flow){ -            return FlowRow({flow: flow, columns: this.props.columns}) +            //TODO: Add UUID +            return FlowRow({flow: flow, columns: this.props.columns});          }.bind(this));          return React.DOM.tbody(null, rows);      }  }); + +var TLSColumn = React.createClass({displayName: 'TLSColumn', +    statics: { +        renderTitle: function(){ +            return React.DOM.th({key: "tls", className: "col-tls"}); +        } +    }, +    render: function(){ +        var flow = this.props.flow; +        var ssl = (flow.request.scheme == "https"); +        return React.DOM.td({className: ssl ? "col-tls-https" : "col-tls-http"}); +    } +}); + + +var IconColumn = React.createClass({displayName: 'IconColumn', +    statics: { +        renderTitle: function(){ +            return React.DOM.th({key: "icon", className: "col-icon"}); +        } +    }, +    render: function(){ +        var flow = this.props.flow; +        return React.DOM.td({className: "resource-icon resource-icon-plain"}); +    } +}); +  var PathColumn = React.createClass({displayName: 'PathColumn',      statics: {          renderTitle: function(){ -            return React.DOM.th({key: "PathColumn"}, "Path"); +            return React.DOM.th({key: "path", className: "col-path"}, "Path");          }      },      render: function(){          var flow = this.props.flow; -        return React.DOM.td({key: "PathColumn"}, flow.request.scheme + "://" + flow.request.host + flow.request.path); +        return React.DOM.td(null, flow.request.scheme + "://" + flow.request.host + flow.request.path);      }  }); + +  var MethodColumn = React.createClass({displayName: 'MethodColumn',      statics: {          renderTitle: function(){ -            return React.DOM.th({key: "MethodColumn"}, "Method"); +            return React.DOM.th({key: "method", className: "col-method"}, "Method");          }      },      render: function(){          var flow = this.props.flow; -        return React.DOM.td({key: "MethodColumn"}, flow.request.method); +        return React.DOM.td(null, flow.request.method);      }  }); + +  var StatusColumn = React.createClass({displayName: 'StatusColumn',      statics: {          renderTitle: function(){ -            return React.DOM.th({key: "StatusColumn"}, "Status"); +            return React.DOM.th({key: "status", className: "col-status"}, "Status");          }      },      render: function(){          var flow = this.props.flow;          var status;          if(flow.response){ -            status = flow.response.code + " " + flow.response.msg; +            status = flow.response.code;          } else {              status = null;          } -        return React.DOM.td({key: "StatusColumn"}, status); +        return React.DOM.td(null, status);      }  }); + +  var TimeColumn = React.createClass({displayName: 'TimeColumn',      statics: {          renderTitle: function(){ -            return React.DOM.th({key: "TimeColumn"}, "Time"); +            return React.DOM.th({key: "time", className: "col-time"}, "Time");          }      },      render: function(){ @@ -519,11 +565,13 @@ var TimeColumn = React.createClass({displayName: 'TimeColumn',          } else {              time = "...";          } -        return React.DOM.td({key: "TimeColumn"}, time); +        return React.DOM.td(null, time);      }  }); -var all_columns = [PathColumn, MethodColumn, StatusColumn, TimeColumn]; + +var all_columns = [TLSColumn, IconColumn, PathColumn, MethodColumn, StatusColumn, TimeColumn]; +  var FlowTable = React.createClass({displayName: 'FlowTable',      getInitialState: function () { | 
