Working on first-round changes for the global search feature.

This commit is contained in:
Matt Scott 2023-02-19 15:54:11 -05:00
parent 67040ad9c2
commit 14e534468a
2 changed files with 242 additions and 178 deletions

View File

@ -2055,7 +2055,14 @@ def global_search():
else: else:
pass pass
return render_template('admin_global_search.html', domains=domains, records=records, comments=comments) params: dict = {
'query': query if query is not None else '',
'domains': domains,
'records': records,
'comments': comments,
}
return render_template('admin_global_search.html', **params)
def validateURN(value): def validateURN(value):

View File

@ -1,201 +1,258 @@
{% extends "base.html" %} {% extends "base.html" %}
{% set active_page = "admin_global_search" %} {% set active_page = "admin_global_search" %}
{% block title %}<title>Global Search - {{ SITE_NAME }}</title>{% endblock %}
{% block title %}
<title>
Global Search - {{ SITE_NAME }}
</title>
{% endblock %}
{% block dashboard_stat %} {% block dashboard_stat %}
<div class="content-header"> <div class="content-header">
<div class="container-fluid"> <div class="container-fluid">
<div class="row mb-2"> <div class="row mb-2">
<div class="col-sm-6"> <div class="col-6">
<h1 class="m-0 text-dark"> <h1 class="m-0 text-dark">Global Search</h1>
Global Search </div>
<small>Search for domains, records and comments directly from PDNS API</small> <!-- /.col -->
</h1> <div class="col-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ url_for('dashboard.dashboard') }}">Dashboard</a></li>
<li class="breadcrumb-item active">Global Search</li>
</ol>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div> </div>
<div class="col-sm-6"> <!-- /.container-fluid -->
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="{{ url_for('dashboard.dashboard') }}">Dashboard</a></li>
<li class="breadcrumb-item active">Global Search</li>
</ol>
</div>
</div>
</div> </div>
</div> <!-- /.content-header -->
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<section class="content"> <section class="content">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card"> <form action="" method="get">
<div class="card-header"> <div class="card card-outline card-primary shadow">
<h3 class="card-title">Global Search</h3> <div class="card-header">
</div> <h3 class="card-title">Global Search</h3>
<div class="card-body"> </div>
<form action="" method="get"> <!-- /.card-header -->
<div class="input-group"> <div class="card-body">
<input type="text" name="q" class="form-control" placeholder="Your keyword..."> <div class="callout callout-info">
<div class="input-group-btn"> <p>This tool can be used to search for domains, records, and comments via the PDNS
<button type="submit" class="btn btn-success"><i class="fa fa-search"></i></button> API.</p>
</div> </div>
<!-- /.callout -->
<div class="form-group">
<div class="input-group">
<input type="text" name="q" class="form-control" value="{{ query }}"
placeholder="Enter search query...">
<button type="submit" class="btn btn-flat btn-success" title="Execute Query">
<i class="fa fa-search"></i>
</button>
</div>
</div>
<!-- /.form-group -->
<div class="callout callout-warning">
<p>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>
<!-- /.callout -->
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</form>
</div> </div>
</form> <!-- /.col -->
<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>
</div> </div>
</div> <!-- /.row -->
</div>
</div>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card card-outline card-secondary shadow">
<div class="card-header"> <div class="card-header">
<h3 class="card-title">Domains ({{ domains|length }})</h3> <h3 class="card-title">Zones ({{ domains|length }})</h3>
</div>
<!-- /.card-header -->
<div class="card-body table-responsive">
<table id="tbl_domain" class="table table-bordered table-striped table-hover table-sm">
<thead>
<tr>
<th>Zone Name</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>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div> </div>
<div class="card-body"> <!-- /.row -->
<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>
</div>
</div>
</div>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card card-outline card-secondary shadow">
<div class="card-header"> <div class="card-header">
<h3 class="card-title">Records ({{ records|length }})</h3> <h3 class="card-title">Zone Records ({{ records|length }})</h3>
</div>
<!-- /.card-header -->
<div class="card-body table-responsive">
<table id="tbl_record" class="table table-bordered table-striped table-hover table-sm">
<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>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div> </div>
<div class="card-body"> <!-- /.row -->
<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>
</div>
</div>
</div>
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card card-outline card-secondary shadow">
<div class="card-header"> <div class="card-header">
<h3 class="card-title">Comments ({{ comments|length }})</h3> <h3 class="card-title">Comments ({{ comments|length }})</h3>
</div>
<!-- /.card-header -->
<div class="card-body table-responsive">
<table id="tbl_comment" class="table table-bordered table-striped table-hover table-sm">
<thead>
<tr>
<th>Comment</th>
<th>Record</th>
<th>Zone</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>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div> </div>
<div class="card-body"> <!-- /.row -->
<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>
</div>
</div> </div>
</div> <!-- /.container-fluid -->
</div> </section>
</section> {% endblock %}
{% block head_styles %}
<style>
table#tbl_record { table-layout: fixed; }
table#tbl_record thead th:nth-child(0n+1) { width: 20%;}
table#tbl_record thead th:nth-child(0n+2),
table#tbl_record thead th:nth-child(0n+3),
table#tbl_record thead th:nth-child(0n+4) { width: 5%; }
table#tbl_record thead th:nth-child(0n+2),
table#tbl_record thead th:nth-child(0n+3),
table#tbl_record thead th:nth-child(0n+4),
table#tbl_record tbody td:nth-child(0n+2),
table#tbl_record tbody td:nth-child(0n+3),
table#tbl_record tbody td:nth-child(0n+4) { text-align: center; }
table#tbl_record tbody td:first-of-type,
table#tbl_record tbody td:last-of-type { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media only screen and (max-device-width: 480px) {
table#tbl_record thead th:nth-child(0n+1) { width: 10%;}
table#tbl_record thead th:nth-child(0n+2),
table#tbl_record thead th:nth-child(0n+3),
table#tbl_record thead th:nth-child(0n+4) { width: 15%; }
}
@media only screen and (max-device-width: 992px) {
table#tbl_record { table-layout: auto; }
}
@media only screen and (min-device-width: 481px) and (max-device-width: 992px) {
table#tbl_record thead th:nth-child(0n+2),
table#tbl_record thead th:nth-child(0n+3),
table#tbl_record thead th:nth-child(0n+4) { width: 10%; }
}
</style>
{% endblock %} {% endblock %}
{% block extrascripts %} {% block extrascripts %}
<script> <script>
// set up domain result data table // Initialize DataTables for zones
$("#tbl_domain").DataTable({ $("#tbl_domain").DataTable({
"paging": false, "paging": true,
"lengthChange": false, "lengthChange": true,
"searching": false, "searching": true,
"ordering": true, "ordering": true,
"info": false, "info": false,
"autoWidth": false, "autoWidth": false,
"order": [ "order": [
[0, "asc"] [0, "asc"]
] ]
}); });
// set up domain result data table // Initialize DataTables for zone records
$("#tbl_record").DataTable({ $("#tbl_record").DataTable({
"paging": false, "paging": true,
"lengthChange": false, "lengthChange": true,
"searching": false, "searching": true,
"ordering": true, "ordering": true,
"info": false, "info": false,
"autoWidth": false, "autoWidth": false,
"order": [ "order": [
[0, "asc"] [0, "asc"]
] ]
}); });
// set up domain result data table // Initialize DataTables for comments
$("#tbl_comment").DataTable({ $("#tbl_comment").DataTable({
"paging": false, "paging": true,
"lengthChange": false, "lengthChange": true,
"searching": false, "searching": true,
"ordering": true, "ordering": true,
"info": false, "info": false,
"autoWidth": false, "autoWidth": false,
"order": [ "order": [
[0, "asc"] [0, "asc"]
] ]
}); });
</script> </script>
{% endblock %} {% endblock %}