{# Copyright (c) 2016, NVIDIA CORPORATION.  All rights reserved. #}
<div class="tab-content">
    {% set batch_size = 10 %}
    {% for batch in form.previous_networks|batch(batch_size) %}
    {% set batch_loop_index = loop.index0 %}
    <div class="tab-pane{{' active' if loop.index==1}}" id="previous_networks-page-{{loop.index}}">

        <table class="table">
            <tr>
                <th>Network</th>
                <th>Pretrained Model</th>
                <th></th>
            </tr>
            {% for network in batch %}
            {% set inner_index = batch_loop_index * batch_size + loop.index0 %}
            {% set previous_job = previous_networks_fullinfo[inner_index] %}
            <tr>
                <td>
                    {{network}}
                    {{network.label}}
                    <a href="{{url_for('digits.model.views.show', job_id=network.data)}}" target="_blank">View</a>
                    <span class="badge">{{previous_job.train_task().get_framework_id()}}</span>
                </td>
                <td>
                    {% set snapshot_list = previous_network_snapshots[inner_index] %}
                    {% if snapshot_list|length %}
                    <select class="form-control" id="{{network.data}}-snapshot" name="{{network.data}}-snapshot">
                        {% for each_epoch in snapshot_list %}
                        <option value="{{each_epoch[0]}}">{{each_epoch[1]}}</option>
                        {% endfor %}
                    </select>
                    {% endif %}
                </td>
                <td><a class="btn btn-sm" onClick="customizeNetwork('{{network.data}}', '{{network.data}}-snapshot', '{{previous_job.train_task().get_framework_id()}}' );">Customize</a></td>
            </tr>
            {% else %}
            <tr>
                <td><i>None</i></td>
            </tr>
            {% endfor %}
        </table>

    </div>
    {% endfor %}
</div>

{% if form.previous_networks.choices|length > batch_size %}
<div class="text-center">
    <ul class="pagination">
        {% for i in range((form.previous_networks.choices|length/batch_size)|round(0,'ceil')|int) %}
        <li class="{{'active' if i==0}}"><a href="#previous_networks-page-{{i+1}}" data-toggle="tab">{{i+1}}</a></li>
        {% endfor %}
    </ul>
</div>
{% endif %}
