2015-12-13 09:34:12 +00:00
|
|
|
{% extends "base.html" %}
|
|
|
|
{% block title %}<title>DNS Control Panel - DOMAIN</title>{% endblock %}
|
|
|
|
|
|
|
|
{% block dashboard_stat %}
|
2016-04-27 02:44:22 +00:00
|
|
|
<section class="content-header">
|
|
|
|
<h1>
|
|
|
|
Manage domain <small>{{ domain.name }}</small>
|
|
|
|
</h1>
|
|
|
|
<ol class="breadcrumb">
|
|
|
|
<li><a href="{{ url_for('dashboard') }}"><i
|
|
|
|
class="fa fa-dashboard"></i> Home</a></li>
|
|
|
|
<li>Domain</li>
|
|
|
|
<li class="active">{{ domain.name }}</li>
|
|
|
|
</ol>
|
|
|
|
</section>
|
2015-12-13 09:34:12 +00:00
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block content %}
|
2016-04-27 02:44:22 +00:00
|
|
|
<section class="content">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-xs-12">
|
|
|
|
<div class="box">
|
|
|
|
<div class="box-header">
|
|
|
|
<h3 class="box-title">Manage Records for {{ domain.name }}</h3>
|
|
|
|
</div>
|
|
|
|
<div class="box-body">
|
2016-04-29 17:07:46 +00:00
|
|
|
{% if domain.type != 'Slave' %}
|
2016-04-27 02:44:22 +00:00
|
|
|
<button type="button" class="btn btn-flat btn-primary pull-left button_add_record" id="{{ domain.name }}">
|
|
|
|
Add Record <i class="fa fa-plus"></i>
|
|
|
|
</button>
|
|
|
|
<button type="button" class="btn btn-flat btn-primary pull-right button_apply_changes" id="{{ domain.name }}">
|
|
|
|
Apply Changes <i class="fa fa-floppy-o"></i>
|
|
|
|
</button>
|
2016-04-29 17:07:46 +00:00
|
|
|
{% else %}
|
|
|
|
<button type="button" class="btn btn-flat btn-primary pull-left button_update_from_master" id="{{ domain.name }}">
|
|
|
|
Update from Master <i class="fa fa-download"></i>
|
|
|
|
</button>
|
|
|
|
{% endif %}
|
2016-04-27 02:44:22 +00:00
|
|
|
</div>
|
|
|
|
<div class="box-body">
|
|
|
|
<table id="tbl_records" class="table table-bordered table-striped">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Type</th>
|
|
|
|
<th>Status</th>
|
|
|
|
<th>TTL</th>
|
|
|
|
<th>Data</th>
|
|
|
|
<th>Edit</th>
|
|
|
|
<th>Delete</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2015-12-13 09:34:12 +00:00
|
|
|
{% for record in records %}
|
2016-04-27 02:44:22 +00:00
|
|
|
<tr class="odd">
|
2015-12-13 09:34:12 +00:00
|
|
|
<td>
|
|
|
|
{{ (record.name,domain.name)|display_record_name }}
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{{ record.type }}
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{{ record.status }}
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
{{ record.ttl }}
|
|
|
|
</td>
|
2016-04-28 04:05:41 +00:00
|
|
|
<td class="length-break">
|
2015-12-13 09:34:12 +00:00
|
|
|
{{ record.data }}
|
|
|
|
</td>
|
|
|
|
{% if domain.type != 'Slave' %}
|
|
|
|
<td width="6%">
|
|
|
|
{% if record.is_allowed() %}
|
2016-04-27 02:44:22 +00:00
|
|
|
<button type="button" class="btn btn-flat btn-warning button_edit" id="{{ (record.name,domain.name)|display_record_name }}">
|
|
|
|
Edit <i class="fa fa-edit"></i>
|
|
|
|
</button>
|
2015-12-13 09:34:12 +00:00
|
|
|
{% else %}
|
2016-04-27 02:44:22 +00:00
|
|
|
<!-- TODO: replace this link for slave records -->
|
|
|
|
<a href="#" class="btn default btn-xs purple"> <i class="fa fa-exclamation-circle"></i></a>
|
2015-12-13 09:34:12 +00:00
|
|
|
{% endif %}
|
|
|
|
</td>
|
|
|
|
<td width="6%">
|
|
|
|
{% if record.is_allowed() %}
|
2016-04-27 02:44:22 +00:00
|
|
|
<button type="button" class="btn btn-flat btn-danger button_delete" id="{{ (record.name,domain.name)|display_record_name }}">
|
|
|
|
Delete <i class="fa fa-trash"></i>
|
|
|
|
</button>
|
2015-12-13 09:34:12 +00:00
|
|
|
{% else %}
|
2016-04-27 02:44:22 +00:00
|
|
|
<!-- TODO: replace this link for slave records -->
|
2015-12-13 09:34:12 +00:00
|
|
|
<a href="#" class="btn default btn-xs red"> <i class="fa fa-exclamation-circle"></i></a>
|
|
|
|
{% endif %}
|
|
|
|
{% else %}
|
2016-04-27 02:44:22 +00:00
|
|
|
<!-- TODO: replace these links for slave records -->
|
2015-12-13 09:34:12 +00:00
|
|
|
<td width="6%">
|
|
|
|
<a href="#" class="btn default btn-xs purple"> <i class="fa fa-exclamation-circle"></i></a>
|
|
|
|
</td>
|
|
|
|
<td width="6%">
|
|
|
|
<a href="#" class="btn default btn-xs purple"> <i class="fa fa-exclamation-circle"></i></a>
|
|
|
|
</td>
|
|
|
|
{% endif %}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{% endfor %}
|
2016-04-27 02:44:22 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<!-- /.box-body -->
|
|
|
|
</div>
|
|
|
|
<!-- /.box -->
|
|
|
|
</div>
|
|
|
|
<!-- /.col -->
|
|
|
|
</div>
|
|
|
|
<!-- /.row -->
|
|
|
|
</section>
|
2015-12-13 09:34:12 +00:00
|
|
|
{% endblock %}
|
2016-04-27 02:44:22 +00:00
|
|
|
{% block extrascripts %}
|
2015-12-13 09:34:12 +00:00
|
|
|
<script>
|
2016-04-27 02:44:22 +00:00
|
|
|
// superglobals
|
|
|
|
window.records_allow_edit = {{ editable_records|tojson }};
|
|
|
|
window.nEditing = null;
|
|
|
|
window.nNew = false;
|
|
|
|
|
|
|
|
// set up user data table
|
|
|
|
$("#tbl_records").DataTable({
|
|
|
|
"paging" : true,
|
|
|
|
"lengthChange" : true,
|
|
|
|
"searching" : true,
|
|
|
|
"ordering" : true,
|
|
|
|
"info" : true,
|
|
|
|
"autoWidth" : false,
|
|
|
|
"lengthMenu": [ [5, 15, 20, -1],
|
|
|
|
[5, 15, 20, "All"]],
|
|
|
|
"pageLength": 15,
|
|
|
|
"language": {
|
|
|
|
"lengthMenu": " _MENU_ records"
|
|
|
|
},
|
|
|
|
"retrieve" : true
|
|
|
|
});
|
|
|
|
|
|
|
|
// handle delete button
|
|
|
|
$(document).on("click", ".button_delete", function() {
|
|
|
|
var modal = $("#modal_delete");
|
|
|
|
var table = $("#tbl_records").DataTable();
|
|
|
|
var record = $(this).prop('id');
|
|
|
|
var info = "Are you sure you want to delete " + record + "?";
|
|
|
|
modal.find('.modal-body p').text(info);
|
|
|
|
modal.find('#button_delete_confirm').click(function() {
|
|
|
|
table.row($(this).parents('tr')[0]).remove().draw();
|
|
|
|
modal.modal('hide');
|
|
|
|
})
|
|
|
|
modal.modal('show');
|
|
|
|
|
|
|
|
});
|
|
|
|
// handle edit button
|
|
|
|
$(document).on("click", ".button_edit", function() {
|
|
|
|
var nRow = $(this).parents('tr')[0];
|
|
|
|
var table = $("#tbl_records").DataTable();
|
|
|
|
|
|
|
|
if (nEditing !== null && nEditing != nRow && nNew == false) {
|
|
|
|
/* Currently editing - but not this row - restore the old before continuing to edit mode */
|
|
|
|
restoreRow(table, nEditing);
|
|
|
|
editRow(table, nRow);
|
|
|
|
nEditing = nRow;
|
|
|
|
} else if (nNew == true) {
|
|
|
|
/* adding a new row, delete it and start editing */
|
|
|
|
table.row(nEditing).remove().draw();
|
|
|
|
nNew = false;
|
|
|
|
editRow(table, nRow);
|
|
|
|
nEditing = nRow;
|
|
|
|
} else {
|
|
|
|
/* No edit in progress - let's start one */
|
|
|
|
editRow(table, nRow);
|
|
|
|
nEditing = nRow;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// handle apply changes button
|
|
|
|
$(document).on("click",".button_apply_changes", function() {
|
|
|
|
var modal = $("#modal_apply_changes");
|
|
|
|
var table = $("#tbl_records").DataTable();
|
|
|
|
var domain = $(this).prop('id');
|
|
|
|
var info = "Are you sure you want to apply your changes?";
|
|
|
|
modal.find('.modal-body p').text(info);
|
|
|
|
modal.find('#button_apply_confirm').click(function() {
|
|
|
|
var data = getTableData(table);
|
|
|
|
applyChanges(data, '/domain/' + domain + '/apply', true);
|
|
|
|
modal.modal('hide');
|
|
|
|
})
|
|
|
|
modal.modal('show');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
// handle add record button
|
|
|
|
$(document).on("click", ".button_add_record", function (e) {
|
|
|
|
if (nNew || nEditing) {
|
|
|
|
// TODO: replace this alert with modal
|
|
|
|
alert("Previous record not saved. Please save it before adding more record.")
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var table = $("#tbl_records").DataTable();
|
|
|
|
|
|
|
|
var aiNew = table.row.add(['', 'A', 'Active', 3600, '', '', '']).draw();
|
|
|
|
var nRow = aiNew.index();
|
|
|
|
editRow(table, nRow);
|
|
|
|
nEditing = nRow;
|
|
|
|
nNew = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
//handle cancel button
|
|
|
|
$(document).on("click", ".button_cancel", function (e) {
|
|
|
|
var oTable = $("#tbl_records").DataTable();
|
|
|
|
if (nNew) {
|
|
|
|
oTable.row(nEditing).remove().draw();
|
|
|
|
nEditing = null;
|
|
|
|
nNew = false;
|
|
|
|
} else {
|
|
|
|
restoreRow(oTable, nEditing);
|
|
|
|
nEditing = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
//handle save button
|
|
|
|
$(document).on("click", ".button_save", function (e) {
|
|
|
|
var table = $("#tbl_records").DataTable();
|
|
|
|
saveRow(table, nEditing);
|
|
|
|
nEditing = null;
|
2016-04-29 16:25:43 +00:00
|
|
|
nNew = false;
|
2016-04-27 02:44:22 +00:00
|
|
|
});
|
2016-04-29 17:07:46 +00:00
|
|
|
|
|
|
|
//handle update_from_master button
|
|
|
|
$(document).on("click", ".button_update_from_master", function (e) {
|
|
|
|
var domain = $(this).prop('id');
|
|
|
|
applyChanges({'domain': domain}, '/domain/' + domain + '/update');
|
|
|
|
});
|
2015-12-13 09:34:12 +00:00
|
|
|
</script>
|
2016-04-27 02:44:22 +00:00
|
|
|
{% endblock %}
|
|
|
|
{% block modals %}
|
|
|
|
<div class="modal fade modal-warning" id="modal_delete">
|
|
|
|
<div class="modal-dialog">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<button type="button" class="close" data-dismiss="modal"
|
|
|
|
aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
<h4 class="modal-title">Confirmation</h4>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<p></p>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-default pull-left"
|
|
|
|
data-dismiss="modal">Close</button>
|
|
|
|
<button type="button" class="btn btn-danger" id="button_delete_confirm">Delete</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- /.modal-content -->
|
|
|
|
</div>
|
|
|
|
<!-- /.modal-dialog -->
|
|
|
|
</div>
|
|
|
|
<div class="modal fade modal-primary" id="modal_apply_changes">
|
|
|
|
<div class="modal-dialog">
|
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
|
|
|
<button type="button" class="close" data-dismiss="modal"
|
|
|
|
aria-label="Close">
|
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
<h4 class="modal-title">Confirmation</h4>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<p></p>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
|
|
<button type="button" class="btn btn-flat btn-default pull-left"
|
|
|
|
data-dismiss="modal">Close</button>
|
|
|
|
<button type="button" class="btn btn-flat btn-primary" id="button_apply_confirm">Apply</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- /.modal-content -->
|
|
|
|
</div>
|
|
|
|
<!-- /.modal-dialog -->
|
|
|
|
</div>
|
2015-12-13 09:34:12 +00:00
|
|
|
{% endblock %}
|