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

101 lines
2.3 KiB
React
Raw Normal View History

2017-05-16 13:34:00 +02:00
2017-06-26 15:35:54 +02:00
import _ from 'underscore'
2017-05-16 13:34:00 +02:00
import React from 'react'
2017-06-26 15:35:54 +02:00
import {connect} from 'react-redux'
2017-05-16 13:34:00 +02:00
2017-06-26 15:35:54 +02:00
import FilterReason
from 'components/routeservers/large-communities/filter-reason'
2017-05-16 13:34:00 +02:00
2017-06-26 15:35:54 +02:00
import NoexportReason
from 'components/routeservers/large-communities/noexport-reason'
2017-05-16 13:34:00 +02:00
2017-06-26 15:35:54 +02:00
class ResultsTable extends React.Component {
render() {
if (this.props.routes.length == 0) {
return null;
2017-05-16 13:34:00 +02:00
}
2017-06-26 15:35:54 +02:00
const routes = this.props.routes.map((route) => (
<tr key={route.id + route.routeserver.id}>
<td>{route.network}</td>
<td>{route.bgp.as_path.join(" ")}</td>
<td>{route.gateway}</td>
<td>{route.neighbour.description}</td>
<td>{route.neighbour.asn}</td>
<td>{route.routeserver.name}</td>
</tr>
));
2017-05-16 13:34:00 +02:00
2017-06-26 15:35:54 +02:00
return (
<div className="card">
{this.props.header}
<table className="table table-striped table-routes">
<thead>
<tr>
<th>Network</th>
<th>AS Path</th>
<th>Gateway</th>
<th>Neighbour</th>
<th>ASN</th>
<th>RS</th>
</tr>
</thead>
<tbody>
{routes}
</tbody>
</table>
</div>
);
}
}
2017-05-16 13:34:00 +02:00
2017-06-26 15:35:54 +02:00
class LookupResults extends React.Component {
render() {
const mkHeader = (color, action) => (
<p style={{"color": color, "textTransform": "uppercase"}}>
Routes {action}
</p>
);
const filtdHeader = mkHeader("orange", "filtered");
const recvdHeader = mkHeader("green", "accepted");
const noexHeader = mkHeader("red", "not exported");
let filteredRoutes = this.props.routes.filtered;
let importedRoutes = this.props.routes.imported;
return (
<div className="lookup-results">
<ResultsTable header={filtdHeader} routes={filteredRoutes} />
<ResultsTable header={recvdHeader} routes={importedRoutes} />
</div>
)
}
}
function selectRoutes(routes, state) {
return _.where(routes, {state: state});
2017-05-16 13:34:00 +02:00
}
2017-06-26 15:35:54 +02:00
export default connect(
(state) => {
let routes = state.lookup.results;
let filteredRoutes = selectRoutes(routes, 'filtered');
let importedRoutes = selectRoutes(routes, 'imported');
return {
routes: {
filtered: filteredRoutes,
imported: importedRoutes
}
}
}
)(LookupResults);
2017-05-16 13:34:00 +02:00