Skip to content

Commit

Permalink
more work on advanced dns settings
Browse files Browse the repository at this point in the history
  • Loading branch information
kiekerjan committed Jul 23, 2024
1 parent e891322 commit 807aebf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
16 changes: 16 additions & 0 deletions management/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,22 @@ def dns_get_zonefile(zone):
from dns_update import get_dns_zonefile
return Response(get_dns_zonefile(zone, env), status=200, mimetype='text/plain')

@app.route('/dns/advanced-dns')
@authorized_personnel_only
def dns_get_advanced_dns_options():

return json_response({ "hiddenmaster_enabled": False, "hiddenmaster_selected": False, "short_ttl_selected" })

@app.route('/dns/advanced-dns', methods=['POST'])
@authorized_personnel_only
def dns_set_advanced_dns_options():

try:
return "Updated it very nicely"
except ValueError as e:
# Use as raise ValueError(msg)
return (str(e), 400)

# SSL

@app.route('/ssl/status')
Expand Down
34 changes: 24 additions & 10 deletions management/templates/custom-dns.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ <h4>Examples:</h4>
function(data) {
$('#secondarydnsHostname').val(data.hostnames.join(' '));
$('#secondarydns-clear-instructions').toggle(data.hostnames.length > 0);
$('#enableHiddenMaster').disabled);
});

api(
Expand All @@ -213,11 +212,9 @@ <h4>Examples:</h4>
}
});




show_current_custom_dns();
show_customdns_rtype_hint();
show_advanced_dns();
}

function show_current_custom_dns() {
Expand Down Expand Up @@ -294,7 +291,7 @@ <h4>Examples:</h4>
if ($('#customdnsQname').val() != '')
qname = $('#customdnsQname').val() + '.' + $('#customdnsZone').val();
else
qname = $('#customdnsZone').val();
qname = $('#customdnsZone').val();
rtype = $('#customdnsType').val();
value = $('#customdnsValue').val();
method = 'POST';
Expand All @@ -319,22 +316,39 @@ <h4>Examples:</h4>
}

function show_advanced_dns() {
api(
"/dns/advanced-dns",
"GET",
{ },
function(data) {
if (data.hiddenmaster_enable) {
$('#enableHiddenMaster').removeClass('disabled')
$('#enableHiddenMaster').prop('checked', data.hiddenmaster_selected);
}
else {
$('#enableHiddenMaster').addClass('disabled')
$('#enableHiddenMaster').prop('checked', false);
}

$('#enableShortTTL').prop(data.short_ttl_selected);
});
}

function do_set_advanced_dns() {
api(
"/dns/secondary-nameserver",
"/dns/advanced-dns",
"POST",
{
hostnames: $('#secondarydnsHostname').val()
hiddenmaster_selected: $('#enableHiddenMaster').val();
short_ttl_selected: $('#enableShortTTL').val();
},
function(data) {
if (data == "") return; // nothing updated
show_modal_error("Secondary DNS", $("<pre/>").text(data));
$('#secondarydns-clear-instructions').slideDown();
show_modal_error("Advanced DNS", $("<pre/>").text(data));
show_advanced_dns();
},
function(err) {
show_modal_error("Secondary DNS", $("<pre/>").text(err));
show_modal_error("Advanced DNS", $("<pre/>").text(err));
});
}

Expand Down

0 comments on commit 807aebf

Please sign in to comment.