Fixed issue when removing hosts in CP

This commit is contained in:
Pinga 2024-11-18 15:01:17 +02:00
parent 2d5efcd9ae
commit 8719fe9571
4 changed files with 8 additions and 8 deletions

View file

@ -977,8 +977,7 @@ class ApplicationsController extends Controller
if ($data['nameserver']) {
$host_id = $db->selectValue('SELECT id FROM host WHERE name = ?',
[ $data['nameserver'] ]);
$domain_id = $db->selectValue('SELECT domain_id FROM application_host_map WHERE host_id = ?',
[ $host_id ]);
$domain_id = $data['domain_id'];
$domainName = $db->selectValue('SELECT name FROM application WHERE id = ?',
[ $domain_id ]);
$db->delete(

View file

@ -1624,8 +1624,7 @@ class DomainsController extends Controller
if ($data['nameserver']) {
$host_id = $db->selectValue('SELECT id FROM host WHERE name = ?',
[ $data['nameserver'] ]);
$domain_id = $db->selectValue('SELECT domain_id FROM domain_host_map WHERE host_id = ?',
[ $host_id ]);
$domain_id = $data['domain_id'];
$domainName = $db->selectValue('SELECT name FROM domain WHERE id = ?',
[ $domain_id ]);
$db->delete(

View file

@ -91,7 +91,7 @@
<div class="nameserver-group mb-1 row">
<div class="input-group mb-1">
<input type="text" class="form-control" placeholder="{{ __('Nameserver') }} {{ loop.index }}" value="{{ host.name }}" autocapitalize="none" disabled>
<button type="button" class="btn btn-secondary btn-icon" onclick="sendRequest('{{ host.name }}')" title="Delete nameserver"><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>
<button type="button" class="btn btn-secondary btn-icon" onclick="sendRequest('{{ host.name }}','{{ domain.id }}')" title="Delete nameserver"><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>
</div>
</div>
{% endfor %}
@ -109,9 +109,10 @@
var csrfTokenName = "{{ csrfTokenName }}";
var csrfTokenValue = "{{ csrfTokenValue }}";
function sendRequest(nameserver) {
function sendRequest(nameserver,domain_id) {
var formData = new FormData();
formData.append('nameserver', nameserver);
formData.append('domain_id', domain_id);
var xhr = new XMLHttpRequest();
xhr.open('POST', '/application/deletehost');

View file

@ -123,7 +123,7 @@
<div class="nameserver-group mb-1 row">
<div class="input-group mb-1">
<input type="text" class="form-control" placeholder="{{ __('Nameserver') }} {{ loop.index }}" value="{{ host.name }}" autocapitalize="none" disabled>
<button type="button" class="btn btn-secondary btn-icon" onclick="sendRequest('{{ host.name }}')" title="Delete nameserver"><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>
<button type="button" class="btn btn-secondary btn-icon" onclick="sendRequest('{{ host.name }}','{{ domain.id }}')" title="Delete nameserver"><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>
</div>
</div>
{% endfor %}
@ -305,9 +305,10 @@
var csrfTokenName = "{{ csrfTokenName }}";
var csrfTokenValue = "{{ csrfTokenValue }}";
function sendRequest(nameserver) {
function sendRequest(nameserver,domain_id) {
var formData = new FormData();
formData.append('nameserver', nameserver);
formData.append('domain_id', domain_id);
var xhr = new XMLHttpRequest();
xhr.open('POST', '/domain/deletehost');