1
0
mirror of https://github.com/alice-lg/alice-lg.git synced 2024-05-11 05:55:03 +00:00

73 lines
1.9 KiB
React
Raw Normal View History

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;
}
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-10-03 21:48:58 +02:00
blackholes={blackholes} />)
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