2018-08-03 12:22:10 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Lookup Results Table
|
|
|
|
* --------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react'
|
|
|
|
import {connect} from 'react-redux'
|
|
|
|
import {Link} from 'react-router'
|
|
|
|
import {push} from 'react-router-redux'
|
|
|
|
|
|
|
|
|
|
|
|
import {_lookup,
|
|
|
|
ColDefault,
|
|
|
|
ColNetwork,
|
2018-09-17 02:08:30 +02:00
|
|
|
ColFlags,
|
2018-09-17 23:22:41 +02:00
|
|
|
ColAsPath} from 'components/routeservers/routes/route/column'
|
2018-08-03 12:22:10 +02:00
|
|
|
|
|
|
|
import {showBgpAttributes}
|
|
|
|
from 'components/routeservers/routes/bgp-attributes-modal-actions'
|
|
|
|
|
|
|
|
|
|
|
|
// Link Wrappers:
|
|
|
|
const ColLinkedNeighbor = function(props) {
|
|
|
|
const route = props.route;
|
|
|
|
const to = `/routeservers/${route.routeserver.id}/protocols/${route.neighbour.id}/routes`;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<td>
|
|
|
|
<Link to={to}>{_lookup(props.route, props.column)}</Link>
|
|
|
|
</td>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
const ColLinkedRouteserver = function(props) {
|
|
|
|
const route = props.route;
|
|
|
|
const to = `/routeservers/${route.routeserver.id}`;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<td>
|
|
|
|
<Link to={to}>{_lookup(props.route, props.column)}</Link>
|
|
|
|
</td>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Custom RouteColumn
|
|
|
|
const RouteColumn = function(props) {
|
|
|
|
const widgets = {
|
|
|
|
"network": ColNetwork,
|
|
|
|
|
2018-09-17 02:08:30 +02:00
|
|
|
"flags": ColFlags,
|
|
|
|
|
2018-08-03 12:22:10 +02:00
|
|
|
"bgp.as_path": ColAsPath,
|
|
|
|
"ASPath": ColAsPath,
|
|
|
|
|
|
|
|
"neighbour.description": ColLinkedNeighbor,
|
|
|
|
"neighbour.asn": ColLinkedNeighbor,
|
|
|
|
|
|
|
|
"routeserver.name": ColLinkedRouteserver
|
|
|
|
};
|
|
|
|
|
2018-09-17 20:01:48 +02:00
|
|
|
const rsId = props.route.routeserver.id;
|
|
|
|
const blackholes = props.blackholesMap[rsId] || [];
|
|
|
|
|
2018-08-03 12:22:10 +02:00
|
|
|
let Widget = widgets[props.column] || ColDefault;
|
|
|
|
return (
|
|
|
|
<Widget column={props.column} route={props.route}
|
|
|
|
displayReasons={props.displayReasons}
|
2018-09-17 20:01:48 +02:00
|
|
|
blackholes={blackholes}
|
2018-08-03 12:22:10 +02:00
|
|
|
onClick={props.onClick} />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-17 01:29:56 +02:00
|
|
|
class LookupRoutesTable extends React.Component {
|
2018-08-03 12:22:10 +02:00
|
|
|
showAttributesModal(route) {
|
|
|
|
this.props.dispatch(showBgpAttributes(route));
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
let routes = this.props.routes;
|
|
|
|
const routesColumns = this.props.routesColumns;
|
|
|
|
const routesColumnsOrder = this.props.routesColumnsOrder;
|
|
|
|
|
|
|
|
if (!routes || !routes.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
let routesView = routes.map((r,i) => {
|
|
|
|
return (
|
2018-12-16 17:18:59 +01:00
|
|
|
<tr key={i}>
|
2018-08-03 12:22:10 +02:00
|
|
|
{routesColumnsOrder.map(col => {
|
|
|
|
return (<RouteColumn key={col}
|
|
|
|
onClick={() => this.showAttributesModal(r)}
|
2018-09-17 20:01:48 +02:00
|
|
|
blackholesMap={this.props.blackholesMap}
|
2018-08-03 12:22:10 +02:00
|
|
|
column={col}
|
|
|
|
route={r}
|
2018-09-17 01:29:56 +02:00
|
|
|
displayReasons={this.props.displayReasons} />);
|
2018-08-03 12:22:10 +02:00
|
|
|
}
|
|
|
|
)}
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
|
|
|
<table className="table table-striped table-routes">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
{routesColumnsOrder.map(col => <th key={col}>{routesColumns[col]}</th>)}
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{routesView}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
(state) => ({
|
2018-09-17 20:01:48 +02:00
|
|
|
blackholesMap: state.config.blackholes,
|
2018-08-03 12:22:10 +02:00
|
|
|
routesColumns: state.config.lookup_columns,
|
|
|
|
routesColumnsOrder: state.config.lookup_columns_order,
|
|
|
|
})
|
2018-09-17 01:29:56 +02:00
|
|
|
)(LookupRoutesTable);
|
2018-08-03 12:22:10 +02:00
|
|
|
|
|
|
|
|