{% extends "base.html" %}

{% block title %}AS215085 - Router tools | BGP Route visualizer{% endblock %}

{% block page_header %}<H3>BGP Visualizer</H3>{% endblock %}

{% block content %}
    <script type="text/javascript" src="../static/js/vis-network.min.js"></script>
	<script src="../static/js/pages/visual-route.js"></script>
    <section>
        <h2>BGP Route visualizer</h2>
        <div class="bgprtv-container">
            <form id="bgprtv-form">
                <div class="input-group mb-3">
                    <input type="text" id="bgprtv-ip-address" class="form-control" name="ip_address" placeholder="Enter IPv4 or IPv6 Address" required>
                    <button type="submit" class="btn btn-outline-primary">Visualize</button>
                </div>
            </form>
        
            <div class="bgprtv-legend-container">
                <div class="bgprtv-legend-item">
                    <div class="bgprtv-legend-symbol"><div class="bgprtv-legend-line best-path"></div></div>
                    <span><b>Best path</b></span>
                </div>
                <div class="bgprtv-legend-item">
                    <div class="bgprtv-legend-symbol"><div class="bgprtv-legend-line multipath"></div></div>
                    <span><b>Multipath</b></span>
                </div>
                <div class="bgprtv-legend-item">
                    <div class="bgprtv-legend-symbol"><div class="bgprtv-legend-line alt-path"></div></div>
                    <span><b>Alternate path</b></span>
                </div>
                <div class="bgprtv-legend-item">
                    <div class="bgprtv-legend-symbol"><div class="bgprtv-legend-node best-path-node"></div></div>
                    <span>Best path node</span>
                </div>
                <div class="bgprtv-legend-item">
                    <div class="bgprtv-legend-symbol"><div class="bgprtv-legend-node multipath-node"></div></div>
                    <span>Multipath node</span>
                </div>
                <div class="bgprtv-legend-item">
                    <div class="bgprtv-legend-symbol"><div class="bgprtv-legend-node alt-path-node"></div></div>
                    <span>Alternate path node</span>
                </div>

                <div class="bgprtv-filter-container">
                    <h4 class="bgprtv-filter-title">Filter by Path Type:</h4>
                    <div id="bgprtv-filter-controls">
                        <label>
                            <input type="checkbox" name="bgprtv-filter" value="active"> Active paths
                        </label>
                        <span class="bgprtv-filter-separator"></span>
                        <label>
                            <input type="checkbox" name="bgprtv-filter" value="all" checked> All paths
                        </label>
                        <label>
                            <input type="checkbox" name="bgprtv-filter" value="transit"> Transit
                        </label>
                        <label>
                            <input type="checkbox" name="bgprtv-filter" value="ix"> IX
                        </label>
                        <label>
                            <input type="checkbox" name="bgprtv-filter" value="customer"> Customer
                        </label>
                        <label>
                            <input type="checkbox" name="bgprtv-filter" value="other"> Other
                        </label>
                    </div>
                </div>
            </div>
            <div id="bgprtv-loader" style="display:none; text-align: center; padding: 20px;">Loading...</div>
            <div id="bgprtv-error-message" style="display:none; color: #dc3545; text-align: center; padding: 10px; background-color: #f8d7da; border: 1px solid #f5c6cb; border-radius: 4px;"></div>
        
            <div id="bgprtv-mynetwork" data-graph-url="{{ url_for('visual_route_graph') }}"></div>
        </div>
    </section>
{% endblock %}