dnmgmt/templates/domains/dns_check.html

80 lines
2.0 KiB
HTML

{% extends "base.html" %}
{% load staticfiles %}
{% block content %}
<div class="row">
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">Checking domain {{ domain.name }}</div>
<div class="panel-body">
<div id="dnscontent">
</div>
</div>
</div>
</div>
</div>
<script>
function addMessage(div, level, message) {
$(div).html($(div).html() + ' <div role="alert" class="alert alert-'+level+'"><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> '+message+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"></button></div>');
}
function addRecord(d, key, title) {
var msg = "";
if(d[key].length > 0) {
msg += "\n<p>" + title + ":<ul>";
for(var i=0; i<d[key].length; i++)
msg += "<li>" + d[key][i].join(" ") + "</li>";
msg += "</ul></p>";
}
return msg;
}
$(document).ready(function() {
$("#dnscontent").text("Running API request...");
$.get({
url: "{{ apiUrl }}",
data: {domain: "{{ key}}"},
beforeSend: function() {
$("#dnscontent").html('<img src="{% static "img/loader.gif" %}">');
},
success: function(data) {
$("#dnscontent").html("<p>Checked domain: " + data.domain + "</p>");
if(data.success) {
for(message of data.result) {
var level = "success";
if(message[0] == "err")
level = "danger";
var msg = message[1];
if(message.length > 2) {
var d = message[2];
msg += addRecord(d, "nameMissing", "Missing names");
msg += addRecord(d, "rrExtra", "Extra records");
msg += addRecord(d, "rrMissing", "Missing records");
//console.log(d);
//if(d["rrMissing"].length > 0) {
// msg += "\n<p>Missing records:<ul>";
// for(var i=0; i<d["rrMissing"].length; i++)
// msg += "<li>" + d["rrMissing"][i].join(" ") + "</li>";
// msg += "</ul></p>";
//}
}
addMessage("#dnscontent", level, msg);
}
} else {
addMessage("#dnscontent", "danger", "Could not get DNS data from API!");
}
}
});
});
</script>
{% endblock %}