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:
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):

View File

@ -1,32 +1,28 @@
{% extends "base.html" %}
{% 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 %}
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0 text-dark">
Global Search
<small>Search for domains, records and comments directly from PDNS API</small>
</h1>
<div class="col-6">
<h1 class="m-0 text-dark">Global Search</h1>
</div>
<div class="col-sm-6">
<!-- /.col -->
<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>
<!-- /.container-fluid -->
</div>
<!-- /.content-header -->
{% endblock %}
{% block content %}
@ -34,41 +30,55 @@
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<form action="" method="get">
<div class="card card-outline card-primary shadow">
<div class="card-header">
<h3 class="card-title">Global Search</h3>
</div>
<!-- /.card-header -->
<div class="card-body">
<form action="" method="get">
<div class="callout callout-info">
<p>This tool can be used to search for domains, records, and comments via the PDNS
API.</p>
</div>
<!-- /.callout -->
<div class="form-group">
<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>
<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>
<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>
<!-- /.col -->
</div>
<!-- /.row -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card card-outline card-secondary shadow">
<div class="card-header">
<h3 class="card-title">Domains ({{ domains|length }})</h3>
<h3 class="card-title">Zones ({{ domains|length }})</h3>
</div>
<div class="card-body">
<table id="tbl_domain" class="table table-bordered table-striped">
<!-- /.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>Domain</th>
<th>Zone Name</th>
</tr>
</thead>
<tbody>
@ -82,18 +92,23 @@
</tbody>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card card-outline card-secondary shadow">
<div class="card-header">
<h3 class="card-title">Records ({{ records|length }})</h3>
<h3 class="card-title">Zone Records ({{ records|length }})</h3>
</div>
<div class="card-body">
<table id="tbl_record" class="table table-bordered table-striped">
<!-- /.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>
@ -118,23 +133,28 @@
</tbody>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card card-outline card-secondary shadow">
<div class="card-header">
<h3 class="card-title">Comments ({{ comments|length }})</h3>
</div>
<div class="card-body">
<table id="tbl_comment" class="table table-bordered table-striped">
<!-- /.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>Domain</th>
<th>Zone</th>
</tr>
</thead>
<tbody>
@ -150,20 +170,57 @@
</tbody>
</table>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div>
<!-- /.container-fluid -->
</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 %}
{% block extrascripts %}
<script>
// set up domain result data table
// Initialize DataTables for zones
$("#tbl_domain").DataTable({
"paging": false,
"lengthChange": false,
"searching": false,
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": false,
"autoWidth": false,
@ -172,11 +229,11 @@
]
});
// set up domain result data table
// Initialize DataTables for zone records
$("#tbl_record").DataTable({
"paging": false,
"lengthChange": false,
"searching": false,
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": false,
"autoWidth": false,
@ -185,11 +242,11 @@
]
});
// set up domain result data table
// Initialize DataTables for comments
$("#tbl_comment").DataTable({
"paging": false,
"lengthChange": false,
"searching": false,
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": false,
"autoWidth": false,