{% extends 'cabinet/_internal_base.html' %}

{% block breadcrumbs %}
    <li><span>Feed list</span></li>
{% endblock %}

{% block content %}
    <section class="card">
        <header class="card-header">
            <div class="card-button-actions">
                <div class="dropdown">
                    <button class="btn btn-primary btn-sm dropdown-toggle" type="button" data-toggle="dropdown">
                        Add new feed
                    </button>
                    <div class="dropdown-menu dropdown-menu-right">
                        {% for module in feed_modules %}
                            <a class="dropdown-item"
                               href="{% url 'cabinet:feeds:new' content_type=module.content_type.model %}">{{ module.MODULE_NAME }}</a>
                        {% endfor %}
                    </div>
                </div>
            </div>
            <h2 class="card-title">Your feeds</h2>
        </header>
        <div class="card-body">
            <table class="table table-hover table-responsive-md mb-0">
                <thead>
                <tr>
                    <th>Title</th>
                    <th>Module</th>
                    <th>Chat ID</th>
                    <th>Interval</th>
                </tr>
                </thead>
                {% for feed in object_list %}
                <tr class="clickable-row" data-href="{% url 'cabinet:feeds:edit' pk=feed.pk %}">
                    <td>{{ feed.title }}</td>
                    <td>{{ feed.config.MODULE_NAME }}</td>
                    <td>{{ feed.chat_id }}</td>
                    <td>{{ feed.check_interval }}</td>
                </tr>
                {% empty %}
                <tfoot>
                <tr>
                    <td colspan="4">No feeds added</td>
                </tr>
                </tfoot>
                {% endfor %}
            </table>
        </div>
    </section>
{% endblock %}
