mirror of
https://github.com/getnamingo/registry.git
synced 2025-05-10 16:58:34 +02:00
Updates on applications
This commit is contained in:
parent
1707453f70
commit
b0885e7dd1
2 changed files with 274 additions and 285 deletions
|
@ -688,10 +688,10 @@ class ApplicationsController extends Controller
|
||||||
|
|
||||||
if (!preg_match('/^([a-z0-9]([-a-z0-9]*[a-z0-9])?\.)*[a-z0-9]([-a-z0-9]*[a-z0-9])?$/', $args)) {
|
if (!preg_match('/^([a-z0-9]([-a-z0-9]*[a-z0-9])?\.)*[a-z0-9]([-a-z0-9]*[a-z0-9])?$/', $args)) {
|
||||||
$this->container->get('flash')->addMessage('error', 'Invalid domain name format');
|
$this->container->get('flash')->addMessage('error', 'Invalid domain name format');
|
||||||
return $response->withHeader('Location', '/domains')->withStatus(302);
|
return $response->withHeader('Location', '/applications')->withStatus(302);
|
||||||
}
|
}
|
||||||
|
|
||||||
$domain = $db->selectRow('SELECT id, name, registrant, crdate, exdate, lastupdate, clid, idnlang, rgpstatus FROM domain WHERE name = ?',
|
$domain = $db->selectRow('SELECT id, name, registrant, crdate, phase_name, phase_type, clid, idnlang, rgpstatus FROM application WHERE name = ?',
|
||||||
[ $args ]);
|
[ $args ]);
|
||||||
|
|
||||||
if ($domain) {
|
if ($domain) {
|
||||||
|
@ -706,8 +706,8 @@ class ApplicationsController extends Controller
|
||||||
|
|
||||||
// Check if the registrar's ID is in the user's list of registrar IDs
|
// Check if the registrar's ID is in the user's list of registrar IDs
|
||||||
if (!in_array($registrars['id'], $userRegistrarIds)) {
|
if (!in_array($registrars['id'], $userRegistrarIds)) {
|
||||||
// Redirect to the domains view if the user is not authorized for this contact
|
// Redirect to the applications view if the user is not authorized for this contact
|
||||||
return $response->withHeader('Location', '/domains')->withStatus(302);
|
return $response->withHeader('Location', '/applications')->withStatus(302);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,10 +715,6 @@ class ApplicationsController extends Controller
|
||||||
[ $domain['registrant'] ]);
|
[ $domain['registrant'] ]);
|
||||||
$domainStatus = $db->select('SELECT status FROM application_status WHERE domain_id = ?',
|
$domainStatus = $db->select('SELECT status FROM application_status WHERE domain_id = ?',
|
||||||
[ $domain['id'] ]);
|
[ $domain['id'] ]);
|
||||||
$domainAuth = $db->selectRow('SELECT authinfo FROM domain_authInfo WHERE domain_id = ?',
|
|
||||||
[ $domain['id'] ]);
|
|
||||||
$domainSecdns = $db->select('SELECT * FROM secdns WHERE domain_id = ?',
|
|
||||||
[ $domain['id'] ]);
|
|
||||||
$domainHostsQuery = '
|
$domainHostsQuery = '
|
||||||
SELECT dhm.id, dhm.domain_id, dhm.host_id, h.name
|
SELECT dhm.id, dhm.domain_id, dhm.host_id, h.name
|
||||||
FROM application_host_map dhm
|
FROM application_host_map dhm
|
||||||
|
@ -736,13 +732,10 @@ class ApplicationsController extends Controller
|
||||||
$csrfTokenName = $this->container->get('csrf')->getTokenName();
|
$csrfTokenName = $this->container->get('csrf')->getTokenName();
|
||||||
$csrfTokenValue = $this->container->get('csrf')->getTokenValue();
|
$csrfTokenValue = $this->container->get('csrf')->getTokenValue();
|
||||||
|
|
||||||
|
return view($response,'admin/domains/updateApplication.twig', [
|
||||||
return view($response,'admin/domains/updateDomain.twig', [
|
|
||||||
'domain' => $domain,
|
'domain' => $domain,
|
||||||
'domainStatus' => $domainStatus,
|
'domainStatus' => $domainStatus,
|
||||||
'domainAuth' => $domainAuth,
|
|
||||||
'domainRegistrant' => $domainRegistrant,
|
'domainRegistrant' => $domainRegistrant,
|
||||||
'domainSecdns' => $domainSecdns,
|
|
||||||
'domainHosts' => $domainHosts,
|
'domainHosts' => $domainHosts,
|
||||||
'domainContacts' => $domainContacts,
|
'domainContacts' => $domainContacts,
|
||||||
'registrar' => $registrars,
|
'registrar' => $registrars,
|
||||||
|
@ -751,13 +744,13 @@ class ApplicationsController extends Controller
|
||||||
'csrfTokenValue' => $csrfTokenValue
|
'csrfTokenValue' => $csrfTokenValue
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
// Domain does not exist, redirect to the domains view
|
// Domain does not exist, redirect to the applications view
|
||||||
return $response->withHeader('Location', '/domains')->withStatus(302);
|
return $response->withHeader('Location', '/applications')->withStatus(302);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Redirect to the domains view
|
// Redirect to the applications view
|
||||||
return $response->withHeader('Location', '/domains')->withStatus(302);
|
return $response->withHeader('Location', '/applications')->withStatus(302);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1249,33 +1242,14 @@ class ApplicationsController extends Controller
|
||||||
|
|
||||||
if (!preg_match('/^([a-z0-9]([-a-z0-9]*[a-z0-9])?\.)*[a-z0-9]([-a-z0-9]*[a-z0-9])?$/', $args)) {
|
if (!preg_match('/^([a-z0-9]([-a-z0-9]*[a-z0-9])?\.)*[a-z0-9]([-a-z0-9]*[a-z0-9])?$/', $args)) {
|
||||||
$this->container->get('flash')->addMessage('error', 'Invalid domain name format');
|
$this->container->get('flash')->addMessage('error', 'Invalid domain name format');
|
||||||
return $response->withHeader('Location', '/domains')->withStatus(302);
|
return $response->withHeader('Location', '/applications')->withStatus(302);
|
||||||
}
|
}
|
||||||
|
|
||||||
$domain = $db->selectRow('SELECT id, name, tldid, registrant, crdate, exdate, clid, crid, upid, trdate, trstatus, reid, redate, acid, acdate, rgpstatus, addPeriod, autoRenewPeriod, renewPeriod, renewedDate, transferPeriod FROM domain WHERE name = ?',
|
$domain = $db->selectRow('SELECT id, name FROM application WHERE name = ?',
|
||||||
[ $args ]);
|
[ $args ]);
|
||||||
|
|
||||||
$domainName = $domain['name'];
|
$domainName = $domain['name'];
|
||||||
$domain_id = $domain['id'];
|
$domain_id = $domain['id'];
|
||||||
$tldid = $domain['tldid'];
|
|
||||||
$registrant = $domain['registrant'];
|
|
||||||
$crdate = $domain['crdate'];
|
|
||||||
$exdate = $domain['exdate'];
|
|
||||||
$registrar_id_domain = $domain['clid'];
|
|
||||||
$crid = $domain['crid'];
|
|
||||||
$upid = $domain['upid'];
|
|
||||||
$trdate = $domain['trdate'];
|
|
||||||
$trstatus = $domain['trstatus'];
|
|
||||||
$reid = $domain['reid'];
|
|
||||||
$redate = $domain['redate'];
|
|
||||||
$acid = $domain['acid'];
|
|
||||||
$acdate = $domain['acdate'];
|
|
||||||
$rgpstatus = $domain['rgpstatus'];
|
|
||||||
$addPeriod = $domain['addPeriod'];
|
|
||||||
$autoRenewPeriod = $domain['autoRenewPeriod'];
|
|
||||||
$renewPeriod = $domain['renewPeriod'];
|
|
||||||
$renewedDate = $domain['renewedDate'];
|
|
||||||
$transferPeriod = $domain['transferPeriod'];
|
|
||||||
|
|
||||||
$parts = extractDomainAndTLD($domainName);
|
$parts = extractDomainAndTLD($domainName);
|
||||||
$label = $parts['domain'];
|
$label = $parts['domain'];
|
||||||
|
@ -1297,72 +1271,9 @@ class ApplicationsController extends Controller
|
||||||
$clid = $registrar_id_domain;
|
$clid = $registrar_id_domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = $db->select(
|
|
||||||
'SELECT status FROM application_status WHERE domain_id = ?',
|
|
||||||
[ $domain_id ]
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($results as $row) {
|
|
||||||
$status = $row['status'];
|
|
||||||
if (preg_match('/.*(UpdateProhibited|DeleteProhibited)$/', $status) || preg_match('/^pending/', $status)) {
|
|
||||||
$this->container->get('flash')->addMessage('error', 'It has a status that does not allow deletion, first change the status');
|
|
||||||
return $response->withHeader('Location', '/domains')->withStatus(302);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$grace_period = 30;
|
|
||||||
|
|
||||||
$db->delete(
|
|
||||||
'application_status',
|
|
||||||
[
|
|
||||||
'domain_id' => $domain_id
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
$db->exec(
|
|
||||||
'UPDATE domain SET rgpstatus = ?, delTime = DATE_ADD(CURRENT_TIMESTAMP(3), INTERVAL ? DAY) WHERE id = ?',
|
|
||||||
['redemptionPeriod', $grace_period, $domain_id]
|
|
||||||
);
|
|
||||||
|
|
||||||
$db->insert(
|
|
||||||
'application_status',
|
|
||||||
[
|
|
||||||
'domain_id' => $domain_id,
|
|
||||||
'status' => 'pendingDelete'
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($rgpstatus) {
|
|
||||||
if ($rgpstatus === 'addPeriod') {
|
|
||||||
$addPeriod_id = $db->selectValue(
|
|
||||||
'SELECT id FROM domain WHERE id = ? AND (CURRENT_TIMESTAMP(3) < DATE_ADD(crdate, INTERVAL 5 DAY)) LIMIT 1',
|
|
||||||
[
|
|
||||||
$domain_id
|
|
||||||
]
|
|
||||||
);
|
|
||||||
if ($addPeriod_id) {
|
|
||||||
$returnValue = getDomainPrice($db, $domainName, $tld_id, $addPeriod, 'create');
|
|
||||||
$price = $returnValue['price'];
|
|
||||||
|
|
||||||
if (!$price) {
|
|
||||||
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
|
||||||
return $response->withHeader('Location', '/domains')->withStatus(302);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$db->beginTransaction();
|
$db->beginTransaction();
|
||||||
|
|
||||||
$db->exec(
|
|
||||||
'UPDATE registrar SET accountBalance = accountBalance + ? WHERE id = ?',
|
|
||||||
[$price, $clid]
|
|
||||||
);
|
|
||||||
|
|
||||||
$description = "domain name is deleted by the registrar during grace addPeriod, the registry provides a credit for the cost of the registration domain $domainName for period $addPeriod MONTH";
|
|
||||||
$db->exec(
|
|
||||||
'INSERT INTO payment_history (registrar_id, date, description, amount) VALUES(?, CURRENT_TIMESTAMP(3), ?, ?)',
|
|
||||||
[$clid, $description, $price]
|
|
||||||
);
|
|
||||||
|
|
||||||
$hostIds = $db->select(
|
$hostIds = $db->select(
|
||||||
'SELECT id FROM host WHERE domain_id = ?',
|
'SELECT id FROM host WHERE domain_id = ?',
|
||||||
[$domain_id]
|
[$domain_id]
|
||||||
|
@ -1405,12 +1316,6 @@ class ApplicationsController extends Controller
|
||||||
'domain_id' => $domain_id
|
'domain_id' => $domain_id
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$db->delete(
|
|
||||||
'domain_authInfo',
|
|
||||||
[
|
|
||||||
'domain_id' => $domain_id
|
|
||||||
]
|
|
||||||
);
|
|
||||||
$db->delete(
|
$db->delete(
|
||||||
'application_status',
|
'application_status',
|
||||||
[
|
[
|
||||||
|
@ -1423,12 +1328,6 @@ class ApplicationsController extends Controller
|
||||||
'domain_id' => $domain_id
|
'domain_id' => $domain_id
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$db->delete(
|
|
||||||
'secdns',
|
|
||||||
[
|
|
||||||
'domain_id' => $domain_id
|
|
||||||
]
|
|
||||||
);
|
|
||||||
$db->delete(
|
$db->delete(
|
||||||
'domain',
|
'domain',
|
||||||
[
|
[
|
||||||
|
@ -1436,121 +1335,18 @@ class ApplicationsController extends Controller
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$curdate_id = $db->selectValue(
|
|
||||||
'SELECT id FROM statistics WHERE date = CURDATE()'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!$curdate_id) {
|
|
||||||
$db->exec(
|
|
||||||
'INSERT IGNORE INTO statistics (date) VALUES(CURDATE())'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->exec(
|
|
||||||
'UPDATE statistics SET deleted_domains = deleted_domains + 1 WHERE date = CURDATE()'
|
|
||||||
);
|
|
||||||
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$db->rollBack();
|
$db->rollBack();
|
||||||
$this->container->get('flash')->addMessage('error', 'Database failure: ' . $e->getMessage());
|
$this->container->get('flash')->addMessage('error', 'Database failure: ' . $e->getMessage());
|
||||||
return $response->withHeader('Location', '/domain/renew/'.$domainName)->withStatus(302);
|
return $response->withHeader('Location', '/applications')->withStatus(302);
|
||||||
}
|
|
||||||
$isImmediateDeletion = true;
|
|
||||||
}
|
|
||||||
} elseif ($rgpstatus === 'autoRenewPeriod') {
|
|
||||||
$autoRenewPeriod_id = $db->selectValue(
|
|
||||||
'SELECT id FROM domain WHERE id = ? AND (CURRENT_TIMESTAMP(3) < DATE_ADD(renewedDate, INTERVAL 45 DAY)) LIMIT 1',
|
|
||||||
[
|
|
||||||
$domain_id
|
|
||||||
]
|
|
||||||
);
|
|
||||||
if ($autoRenewPeriod_id) {
|
|
||||||
$returnValue = getDomainPrice($db, $domainName, $tld_id, $autoRenewPeriod, 'renew');
|
|
||||||
$price = $returnValue['price'];
|
|
||||||
|
|
||||||
if (!$price) {
|
|
||||||
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
|
||||||
return $response->withHeader('Location', '/domains')->withStatus(302);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->exec(
|
|
||||||
'UPDATE registrar SET accountBalance = accountBalance + ? WHERE id = ?',
|
|
||||||
[$price, $clid]
|
|
||||||
);
|
|
||||||
|
|
||||||
$description = "domain name is deleted by the registrar during grace autoRenewPeriod, the registry provides a credit for the cost of the renewal domain $domainName for period $autoRenewPeriod MONTH";
|
|
||||||
$db->exec(
|
|
||||||
'INSERT INTO payment_history (registrar_id, date, description, amount) VALUES(?, CURRENT_TIMESTAMP(3), ?, ?)',
|
|
||||||
[$clid, $description, $price]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} elseif ($rgpstatus === 'renewPeriod') {
|
|
||||||
$renewPeriod_id = $db->selectValue(
|
|
||||||
'SELECT id FROM domain WHERE id = ? AND (CURRENT_TIMESTAMP(3) < DATE_ADD(renewedDate, INTERVAL 5 DAY)) LIMIT 1',
|
|
||||||
[
|
|
||||||
$domain_id
|
|
||||||
]
|
|
||||||
);
|
|
||||||
if ($renewPeriod_id) {
|
|
||||||
$returnValue = getDomainPrice($db, $domainName, $tld_id, $renewPeriod, 'renew');
|
|
||||||
$price = $returnValue['price'];
|
|
||||||
|
|
||||||
if (!$price) {
|
|
||||||
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
|
||||||
return $response->withHeader('Location', '/domains')->withStatus(302);
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->exec(
|
|
||||||
'UPDATE registrar SET accountBalance = accountBalance + ? WHERE id = ?',
|
|
||||||
[$price, $clid]
|
|
||||||
);
|
|
||||||
|
|
||||||
$description = "domain name is deleted by the registrar during grace renewPeriod, the registry provides a credit for the cost of the renewal domain $domainName for period $renewPeriod MONTH";
|
|
||||||
$db->exec(
|
|
||||||
'INSERT INTO payment_history (registrar_id, date, description, amount) VALUES(?, CURRENT_TIMESTAMP(3), ?, ?)',
|
|
||||||
[$clid, $description, $price]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} elseif ($rgpstatus === 'transferPeriod') {
|
|
||||||
$transferPeriod_id = $db->selectValue(
|
|
||||||
'SELECT id FROM domain WHERE id = ? AND (CURRENT_TIMESTAMP(3) < DATE_ADD(trdate, INTERVAL 5 DAY)) LIMIT 1',
|
|
||||||
[
|
|
||||||
$domain_id
|
|
||||||
]
|
|
||||||
);
|
|
||||||
if ($transferPeriod_id) {
|
|
||||||
$returnValue = getDomainPrice($db, $domainName, $tld_id, $transferPeriod, 'renew');
|
|
||||||
$price = $returnValue['price'];
|
|
||||||
|
|
||||||
if (!$price) {
|
|
||||||
$this->container->get('flash')->addMessage('error', 'The price, period and currency for such TLD are not declared');
|
|
||||||
return $response->withHeader('Location', '/domains')->withStatus(302);
|
|
||||||
}
|
|
||||||
|
|
||||||
$db->exec(
|
|
||||||
'UPDATE registrar SET accountBalance = accountBalance + ? WHERE id = ?',
|
|
||||||
[$price, $clid]
|
|
||||||
);
|
|
||||||
|
|
||||||
$description = "domain name is deleted by the registrar during grace transferPeriod, the registry provides a credit for the cost of the transfer domain $domainName for period $transferPeriod MONTH";
|
|
||||||
$db->exec(
|
|
||||||
'INSERT INTO payment_history (registrar_id, date, description, amount) VALUES(?, CURRENT_TIMESTAMP(3), ?, ?)',
|
|
||||||
[$clid, $description, $price]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($isImmediateDeletion) {
|
|
||||||
$this->container->get('flash')->addMessage('success', 'Domain ' . $domainName . ' deleted successfully');
|
$this->container->get('flash')->addMessage('success', 'Domain ' . $domainName . ' deleted successfully');
|
||||||
|
return $response->withHeader('Location', '/applications')->withStatus(302);
|
||||||
} else {
|
} else {
|
||||||
$this->container->get('flash')->addMessage('info', 'Deletion process for domain ' . $domainName . ' has been initiated');
|
// Redirect to the applications view
|
||||||
}
|
return $response->withHeader('Location', '/applications')->withStatus(302);
|
||||||
return $response->withHeader('Location', '/domains')->withStatus(302);
|
|
||||||
} else {
|
|
||||||
// Redirect to the domains view
|
|
||||||
return $response->withHeader('Location', '/domains')->withStatus(302);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
193
cp/resources/views/admin/domains/updateApplication.twig
Normal file
193
cp/resources/views/admin/domains/updateApplication.twig
Normal file
|
@ -0,0 +1,193 @@
|
||||||
|
{% extends "layouts/app.twig" %}
|
||||||
|
|
||||||
|
{% block title %}{{ __('Updating Application') }} {{ domain.name }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="page-wrapper">
|
||||||
|
<!-- Page header -->
|
||||||
|
<div class="page-header d-print-none">
|
||||||
|
<div class="container-xl">
|
||||||
|
<div class="row g-2 align-items-center">
|
||||||
|
<div class="col">
|
||||||
|
<!-- Page pre-title -->
|
||||||
|
<div class="page-pretitle">
|
||||||
|
{{ __('Overview') }}
|
||||||
|
</div>
|
||||||
|
<h2 class="page-title">
|
||||||
|
{{ __('Updating Application') }} {{ domain.name }}
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Page body -->
|
||||||
|
<div class="page-body">
|
||||||
|
<div class="container-xl">
|
||||||
|
<form id="domainUpdateForm" action="/application/update" method="post">
|
||||||
|
{{ csrf.field | raw }}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
{% include 'partials/flash.twig' %}
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-header">
|
||||||
|
<h3 class="card-title">
|
||||||
|
Domain {{ domain.name }} <input type="hidden" name="domainName" value="{{ domain.name }}">
|
||||||
|
{% if domainStatus.status or domain.rgpstatus %}
|
||||||
|
{% if domainStatus is iterable %}
|
||||||
|
{% for status in domainStatus %}
|
||||||
|
<span class="status status-green" title="Status">{{ status.status }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
{% if domainStatus.status %}
|
||||||
|
<span class="status status-green" title="Status">{{ domainStatus.status }}</span>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if domain.rgpstatus %}
|
||||||
|
<span class="status status-info" title="Status">{{ domain.rgpstatus }}</span>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<span class="status status-info" title="Status">ok</span>
|
||||||
|
{% endif %}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="datagrid">
|
||||||
|
<div class="datagrid-item">
|
||||||
|
<div class="datagrid-title">Created On</div>
|
||||||
|
<div class="datagrid-content">{{ domain.crdate }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="datagrid-item">
|
||||||
|
<div class="datagrid-title">Launch Phase</div>
|
||||||
|
<div class="datagrid-content">{{ domain.phase_type }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="datagrid-item">
|
||||||
|
<div class="datagrid-title">Expiration Date</div>
|
||||||
|
<div class="datagrid-content">{{ domain.exdate }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="datagrid-item">
|
||||||
|
<div class="datagrid-title">Registrar</div>
|
||||||
|
<div class="datagrid-content">{{ registrar.name }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer">
|
||||||
|
<div class="row align-items-center">
|
||||||
|
<div class="col-auto">
|
||||||
|
<button type="submit" class="btn btn-primary">{{ __('Update Application') }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div id="nameserverFields">
|
||||||
|
<label class="form-label">{{ __('Nameservers') }} <button type="button" id="addNameserver" class="btn btn-success btn-sm mb-2">+</button> <button type="button" id="removeNameserver" class="btn btn-danger btn-sm mb-2">-</button></label>
|
||||||
|
{% for host in domainHosts %}
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<footer class="footer footer-transparent d-print-none">
|
||||||
|
<div class="container-xl">
|
||||||
|
<div class="col-12 col-lg-auto mt-3 mt-lg-0">
|
||||||
|
<ul class="list-inline list-inline-dots mb-0">
|
||||||
|
<li class="list-inline-item">
|
||||||
|
Copyright © 2023
|
||||||
|
<a href="https://namingo.org" target="_blank" class="link-secondary">Namingo</a>.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
var csrfTokenName = "{{ csrfTokenName }}";
|
||||||
|
var csrfTokenValue = "{{ csrfTokenValue }}";
|
||||||
|
|
||||||
|
function sendRequest(nameserver) {
|
||||||
|
var formData = new FormData();
|
||||||
|
formData.append('nameserver', nameserver);
|
||||||
|
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('POST', '/domain/deletehost');
|
||||||
|
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');
|
||||||
|
const removeNameserverBtn = document.getElementById('removeNameserver');
|
||||||
|
const nameserverFields = document.getElementById('nameserverFields');
|
||||||
|
|
||||||
|
function createNameserverGroup(count) {
|
||||||
|
const group = document.createElement('div');
|
||||||
|
group.className = 'nameserver-group mb-1 row';
|
||||||
|
|
||||||
|
const nameserverCol = document.createElement('div');
|
||||||
|
nameserverCol.className = 'col-md-12';
|
||||||
|
const nameserverField = document.createElement('input');
|
||||||
|
nameserverField.type = 'text';
|
||||||
|
nameserverField.className = 'form-control mb-1';
|
||||||
|
nameserverField.placeholder = `{{ __('Nameserver') }} ${count}`;
|
||||||
|
nameserverField.name = `nameserver[]`;
|
||||||
|
nameserverCol.appendChild(nameserverField);
|
||||||
|
|
||||||
|
group.appendChild(nameserverCol);
|
||||||
|
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add nameserver fields
|
||||||
|
let nameserverCount = {{ domainHosts|length }}; // Initialize count based on the number of domain hosts
|
||||||
|
|
||||||
|
addNameserverBtn.addEventListener('click', function() {
|
||||||
|
if (nameserverCount < 13) {
|
||||||
|
nameserverCount++;
|
||||||
|
const nameserverGroup = createNameserverGroup(nameserverCount);
|
||||||
|
nameserverFields.appendChild(nameserverGroup);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove nameserver group
|
||||||
|
removeNameserverBtn.addEventListener('click', function() {
|
||||||
|
if (nameserverCount > {{ domainHosts|length }}) {
|
||||||
|
const lastGroup = nameserverFields.querySelector('.nameserver-group:last-child');
|
||||||
|
if (lastGroup) {
|
||||||
|
nameserverFields.removeChild(lastGroup);
|
||||||
|
nameserverCount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
Loading…
Add table
Reference in a new issue