anyproxy/web/src/recordPanel.js

71 lines
1.6 KiB
JavaScript
Raw Normal View History

function init(React){
var RecordRow = require("./recordRow").init(React);
var RecordPanel = React.createClass({
getInitialState : function(){
return {
2015-07-01 23:18:35 +08:00
list : [],
filter: ""
};
},
render : function(){
2015-07-01 23:18:35 +08:00
var rowCollection = [],
filterStr = this.state.filter,
filter = filterStr;
//regexp
if(filterStr[0]=="/" && filterStr[filterStr.length-1]=="/"){
try{
filter = new RegExp(filterStr.substr(1,filterStr.length-2));
}catch(e){}
}
for(var i = this.state.list.length-1 ; i >=0 ; i--){
var item = this.state.list[i];
if(item){
2015-07-01 23:18:35 +08:00
if(filter && item){
try{
if(typeof filter == "object" && !filter.test(item.url)){
continue;
}else if(typeof filter == "string" && item.url.indexOf(filter) < 0){
continue;
}
}catch(e){}
}
if(item._justUpdated){
item._justUpdated = false;
item._needRender = true;
}else{
item._needRender = false;
}
rowCollection.push(<RecordRow key={item.id} data={item}></RecordRow>);
}
}
return (
<table className="uk-table uk-table-condensed uk-table-hover">
<thead>
<tr>
2015-07-01 14:43:32 +08:00
<th className="col_id">#</th>
<th className="col_method">method</th>
<th className="col_code">code</th>
<th className="col_host">host</th>
<th className="col_path">path</th>
<th className="col_mime">mime type</th>
<th className="col_time">time</th>
</tr>
</thead>
<tbody>
{rowCollection}
</tbody>
</table>
);
}
});
return RecordPanel;
}
module.exports.init = init;