{% extends "admin/change_list.html" %}
{% load i18n %}
{% load i18n admin_list %}

{% block content_title %}
<h1 id="site-name">{% trans 'Chat Admin' %}</h1>
{% endblock %}

{% block content %}
    <script>
        document.get_messages_url = "{% url live_support.views.get_messages %}";
    </script>
    <div class="module">
        <div class="pending_chats">
            <h4>Pending Chats</h4>
            <ul>
            {% for chat in pending_chats %}
                <li><a href="{% url live_support.views.join_chat chat.id %}">{{ chat.name }}</a></li>
            {% endfor %}
            </ul>
        </div>
        <div class="active_chats">
        <h4>Your Chats</h4>
        <ul class="chat_names">
        {% for chat in active_chats %}
            <li><a href="{{ chat.id }}" send_message_url="{% url live_support.views.post_message chat.id %}">{{ chat.name }}</a></li>
        {% endfor %}
        </ul>
        {% for chat in active_chats %}
            <div class="chat">
                <div class="clear_left"></div>
                <div id="chat_{{ chat.id }}" class="message_list">
                <div class="status">The user seems to have disconnected.</div>
                    <ul>
                    <li>{{ chat.name }}: {{ chat.details }}</li>
                    {% for message in chat.messages.all %}
                        <li id="message_{{ message.id }}">{{ message.name }}: {{ message.message }}</li>
                    {% endfor %}
                    </ul>
                    <div class="message_box_container">
                        <form method="post" action="{% url live_support.views.post_message chat.id %}">
                            {% csrf_token %}
                            <input type="hidden" class="chat_id" name="chat_id" value="{{ chat.id }}" />
                            <input type="text" class="message_box" name="message" />
                            <input type="submit" class="send_message_button" value="Send" />
                        </form>
                        <form method="post" 
                            action="{% url live_support.views.end_chat chat.id %}"
                        >
                            {% csrf_token %}
                            <input type="hidden" name="end_chat" value="true" />
                            <input type="submit" class="end_chat_button" value="End" />
                        </form>
                    </div>
                </div>
            </div>
        {% endfor %}
        </div>
        <div class="clear_left"></div>
    </div>
<br />
<br />
{# block.super #}
{% endblock %}

