start with sort, continue tomorrow

This commit is contained in:
Clemens 2016-06-07 00:17:09 +02:00
parent ac2d8549e5
commit ff2129773f
3 changed files with 14 additions and 36 deletions

View File

@ -1536,28 +1536,13 @@ function FlowTableHead(_ref2) {
var sort = _ref2.sort;
//const hasSort = Column.sortKeyFun;
// let sortDesc = this.props.sort.sortDesc;
//
// if (Column === this.props.sort.sortColumn) {
// sortDesc = !sortDesc;
// this.props.setSort(sortColumn, sortDesc);
// } else {
// this.props.setSort({sortColumn: hasSort && Column, sortDesc: false});
// }
//
// let sortKeyFun = Column.sortKeyFun;
// if (sortDesc) {
// sortKeyFun = hasSort && function () {
// const k = Column.sortKeyFun.apply(this, arguments);
// if (_.isString(k)) {
// return reverseString("" + k);
// }
// return -k;
// };
// }
//this.props.setSortKeyFun(sortKeyFun);
/* function () {
const k = Column.sortKeyFun.apply(this, arguments);
if (_.isString(k)) {
return reverseString("" + k);
}
return -k;
};*/
var sortColumn = sort.sortColumn;
var sortType = sort.sortDesc ? "sort-desc" : "sort-asc";
@ -1583,7 +1568,7 @@ FlowTableHead.propTypes = {
columns: _react2.default.PropTypes.array.isRequired
};
var FlowTableHeadContainer = (0, _reactRedux.connect)(function (state, ownProps) {
var FlowTableHeadContainer = (0, _reactRedux.connect)(function (state) {
return {
sort: state.flows.sort
};
@ -1730,7 +1715,9 @@ var parseFilter = _lodash2.default.memoize(_filt2.default.parse);
var FlowTableContainer = (0, _reactRedux.connect)(function (state) {
return {
flows: state.flows.view
flows: state.flows.view.sort(function (a, b) {
return state.flows.sort.sortColumn ? a.response.status_code > b.response.status_code : 0;
})
};
})(FlowTable);
@ -3801,9 +3788,6 @@ var MainView = _react2.default.createClass({
this.props.setHighlight(nextProps.location.query[_actions.Query.HIGHLIGHT], false);
}
},
setSortKeyFun: function setSortKeyFun(sortKeyFun) {
// FIXME: Move to redux. This requires that sortKeyFun is not a function anymore.
},
selectFlow: function selectFlow(flow) {
// TODO: This belongs into redux
if (flow) {
@ -3934,9 +3918,6 @@ var MainView = _react2.default.createClass({
{ className: "main-view" },
_react2.default.createElement(_flowtable2.default, { ref: "flowTable",
selectFlow: this.selectFlow,
setSortKeyFun: function setSortKeyFun(f) {
return console.log("asdf");
},
setSort: this.props.setSort,
selected: this.props.selectedFlow }),
details

View File

@ -94,7 +94,7 @@ FlowTableHead.propTypes = {
};
const FlowTableHeadContainer = connect(
(state, ownProps) => ({
(state) => ({
sort: state.flows.sort
})
)(FlowTableHead)
@ -215,7 +215,8 @@ const parseFilter = _.memoize(Filt.parse)
const FlowTableContainer = connect(
state => ({
flows: state.flows.view,
// first idea to sort here, but i think thats not good enough ( and not working yet)...
flows: state.flows.view.sort((a,b) => state.flows.sort.sortColumn ? a.response.status_code > b.response.status_code : 0),
})
)(FlowTable)

View File

@ -23,9 +23,6 @@ var MainView = React.createClass({
this.props.setHighlight(nextProps.location.query[Query.HIGHLIGHT], false)
}
},
setSortKeyFun: function (sortKeyFun) {
// FIXME: Move to redux. This requires that sortKeyFun is not a function anymore.
},
selectFlow: function (flow) {
// TODO: This belongs into redux
if (flow) {
@ -161,7 +158,6 @@ var MainView = React.createClass({
<div className="main-view">
<FlowTable ref="flowTable"
selectFlow={this.selectFlow}
setSortKeyFun={(f) => console.log("asdf")}
setSort={this.props.setSort}
selected={this.props.selectedFlow} />
{details}