mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 22:50:26 +00:00
Merge remote-tracking branch 'Ramalama2/master'
This commit is contained in:
commit
5ea38a9b6d
4
app/__init__.py
Normal file → Executable file
4
app/__init__.py
Normal file → Executable file
@ -7,6 +7,10 @@ from authlib.flask.client import OAuth as AuthlibOAuth
|
||||
from sqlalchemy.exc import OperationalError
|
||||
from flask_seasurf import SeaSurf
|
||||
|
||||
### SYBPATCH ###
|
||||
from app.customboxes import customBoxes
|
||||
### SYBPATCH ###
|
||||
|
||||
# subclass SQLAlchemy to enable pool_pre_ping
|
||||
class SQLAlchemy(SA):
|
||||
def apply_pool_defaults(self, app, options):
|
||||
|
5
app/customboxes.py
Executable file
5
app/customboxes.py
Executable file
@ -0,0 +1,5 @@
|
||||
|
||||
# "boxId":("title","filter")
|
||||
class customBoxes:
|
||||
boxes = {"reverse": (" ", " "), "ip6arpa": ("ip6","%.ip6.arpa"), "inaddrarpa": ("in-addr","%.in-addr.arpa")}
|
||||
order = ["reverse", "ip6arpa", "inaddrarpa"]
|
136
app/templates/dashboard.html
Normal file → Executable file
136
app/templates/dashboard.html
Normal file → Executable file
@ -120,43 +120,89 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">Hosted Domains</h3>{% if show_bg_domain_button %}<button type="button" class="btn btn-flat btn-primary refresh-bg-button pull-right"><i class="fa fa-refresh"></i> Sync domains </button>{% endif %}
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<table id="tbl_domain_list" class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>DNSSEC</th>
|
||||
<th>Type</th>
|
||||
<th>Serial</th>
|
||||
<th>Master</th>
|
||||
<th>Account</th>
|
||||
<th {% if current_user.role.name not in ['Administrator','Operator'] %}width="6%"{% else %}width="25%"{% endif %}>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Content loaded via AJAX. -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
</div>
|
||||
<!-- /.box -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
|
||||
<!--SYBPATCH START-->
|
||||
<div class="nav-tabs-custom">
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="#tab_{{custom_boxes.order[0]}}" data-toggle="tab">Hosted Domains <b>{{custom_boxes.boxes[custom_boxes.order[0]][0]}}</b></a></li>
|
||||
{% for boxId in custom_boxes.order[1:] %}
|
||||
<li><a href="#tab_{{boxId}}" data-toggle="tab">Hosted Domains <b>{{custom_boxes.boxes[boxId][0]}}</b></a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
{% for boxId in custom_boxes.order %}
|
||||
<div class="tab-pane" id='tab_{{boxId}}'>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">Hosted Domains <b>{{custom_boxes.boxes[boxId][0]}}</b></h3>{% if show_bg_domain_button %}<button type="button" class="btn btn-flat btn-primary refresh-bg-button pull-right"><i class="fa fa-refresh"></i> Sync domains </button>{% endif %}
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<table id='tbl_domain_list_{{boxId}}' class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>DNSSEC</th>
|
||||
<th>Type</th>
|
||||
<th>Serial</th>
|
||||
<th>Master</th>
|
||||
<th>Account</th>
|
||||
<th {% if current_user.role.name not in ['Administrator','Operator'] %}width="6%"{% else %}width="25%"{% endif %}>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div><!-- /.tab-content -->
|
||||
</div><!-- custom tabs -->
|
||||
<!--SYBPATCH END-->
|
||||
|
||||
</section>
|
||||
<!-- /.content -->
|
||||
{% endblock %}
|
||||
{% block extrascripts %}
|
||||
<script>
|
||||
PDNS_VERSION = '{{ SETTING.get("pdns_version") }}';
|
||||
|
||||
//SYBPATCH START//
|
||||
function setUpDomainList(id ,url){
|
||||
$(id).DataTable({
|
||||
"paging" : true,
|
||||
"lengthChange" : true,
|
||||
"searching" : true,
|
||||
"ordering" : true,
|
||||
"columnDefs": [
|
||||
{ "orderable": false, "targets": [-1] }
|
||||
{% if current_user.role.name not in ['Administrator', 'Operator'] %},{ "visible": false, "targets": [-2] }{% endif %}
|
||||
],
|
||||
"processing" : true,
|
||||
"serverSide" : true,
|
||||
"ajax" : url,
|
||||
"info" : false,
|
||||
"autoWidth" : false,
|
||||
{% if SETTING.get('default_domain_table_size') in ['10','25','50','100'] %}
|
||||
"lengthMenu": [ [10, 25, 50, 100, -1],
|
||||
[10, 25, 50, 100, "All"]],
|
||||
{% else %}
|
||||
"lengthMenu": [ [10, 25, 50, 100, {{ SETTING.get('default_domain_table_size') }}, -1],
|
||||
[10, 25, 50, 100, {{ SETTING.get('default_domain_table_size') }}, "All"]],
|
||||
{% endif %}
|
||||
"pageLength": {{ SETTING.get('default_domain_table_size') }}
|
||||
});
|
||||
}
|
||||
$('#tab_{{custom_boxes.order[0]}}').addClass( "active" );
|
||||
{% for boxId in custom_boxes.order %}
|
||||
setUpDomainList("#tbl_domain_list_{{boxId}}", "{{url_for('dashboard_domains_custom',boxId=boxId)}}");
|
||||
{% endfor %}
|
||||
//SYBPATCH END//
|
||||
|
||||
// set up history data table
|
||||
$("#tbl_history").DataTable({
|
||||
"paging" : false,
|
||||
@ -174,31 +220,9 @@
|
||||
}
|
||||
]
|
||||
});
|
||||
// set up domain list
|
||||
$("#tbl_domain_list").DataTable({
|
||||
"paging" : true,
|
||||
"lengthChange" : true,
|
||||
"searching" : true,
|
||||
"ordering" : true,
|
||||
"columnDefs": [
|
||||
{ "orderable": false, "targets": [-1] }
|
||||
{% if current_user.role.name not in ['Administrator', 'Operator'] %},{ "visible": false, "targets": [-2] }{% endif %}
|
||||
],
|
||||
"processing" : true,
|
||||
"serverSide" : true,
|
||||
"ajax" : "{{ url_for('dashboard_domains') }}",
|
||||
"info" : false,
|
||||
"autoWidth" : false,
|
||||
{% if SETTING.get('default_domain_table_size') in ['10','25','50','100'] %}
|
||||
"lengthMenu": [ [10, 25, 50, 100, -1],
|
||||
[10, 25, 50, 100, "All"]],
|
||||
{% else %}
|
||||
"lengthMenu": [ [10, 25, 50, 100, {{ SETTING.get('default_domain_table_size') }}, -1],
|
||||
[10, 25, 50, 100, {{ SETTING.get('default_domain_table_size') }}, "All"]],
|
||||
{% endif %}
|
||||
"pageLength": {{ SETTING.get('default_domain_table_size') }}
|
||||
});
|
||||
$(document.body).on('click', '.history-info-button', function() {
|
||||
|
||||
$(document.body).on('click', '.history-info-button', function()
|
||||
{
|
||||
var modal = $("#modal_history_info");
|
||||
var info = $(this).val();
|
||||
$('#modal-code-content').html(json_library.prettyPrint(info));
|
||||
|
88
app/views.py
Normal file → Executable file
88
app/views.py
Normal file → Executable file
@ -488,7 +488,89 @@ def saml_logout():
|
||||
else:
|
||||
return render_template('errors/SAML.html', errors=errors)
|
||||
|
||||
# SYBPATCH
|
||||
#########################################################
|
||||
from app import customBoxes
|
||||
from sqlalchemy import not_
|
||||
|
||||
@app.route('/dashboard_domains_custom/<path:boxId>', methods=['GET'])
|
||||
@login_required
|
||||
def dashboard_domains_custom(boxId):
|
||||
if current_user.role.name in ['Administrator', 'Operator']:
|
||||
domains = Domain.query
|
||||
else:
|
||||
domains = User(id=current_user.id).get_domain_query()
|
||||
|
||||
template = app.jinja_env.get_template("dashboard_domain.html")
|
||||
render = template.make_module(vars={"current_user": current_user})
|
||||
|
||||
columns = [Domain.name, Domain.dnssec, Domain.type, Domain.serial, Domain.master, Domain.account]
|
||||
# History.created_on.desc()
|
||||
order_by = []
|
||||
for i in range(len(columns)):
|
||||
column_index = request.args.get("order[{0}][column]".format(i))
|
||||
sort_direction = request.args.get("order[{0}][dir]".format(i))
|
||||
if column_index is None:
|
||||
break
|
||||
if sort_direction != "asc" and sort_direction != "desc":
|
||||
sort_direction = "asc"
|
||||
|
||||
column = columns[int(column_index)]
|
||||
order_by.append(getattr(column, sort_direction)())
|
||||
|
||||
if order_by:
|
||||
domains = domains.order_by(*order_by)
|
||||
|
||||
if boxId == "reverse":
|
||||
for boxId in customBoxes.order:
|
||||
if boxId == "reverse": continue
|
||||
domains = domains.filter(not_(Domain.name.ilike(customBoxes.boxes[boxId][1])))
|
||||
else:
|
||||
domains = domains.filter(Domain.name.ilike(customBoxes.boxes[boxId][1]))
|
||||
|
||||
total_count = domains.count()
|
||||
|
||||
search = request.args.get("search[value]")
|
||||
if search:
|
||||
start = "" if search.startswith("^") else "%"
|
||||
end = "" if search.endswith("$") else "%"
|
||||
|
||||
if current_user.role.name in ['Administrator', 'Operator']:
|
||||
domains = domains.outerjoin(Account).filter(Domain.name.ilike(start + search.strip("^$") + end) |
|
||||
Account.name.ilike(start + search.strip("^$") + end) |
|
||||
Account.description.ilike(start + search.strip("^$") + end))
|
||||
else:
|
||||
domains = domains.filter(Domain.name.ilike(start + search.strip("^$") + end))
|
||||
|
||||
filtered_count = domains.count()
|
||||
|
||||
start = int(request.args.get("start", 0))
|
||||
length = min(int(request.args.get("length", 0)), 100)
|
||||
|
||||
if length != -1:
|
||||
domains = domains[start:start + length]
|
||||
|
||||
data = []
|
||||
for domain in domains:
|
||||
data.append([
|
||||
render.name(domain),
|
||||
render.dnssec(domain),
|
||||
render.type(domain),
|
||||
render.serial(domain),
|
||||
render.master(domain),
|
||||
render.account(domain),
|
||||
render.actions(domain),
|
||||
])
|
||||
|
||||
response_data = {
|
||||
"draw": int(request.args.get("draw", 0)),
|
||||
"recordsTotal": total_count,
|
||||
"recordsFiltered": filtered_count,
|
||||
"data": data,
|
||||
}
|
||||
return jsonify(response_data)
|
||||
|
||||
# add custom boxes
|
||||
@app.route('/dashboard', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def dashboard():
|
||||
@ -514,7 +596,11 @@ def dashboard():
|
||||
else:
|
||||
uptime = 0
|
||||
|
||||
return render_template('dashboard.html', domain_count=domain_count, users=users, history_number=history_number, uptime=uptime, histories=history, show_bg_domain_button=BG_DOMAIN_UPDATE)
|
||||
# add custom boxes to render_template
|
||||
return render_template('dashboard.html', custom_boxes=customBoxes, domain_count=domain_count, users=users, history_number=history_number, uptime=uptime, histories=history, show_bg_domain_button=BG_DOMAIN_UPDATE)
|
||||
|
||||
# SYBPATCH END
|
||||
#########################################################
|
||||
|
||||
|
||||
@app.route('/dashboard-domains', methods=['GET'])
|
||||
|
Loading…
Reference in New Issue
Block a user