<!--
 Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

{% extends 'base.html' %}

{% block content %}
    <h1>Topology</h1>

    <div class="row">
       
        <div class="col">
            {{ speakers | length }} speakers found in context <i>{{ session['context_uuid'] }}</i>
        </div>
    </div>
        <div class="row">
        <div class="col">
            <a href="{{ url_for('topology.addSpeaker') }}" class="btn btn-primary" style="margin-bottom: 10px;">
                <i class="bi bi-plus"></i>
                Add BGPLS Speaker
            </a>
        </div>

        <div class="col">
            <a href="{{ url_for('topology.editSpeakers') }}" class="btn btn-primary" style="margin-bottom: 10px;">
                <i class="bi bi-pencil-square"></i>
                Edit BGPLS Speakers
            </a>
        </div>
    </div>  

    <table class="table table-striped table-hover">
        <thead>
          <tr>
            <th scope="col">Node name</th>
            <th scope="col">Local IGP Id</th>
            <th scope="col">Remote IGP Id</th>
            <th scope="col">Learnt from</th>
            <th scope="col"></th>
          </tr>
        </thead>
        <tbody>
            {% if disdev %}
                {% for device in disdev %}
                <tr>
                    <td>{{ device.nodeName }}</td>
                    <td>{{ device.igpID }}</td>
                    <td></td>
                    <td>{{ device.learntFrom }}</td>
                    <td>
                        <div class="col">
                            <a href='{{ url_for("topology.add",device_name=device.nodeName)}}'>
                                <i class="bi bi-plus"></i>
                                Add Device
                            </a>
                        </div>
                            
                    
                    </td>
                </tr>
                {% endfor %}
            {% else %}
                <tr>
                    <td colspan="3">No devices found</td>
                </tr>
            {% endif %}
        </tbody>
        <tbody>
            {% if dislink %}
                {% for link in dislink %}
                <tr>
                    <td></td>
                    <td>{{ link.local.nodeName }}</td>
                    <td>{{ link.remote.nodeName }}</td>
                    <td>{{ link.learntFrom }}</td>
                    <td>
                        <div class="col">
                            <a href=''>
                                <i class="bi bi-plus"></i>
                                Add Link
                            </a>
                        </div>
                            
                    
                    </td>
                </tr>
                {% endfor %}
            {% else %}
                <tr>
                    <td colspan="3">No devices found</td>
                </tr>
            {% endif %}
        </tbody>
    </table>
        
    <script src="https://d3js.org/d3.v4.min.js"></script>
    <div id="topology"></div>
    <script src="{{ url_for('js.topology_js') }}"></script>

{% endblock %}