{% extends "base.html" %}
{% set active_page = "admin_global_search" %}
{% block title %}
<title>Global Search - {{ SITE_NAME }}</title>
{% endblock %} {% block dashboard_stat %}
<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        Global Search <small>Search for domains, records and comments directly from PDNS API</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="{{ url_for('dashboard.dashboard') }}"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">Global Search</li>
    </ol>
</section>
{% endblock %} {% block content %}
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box-body">
                <!-- search form -->
                <form action="" method="get">
                    <div class="input-group">
                        <input type="text" name="q" class="form-control" placeholder="Your keyword...">
                        <div class="input-group-btn">
                            <button type="submit" class="btn btn-success"><i class="fa fa-search"></i></button>
                        </div>
                    </div>
                </form>
                <div>
                    <p><b>Hints:</b> The * character can be used in your keyword as a wildcard character and the ? character can be used as
                        a wildcard for a
                        single character.</p>
                </div>
                <!-- /.search form -->
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <h3 class="box-title">Domains ({{ domains|length }})</h3>
                </div>
                <div class="box-body">
                    <table id="tbl_domain" class="table table-bordered table-striped">
                        <thead>
                            <tr>
                                <th>Domain</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for domain in domains %}
                            <tr class="odd gradeX">
                                <td>
                                    <a href="{{ url_for('domain.domain', domain_name=domain['name']) }}">{{ domain['name'] }}</a>
                                </td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </div>
        <!-- /.col -->
    </div>

    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <h3 class="box-title">Records ({{ records|length }})</h3>
                </div>
                <div class="box-body">
                    <table id="tbl_record" class="table table-bordered table-striped">
                        <thead>
                            <tr>
                                <th>Name</th>
                                <th>Type</th>
                                <th>Status</th>
                                <th>TTL</th>
                                <th>Data</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for record in records %}
                            <tr class="odd gradeX">
                                <td>
                                    <a href="{{ url_for('domain.domain', domain_name=record['zone_id']) }}">{{ record['name'] }}</a>
                                </td>
                                <td>{{ record['type'] }}</td>
                                <td>{{ 'Disabled' if record['disabled'] else 'Active' }}</td>
                                <td>{{ record['ttl'] }}</td>
                                <td>{{ record['content'] }}</td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </div>
        <!-- /.col -->
    </div>

    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <h3 class="box-title">Comments ({{ comments|length }})</h3>
                </div>
                <div class="box-body">
                    <table id="tbl_comment" class="table table-bordered table-striped">
                        <thead>
                            <tr>
                                <th>Comment</th>
                                <th>Record</th>
                                <th>Domain</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for comment in comments %}
                            <tr class="odd gradeX">
                                <td>{{ comment['content'] }}</td>
                                <td>{{ comment['name'] }}</td>
                                <td>
                                    <a href="{{ url_for('domain.domain', domain_name=comment['zone_id']) }}">{{ comment['zone_id'] }}</a>
                                </td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </div>
        <!-- /.col -->
    </div>
</section>
{% endblock %}
{% block extrascripts %}
<script>
    // set up domain result data table
    $("#tbl_domain").DataTable({
        "paging": false,
        "lengthChange": false,
        "searching": false,
        "ordering": true,
        "info": false,
        "autoWidth": false,
        "order": [
            [0, "asc"]
        ]
    });
</script>

<script>
    // set up domain result data table
    $("#tbl_record").DataTable({
        "paging": false,
        "lengthChange": false,
        "searching": false,
        "ordering": true,
        "info": false,
        "autoWidth": false,
        "order": [
            [0, "asc"]
        ]
    });
</script>

<script>
    // set up domain result data table
    $("#tbl_comment").DataTable({
        "paging": false,
        "lengthChange": false,
        "searching": false,
        "ordering": true,
        "info": false,
        "autoWidth": false,
        "order": [
            [0, "asc"]
        ]
    });
</script>
{% endblock %}
