Domain update improvements, dnssec records can be deleted now

This commit is contained in:
Pinga 2023-12-15 08:21:11 +02:00
parent be28985948
commit 9a45cdab9e
4 changed files with 121 additions and 13 deletions

View file

@ -126,22 +126,55 @@
<label for="authInfo" class="form-label">{{ __('DNSSEC Data') }}</label>
<div class="table-responsive">
<table class="table table-vcenter card-table table-striped">
{% for row in domainSecdns %}
<tr>
{% for key, value in row %}
{% if key not in ['id', 'domain_id', 'maxsiglife'] %}
<th>{{ key }}</th>
<thead>
<tr>
{% set dsDataExists = false %}
{% set keyDataExists = false %}
{% for row in domainSecdns %}
{% if row.interface == 'dsData' %}
{% set dsDataExists = true %}
{% elseif row.interface == 'keyData' %}
{% set keyDataExists = true %}
{% endif %}
{% endfor %}
<!-- Headers for dsData -->
{% if dsDataExists %}
<th>Keytag</th>
<th>Algorithm</th>
<th>Digest Type</th>
<th>Digest</th>
{% endif %}
{% endfor %}
</tr>
<tr>
{% for key, value in row %}
{% if key not in ['id', 'domain_id', 'maxsiglife'] %}
<td>{{ value }}</td>
<!-- Headers for keyData -->
{% if keyDataExists %}
<th>Flags</th>
<th>Protocol</th>
<th>Keydata Algorithm</th>
<th>Public Key</th>
{% endif %}
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{% for row in domainSecdns %}
<tr>
{% if row.interface == 'dsData' %}
<td>{{ row.keytag }}</td>
<td>{{ row.alg }}</td>
<td>{{ row.digesttype }}</td>
<td>{{ row.digest }}</td>
{% elseif row.interface == 'keyData' %}
<td>{{ row.flags }}</td>
<td>{{ row.protocol }}</td>
<td>{{ row.keydata_alg }}</td>
<td>{{ row.pubkey }}</td>
{% endif %}
<td><button type="button" class="btn btn-dark btn-icon" onclick="sendSecRequest('{{ row.id }}','{{ row.domain_id }}')" title="Delete record"><svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M10 10l4 4m0 -4l-4 4" /><path d="M12 3c7.2 0 9 1.8 9 9s-1.8 9 -9 9s-9 -1.8 -9 -9s1.8 -9 9 -9z" /></svg></button></td>
</tr>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
@ -253,6 +286,29 @@ function sendRequest(nameserver) {
xhr.send(formData);
}
function sendSecRequest(record,domain_id) {
var formData = new FormData();
formData.append('record', record);
formData.append('domain_id', domain_id);
var xhr = new XMLHttpRequest();
xhr.open('POST', '/domain/deletesecdns');
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
var response = JSON.parse(xhr.responseText);
if (xhr.status == 200 && response.success) {
// Redirect to the provided URL
window.location.href = response.redirect;
} else {
// Handle error
console.error('Error: ' + response.error);
alert('Error: ' + response.error); // Display error message to the user
}
}
};
xhr.send(formData);
}
document.addEventListener("DOMContentLoaded", function() {
const addNameserverBtn = document.getElementById('addNameserver');