/** @jsx React.DOM */
var FlowRow = React.createClass({
render: function(){
var flow = this.props.flow;
var columns = this.props.columns.map(function(column){
return column({flow: flow});
}.bind(this));
return
{columns}
;
}
});
var FlowTableHead = React.createClass({
render: function(){
var columns = this.props.columns.map(function(column){
return column.renderTitle();
}.bind(this));
return {columns};
}
});
var FlowTableBody = React.createClass({
render: function(){
var rows = this.props.flows.map(function(flow){
return
}.bind(this));
return {rows};
}
});
var PathColumn = React.createClass({
statics: {
renderTitle: function(){
return Path | ;
}
},
render: function(){
var flow = this.props.flow;
return {flow.request.scheme + "://" + flow.request.host + flow.request.path} | ;
}
});
var MethodColumn = React.createClass({
statics: {
renderTitle: function(){
return Method | ;
}
},
render: function(){
var flow = this.props.flow;
return {flow.request.method} | ;
}
});
var StatusColumn = React.createClass({
statics: {
renderTitle: function(){
return Status | ;
}
},
render: function(){
var flow = this.props.flow;
var status;
if(flow.response){
status = flow.response.code + " " + flow.response.msg;
} else {
status = null;
}
return {status} | ;
}
});
var TimeColumn = React.createClass({
statics: {
renderTitle: function(){
return Time | ;
}
},
render: function(){
var flow = this.props.flow;
var time;
if(flow.response){
time = Math.round(1000 * (flow.response.timestamp_end - flow.request.timestamp_start))+"ms";
} else {
time = "...";
}
return {time} | ;
}
});
var all_columns = [PathColumn, MethodColumn, StatusColumn, TimeColumn];
var FlowTable = React.createClass({
getInitialState: function () {
return {
flows: [],
columns: all_columns
};
},
componentDidMount: function () {
this.flowStore = FlowStore.getView();
this.flowStore.addListener("change",this.onFlowChange);
},
componentWillUnmount: function () {
this.flowStore.removeListener("change",this.onFlowChange);
this.flowStore.close();
},
onFlowChange: function () {
this.setState({
flows: this.flowStore.getAll()
});
},
render: function () {
var flows = this.state.flows.map(function(flow){
return {flow.request.method} {flow.request.scheme}://{flow.request.host}{flow.request.path}
;
});
return (
);
}
});