/*
* A copoment for the request log table
*/
import React, { PropTypes } from 'react';
import { Icon } from 'antd';
import RecordRow from 'component/record-row';
import Style from './record-panel.less';
import ClassBind from 'classnames/bind';
import { fetchRecordDetail } from 'action/recordAction';
const StyleBind = ClassBind.bind(Style);
class RecordPanel extends React.Component {
constructor() {
super();
this.state = {
};
this.wsClient = null;
this.getRecordDetail = this.getRecordDetail.bind(this);
this.onKeyUp = this.onKeyUp.bind(this);
this.addKeyEvent = this.addKeyEvent.bind(this);
}
static propTypes = {
dispatch: PropTypes.func,
data: PropTypes.array,
lastActiveRecordId: PropTypes.number,
currentActiveRecordId: PropTypes.number,
loadingNext: PropTypes.bool,
loadingPrev: PropTypes.bool,
stopRefresh: PropTypes.func
}
getRecordDetail(id) {
this.props.dispatch(fetchRecordDetail(id));
this.props.stopRefresh();
}
// get next detail with cursor, to go previous and next
getNextDetail(cursor) {
const currentId = this.props.currentActiveRecordId;
this.props.dispatch(fetchRecordDetail(currentId + cursor));
}
onKeyUp(e) {
if (typeof this.props.currentActiveRecordId === 'number') {
// up arrow
if (e.keyCode === 38) {
this.getNextDetail(-1);
}
// down arrow
if (e.keyCode === 40) {
this.getNextDetail(1);
}
}
}
addKeyEvent() {
document.addEventListener('keyup', this.onKeyUp);
}
getTrs() {
const trs = [];
const { lastActiveRecordId, currentActiveRecordId } = this.props;
const { data: recordList } = this.props;
const length = recordList.length;
for (let i = 0; i < length; i++) {
// only display records less than max limit
if (i >= this.state.maxAllowedRecords) {
break;
}
const item = recordList[i];
const tableRowStyle = StyleBind('row', {
lightBackgroundColor: item.id % 2 === 1,
lightColor: item.statusCode === '',
activeRow: currentActiveRecordId === item.id
});
if (currentActiveRecordId === item.id || lastActiveRecordId === item.id) {
item._render = true;
}
trs.push(
# | Method | Code | Host | Path | Mime | Start |
---|