mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-09 15:10:27 +00:00
Working on the first-round updates for the zone template editor.
This commit is contained in:
parent
fe49651e81
commit
4d64076dac
@ -1,27 +1,18 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% set active_page = "admin_domain_template" %}
|
||||
|
||||
{% block title %}
|
||||
<title>
|
||||
Edit Template - {{ SITE_NAME }}
|
||||
</title>
|
||||
{% endblock %}
|
||||
{% block title %}<title>Edit Zone Template - {{ SITE_NAME }}</title>{% endblock %}
|
||||
|
||||
{% block dashboard_stat %}
|
||||
<div class="content-header">
|
||||
<div class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1 class="m-0 text-dark">
|
||||
Template Edit
|
||||
<small>{{ template }}</small>
|
||||
</h1>
|
||||
<h1 class="m-0 text-dark">Edit Zone Template</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="{{ url_for('admin.templates') }}">Templates</a></li>
|
||||
<li class="breadcrumb-item active">Template Edit: {{ template }}</li>
|
||||
<li class="breadcrumb-item active">Edit Zone Template</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
@ -30,24 +21,27 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="content">
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card card-outline card-primary shadow">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Manage Template Records for {{ template }}</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<button type="button" class="btn btn-primary float-left button_add_record" id="{{ template }}">
|
||||
<h3 class="card-title">Zone Template Editor</h3>
|
||||
<div class="card-tools">
|
||||
<button type="button" class="btn btn-primary float-left button_add_record"
|
||||
title="Add Record" id="{{ template }}">
|
||||
<i class="fa-solid fa-plus"></i> Add Record
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary float-right button_apply_changes" id="{{ template }}">
|
||||
<i class="fa-solid fa-save"></i> Save Changes
|
||||
<button type="button" class="btn btn-primary float-right button_apply_changes ml-2"
|
||||
title="Save Template" id="{{ template }}">
|
||||
<i class="fa-solid fa-save"></i> Save Template
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table id="tbl_records" class="table table-bordered table-striped">
|
||||
</div>
|
||||
<div class="card-body table-responsive">
|
||||
<table id="tbl_records"
|
||||
class="table table-bordered table-striped table-hover table-sm records">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
@ -56,8 +50,7 @@
|
||||
<th>TTL</th>
|
||||
<th>Data</th>
|
||||
<th>Comment</th>
|
||||
<th>Edit</th>
|
||||
<th>Delete</th>
|
||||
<th>Actions</th>
|
||||
<th>ID</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -82,20 +75,17 @@
|
||||
<td>
|
||||
{{ record.comment }}
|
||||
</td>
|
||||
<td width="6%">
|
||||
<button type="button" class="btn btn-warning button_edit">
|
||||
<td>
|
||||
<button type="button" class="btn btn-warning button_edit"
|
||||
title="Edit Record">
|
||||
<i class="fa-solid fa-edit"></i> Edit
|
||||
</button>
|
||||
</td>
|
||||
<td width="6%">
|
||||
<button type="button" class="btn btn-danger button_delete">
|
||||
<button type="button" class="btn btn-danger button_delete"
|
||||
title="Delete Record">
|
||||
<i class="fa-solid fa-trash"></i> Delete
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
{{ record.id }}
|
||||
</td>
|
||||
</td>
|
||||
<td>{{ id }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@ -105,36 +95,37 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
||||
{% block extrascripts %}
|
||||
<script>
|
||||
<script>
|
||||
// superglobals
|
||||
window.records_allow_edit = {{ editable_records | tojson }};
|
||||
window.ttl_options = {{ ttl_options | tojson }};
|
||||
window.nEditing = null;
|
||||
window.nNew = false;
|
||||
|
||||
// set up user data table
|
||||
// Initialize DataTables
|
||||
$("#tbl_records").DataTable({
|
||||
"paging" : true,
|
||||
"lengthChange" : true,
|
||||
"searching" : true,
|
||||
"ordering" : true,
|
||||
"info" : true,
|
||||
"autoWidth" : false,
|
||||
"paging": true,
|
||||
"lengthChange": true,
|
||||
"searching": true,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
{% if SETTING.get('default_record_table_size')|string in ['5','15','20'] %}
|
||||
"lengthMenu": [ [5, 15, 20, -1],
|
||||
"lengthMenu": [[5, 15, 20, -1],
|
||||
[5, 15, 20, "All"]],
|
||||
{% else %}
|
||||
"lengthMenu": [ [5, 15, 20, {{ SETTING.get('default_record_table_size') }}, -1],
|
||||
"lengthMenu": [[5, 15, 20, {{ SETTING.get('default_record_table_size') }}, -1],
|
||||
[5, 15, 20, {{ SETTING.get('default_record_table_size') }}, "All"]],
|
||||
{% endif %}
|
||||
"pageLength": {{ SETTING.get('default_record_table_size') }},
|
||||
"language": {
|
||||
"lengthMenu": " _MENU_ records"
|
||||
},
|
||||
"retrieve" : true,
|
||||
"retrieve": true,
|
||||
"columnDefs": [
|
||||
{
|
||||
type: 'natural',
|
||||
@ -144,18 +135,18 @@
|
||||
// hidden column so that we can add new records on top
|
||||
// regardless of whatever sorting is done. See orderFixed
|
||||
visible: false,
|
||||
targets: [ 8 ]
|
||||
targets: [7]
|
||||
},
|
||||
{
|
||||
className: "length-break",
|
||||
targets: [ 4, 5 ]
|
||||
targets: [4, 5]
|
||||
}
|
||||
],
|
||||
"orderFixed": [[8, 'asc']]
|
||||
"orderFixed": [[7, 'asc']]
|
||||
});
|
||||
|
||||
// handle delete button
|
||||
$(document.body).on("click", ".button_delete", function(e) {
|
||||
$(document.body).on("click", ".button_delete", function (e) {
|
||||
e.stopPropagation();
|
||||
var modal = $("#modal_delete");
|
||||
var table = $("#tbl_records").DataTable();
|
||||
@ -165,17 +156,18 @@
|
||||
modal.find('.modal-body p').text(info);
|
||||
modal.modal('show');
|
||||
|
||||
$("#button_delete_confirm").unbind().one('click', function(e) {
|
||||
$("#button_delete_confirm").unbind().one('click', function (e) {
|
||||
table.row(nRow).remove().draw();
|
||||
modal.modal('hide');
|
||||
});
|
||||
|
||||
$("#button_delete_cancel").unbind().one('click', function(e) {
|
||||
$("#button_delete_cancel").unbind().one('click', function (e) {
|
||||
modal.modal('hide');
|
||||
});
|
||||
});
|
||||
|
||||
// handle edit button and record click
|
||||
$(document.body).on("click", ".button_edit{% if quick_edit %}, .row_record{% endif %}", function(e) {
|
||||
$(document.body).on("click", ".button_edit{% if quick_edit %}, .row_record{% endif %}", function (e) {
|
||||
e.stopPropagation();
|
||||
if ($(this).is('tr')) {
|
||||
var nRow = $(this)[0];
|
||||
@ -205,7 +197,7 @@
|
||||
});
|
||||
|
||||
// handle apply changes button
|
||||
$(document.body).on("click",".button_apply_changes", function() {
|
||||
$(document.body).on("click", ".button_apply_changes", function () {
|
||||
if (nNew || nEditing) {
|
||||
showErrorModal("Previous record not saved. Please save it before applying the changes.");
|
||||
return;
|
||||
@ -218,9 +210,12 @@
|
||||
modal.find('.modal-body p').text(info);
|
||||
|
||||
// following unbind("click") is to avoid multiple times execution
|
||||
modal.find('#button_apply_confirm').unbind("click").click(function() {
|
||||
modal.find('#button_apply_confirm').unbind("click").click(function () {
|
||||
var data = getTableData(table);
|
||||
applyChanges( {'_csrf_token': '{{ csrf_token() }}', 'records': data}, $SCRIPT_ROOT + '/admin/template/' + template + '/apply', true);
|
||||
applyChanges({
|
||||
'_csrf_token': '{{ csrf_token() }}',
|
||||
'records': data
|
||||
}, $SCRIPT_ROOT + '/admin/template/' + template + '/apply', true);
|
||||
modal.modal('hide');
|
||||
})
|
||||
modal.modal('show');
|
||||
@ -294,7 +289,7 @@
|
||||
";
|
||||
}
|
||||
modal.find('.modal-body p').html(form);
|
||||
modal.find('#button_save').click(function() {
|
||||
modal.find('#button_save').click(function () {
|
||||
caa_flag = modal.find('#caa_flag').val();
|
||||
caa_tag = modal.find('#caa_tag').val();
|
||||
caa_value = modal.find('#caa_value').val();
|
||||
@ -320,7 +315,7 @@
|
||||
";
|
||||
}
|
||||
modal.find('.modal-body p').html(form);
|
||||
modal.find('#button_save').click(function() {
|
||||
modal.find('#button_save').click(function () {
|
||||
mx_server = modal.find('#mx_server').val();
|
||||
mx_priority = modal.find('#mx_priority').val();
|
||||
data = mx_priority + " " + mx_server;
|
||||
@ -356,7 +351,7 @@
|
||||
";
|
||||
}
|
||||
modal.find('.modal-body p').html(form);
|
||||
modal.find('#button_save').click(function() {
|
||||
modal.find('#button_save').click(function () {
|
||||
srv_priority = modal.find('#srv_priority').val();
|
||||
srv_weight = modal.find('#srv_weight').val();
|
||||
srv_port = modal.find('#srv_port').val();
|
||||
@ -406,7 +401,7 @@
|
||||
";
|
||||
}
|
||||
modal.find('.modal-body p').html(form);
|
||||
modal.find('#button_save').click(function() {
|
||||
modal.find('#button_save').click(function () {
|
||||
soa_primaryns = modal.find('#soa_primaryns').val();
|
||||
soa_adminemail = modal.find('#soa_adminemail').val();
|
||||
soa_serial = modal.find('#soa_serial').val();
|
||||
@ -423,10 +418,11 @@
|
||||
}
|
||||
});
|
||||
{% endif %}
|
||||
</script>
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block modals %}
|
||||
<div class="modal fade modal-warning" id="modal_delete">
|
||||
<div class="modal fade modal-warning" id="modal_delete">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@ -440,7 +436,8 @@
|
||||
<p></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary float-left" id="button_delete_cancel" data-dismiss="modal">
|
||||
<button type="button" class="btn btn-secondary float-left" id="button_delete_cancel"
|
||||
data-dismiss="modal">
|
||||
Close
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger" id="button_delete_confirm">
|
||||
@ -449,8 +446,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade modal-primary" id="modal_apply_changes">
|
||||
</div>
|
||||
<div class="modal fade modal-primary" id="modal_apply_changes">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@ -473,8 +470,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade modal-primary" id="modal_custom_record">
|
||||
</div>
|
||||
<div class="modal fade modal-primary" id="modal_custom_record">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@ -492,5 +489,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
Loading…
Reference in New Issue
Block a user