dynamically load dns-record help-text for selected dns-type; fixes #719

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-05-15 11:45:50 +02:00
parent ed7faae947
commit dd896659ae
6 changed files with 55 additions and 4 deletions

View File

@@ -83,6 +83,8 @@ class Ajax
return $this->getConfigDetails();
case 'getConfigJsonExport':
return $this->getConfigJsonExport();
case 'loadLanguageString':
return $this->loadLanguageString();
default:
return $this->errorResponse('Action not found!');
}
@@ -344,4 +346,16 @@ class Ajax
}
return $this->errorResponse('Not allowed', 403);
}
/**
* loads a given language string by its identifier
*/
private function loadLanguageString()
{
$langid = isset($_POST['langid']) ? $_POST['langid'] : "";
if (preg_match('/^([a-zA-Z\.]+)$/', $langid)) {
return $this->jsonResponse(lng($langid));
}
return $this->errorResponse('Invalid identifier: ' . $langid, 406);
}
}

View File

@@ -63,7 +63,8 @@ return [
'dns_content' => [
'label' => 'Content',
'type' => 'text',
'value' => $content
'value' => $content,
'note' => lng('dnseditor.notes.A')
],
'dns_ttl' => [
'label' => 'TTL',

View File

@@ -897,6 +897,25 @@ return [
'dnseditor' => [
'edit' => 'edit DNS',
'records' => 'records',
'notes' => [
'A' => '32-bit IPv4 address, used to map hostnames to an IP address of the host.',
'AAAA' => '128-bit IPv6 address, used to map hostnames to an IP address of the host.',
'CAA' => 'The CAA resource record allows a DNS domain name holder to specify one or more Certification Authorities (CAs) authorized to issue certificates for that domain.<br>Structure: <code>flag tag[issue|issuewild|iodef|contactmail|contactphone] value</code><br>Example: <code>0 issue "ca.example.net"<br>0 iodef "mailto:security@example.com"</code>',
'CNAME' => 'Alias of the domain name, the DNS lookup will continue by retrying the lookup with the new name. Only possible for subdomains!',
'DNAME' => 'Creates an alias for an entire subtree of the domain name tree',
'LOC' => 'Geographic location information for a domain name.<br>Structure: <code>( d1 [m1 [s1]] {"N"|"S"} d2 [m2 [s2]] {"E"|"W"} alt["m"] [siz["m"] [hp["m"] [vp["m"]]]] )</code><br>Description: <code>d1: [0 .. 90] (degrees latitude)
d2: [0 .. 180] (degrees longitude)
m1, m2: [0 .. 59] (minutes latitude/longitude)
s1, s2: [0 .. 59.999] (seconds latitude/longitude)
alt: [-100000.00 .. 42849672.95] BY .01 (altitude in meters)
siz, hp, vp: [0 .. 90000000.00] (size/precision in meters)</code><br>Example: <code>52 22 23.000 N 4 53 32.000 E -2.00m 0.00m 10000m 10m</code>',
'MX' => 'Mail exchange record, maps a domain name to a mailserver for that domain.<br>Example: <code>10 mail.example.com</code><br>Note: For priority, use field above',
'NS' => 'Delegates a DNS zone to use the given authoritative name servers.',
'RP' => 'Responsible Person record<br>Structure: <code>mailbox[replace @ with a dot] txt-record-name</code><br>Example: <code>team.froxlor.org. froxlor.org.</code>',
'SRV' => 'Service location record, used for newer protocols instead of creating protocol-specific records such as MX.<br>Structure: <code>priority weight port target</code><br>Example: <code>0 5 5060 sipserver.example.com.</code><br>Note: For priority, use field above',
'SSHFP' => 'The SSHFP resource record is used to publish secure shell (SSH) key fingerprints in the DNS.<br>Structure: <code>algorithm type fingerprint</code><br>Algorithms: <code>0: reserved, 1: RSA, 2: DSA, 3: ECDSA, 4: Ed25519, 6: Ed448</code><br>Types: <code>0: reserved, 1: SHA-1, 2: SHA-256</code><br>Example: <code>2 1 123456789abcdef67890123456789abcdef67890</code>',
'TXT' => 'Free definable, descriptive text.'
]
],
'domain' => [
'openbasedirpath' => 'OpenBasedir-path',

View File

@@ -137,9 +137,6 @@
{% if field.type == 'hidden' and field.display is defined %}
<input type="text" readonly class="form-control-plaintext" value="{{ field.display }}">
{% endif %}
{% if field.note is defined and field.note is not empty %}
<div class="invalid-feedback">{{ field.note|raw }}</div>
{% endif %}
{% if field.next_to is defined %}
{% for nid, nfield in field.next_to %}
{% if nfield.next_to_prefix is defined %}

View File

@@ -0,0 +1,19 @@
$(function () {
// Display helptext to content box according to dns-record type selected
$("select[name='dns_type']").on('change', function () {
var selVal = $(this).val();
$.ajax({
url: "lib/ajax.php?action=loadLanguageString",
type: "POST",
dataType: "json",
data: { langid: 'dnseditor.notes.' + selVal },
success: function (data) {
$("#dns_content").next().html(data);
},
error: function (request, status, error) {
console.log(request, status, error)
}
});
});
});

View File

@@ -22,3 +22,4 @@ require('./components/domains')
require('./components/configfiles')
require('./components/apikeys')
require('./components/install')
require('./components/dnseditor')