2017-05-16 13:34:00 +02:00
|
|
|
import _ from 'underscore'
|
|
|
|
|
|
|
|
import React from 'react'
|
|
|
|
import {connect} from 'react-redux'
|
|
|
|
|
|
|
|
|
|
|
|
import {loadRouteserverRoutes, loadRouteserverRoutesFiltered} from '../actions'
|
|
|
|
import {showBgpAttributes} from './bgp-attributes-modal-actions'
|
|
|
|
|
2018-08-02 14:52:53 +02:00
|
|
|
import LoadingIndicator from './loading-indicator'
|
2017-05-16 13:34:00 +02:00
|
|
|
|
2018-09-17 23:22:41 +02:00
|
|
|
import RouteColumn from './route/column'
|
2018-08-02 14:52:53 +02:00
|
|
|
|
2018-07-30 22:59:59 +02:00
|
|
|
|
2017-05-16 13:34:00 +02:00
|
|
|
class RoutesTable extends React.Component {
|
|
|
|
showAttributesModal(route) {
|
|
|
|
this.props.dispatch(
|
|
|
|
showBgpAttributes(route)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
let routes = this.props.routes;
|
2018-07-05 10:49:52 +02:00
|
|
|
const routesColumns = this.props.routesColumns;
|
|
|
|
const routesColumnsOrder = this.props.routesColumnsOrder;
|
2018-09-17 19:49:55 +02:00
|
|
|
const blackholes = this.props.blackholes;
|
2017-05-16 13:34:00 +02:00
|
|
|
|
|
|
|
if (!routes || !routes.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-10-19 13:49:12 +02:00
|
|
|
let routesView = routes.map((r,i) => {
|
2017-05-16 13:34:00 +02:00
|
|
|
return (
|
2018-03-23 13:06:27 +01:00
|
|
|
<tr key={`${r.network}_${i}`}>
|
2018-07-05 16:02:49 +02:00
|
|
|
{routesColumnsOrder.map(col => (<RouteColumn key={col}
|
2018-07-05 16:39:31 +02:00
|
|
|
onClick={() => this.showAttributesModal(r)}
|
2018-07-05 16:02:49 +02:00
|
|
|
column={col}
|
|
|
|
route={r}
|
2018-09-17 19:49:55 +02:00
|
|
|
blackholes={blackholes}
|
2018-07-25 15:46:06 +02:00
|
|
|
displayReasons={this.props.type} />)
|
2018-07-05 16:02:49 +02:00
|
|
|
)}
|
2017-05-16 13:34:00 +02:00
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
2018-07-16 19:49:54 +02:00
|
|
|
<table className="table table-striped table-routes">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
{routesColumnsOrder.map(col => <th key={col}>{routesColumns[col]}</th>)}
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{routesView}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2017-05-16 13:34:00 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-16 22:53:57 +02:00
|
|
|
export default connect(
|
2018-09-17 19:49:55 +02:00
|
|
|
(state, props) => {
|
|
|
|
const rsId = parseInt(props.routeserverId, 10);
|
|
|
|
const blackholes = state.config.blackholes[rsId];
|
|
|
|
return {
|
|
|
|
blackholes: blackholes,
|
|
|
|
routesColumns: state.config.routes_columns,
|
|
|
|
routesColumnsOrder: state.config.routes_columns_order,
|
|
|
|
}
|
|
|
|
}
|
2018-07-16 22:53:57 +02:00
|
|
|
)(RoutesTable);
|
2017-05-16 13:34:00 +02:00
|
|
|
|