{% extends "base_misc.html" %}


{% block content %}

    {% if query %}
    This was your query: <pre>{{ query }}</pre>
    {%  endif %}
    {% if results %}
        Results:
        <table class="table well">
            <tr>
                {% for i in header %}
                    <th>{{ i }}</th>
                {% endfor %}
            </tr>
            {% for row in results %}
                <tr>
                    {% for x in row.values %}
                        <td>{{ x }}</td>
                    {% endfor %}
                </tr>
            {% endfor %}
        </table>
    {% endif %}
    {% if table %}

        <form action="" method="get" class="form-horizontal">
            Limit results to: <input name="limit" id="id_limit" value=10> rows.
            <button name="submit" type="submit">Get {{ table }}</button>
            <br>
            Show only the following columns {{ table }}:
            <input type="hidden" value="{{ table }}" name=table>
            <table class="well table" border=1>
                <tr>
                    <th><input title="select all" type="checkbox" name="check_all"></th>
                    <th>Column Name</th>
                    <th>Type</th>
                    <th>Description</th>
                </tr>
                {% for i in columns %}
                <tr>
                    <td><input type="checkbox" name="check_{{ i.name }}" {% if i.name == "name" %}checked="checked"{% endif %}{% if i.name == "host_name" %}checked="checked"{% endif %}{% if i.name == "description" %}checked="checked"{% endif %}></td>
                    <td>{{ i.name }}</td>
                    <td>{{ i.type }}</td>
                    <td>{{ i.description }}</td>
                </tr>
                {% endfor %}
            </table>
        </form>

    {% else %}
        Please select a table in the sidebar to the right.
    {% endif %}

{% endblock %}

{%  block sidebar %}
    <h5>Tables</h5>
    <ul>
    <li><a href="?table=hosts" title="your Nagios hosts">hosts</a></li>
    <li><a href="?table=services" title="your Nagios services, joined with all data from hosts">services</a></li>
    <li><a href="?table=hostgroups" title="you Nagios hostgroups">hostgroups</a></li>
    <li><a href="?table=servicegroups" title="Your Nagios Servicegroups">servicegroups</a></li>
    <li><a href="?table=contactgroups" title="you Nagios contact groups">contactgroups</a></li>
    <li><a href="?table=servicesbygroup" title="all services grouped by service groups">servicesbygroup</a></li>
    <li><a href="?table=servicesbyhostgroup" title="all services grouped by host groups">servicesbyhostgroup</a></li>
    <li><a href="?table=hostsbygroup" title="all hosts group by host groups">hostsbygroup</a></li>
    <li><a href="?table=contacts" title="your Nagios contacts">contacts</a></li>
    <li><a href="?table=commands" title="your defined Nagios commands">commands</a></li>
    <li><a href="?table=timeperiods" title="time period definitions (currently only name and alias)">timeperiods</a></li>
    <li><a href="?table=downtimes" title="all scheduled host and service downtimes, joined with data from hosts and services">downtimes</a></li>
    <li><a href="?table=comments" title="all host and service comments">comments</a></li>
    <li><a href="?table=log" title="a transparent access to the nagios logfiles (include archived ones)ones">log</a></li>
    <li><a href="?table=status" title="general performance and status information. This table contains exactly one dataset.">status</a></li>
    <li><a href="?table=colimns" title="a complete list of all tables and columns available via Livestatus, including descriptions!">columns</a></li>
    <li><a href="?table=statehist" title="sla statistics for hosts and services, joined with data from">statehist</a> </li>
    </ul>
{% endblock %}