mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-06-14 12:06:06 +00:00
Converted record management page to new template.
This commit is contained in:
@ -1,126 +1,52 @@
|
||||
{% extends "base.html" %}
|
||||
{% block head %}
|
||||
{{ super() }}
|
||||
<!-- BEGIN PAGE LEVEL PLUGIN STYLES -->
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='global/plugins/select2/select2.css') }}"/>
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.css') }}"/>
|
||||
<!-- END PAGE LEVEL PLUGIN STYLES -->
|
||||
|
||||
<!-- BEGIN THEME STYLES -->
|
||||
<!-- DOC: To use 'rounded corners' style just load 'components-rounded.css' stylesheet instead of 'components.css' in the below style tag -->
|
||||
<link href="{{ url_for('static', filename='global/css/components-md.css') }}" id="style_components" rel="stylesheet" type="text/css"/>
|
||||
<link href="{{ url_for('static', filename='global/css/plugins-md.css') }}" rel="stylesheet" type="text/css"/>
|
||||
<link href="{{ url_for('static', filename='admin/layout2/css/layout.css') }}" rel="stylesheet" type="text/css"/>
|
||||
<link href="{{ url_for('static', filename='admin/layout2/css/themes/grey.css') }}" rel="stylesheet" type="text/css" id="style_color"/>
|
||||
<link href="{{ url_for('static', filename='admin/layout2/css/custom.css') }}" rel="stylesheet" type="text/css"/>
|
||||
<!-- END THEME STYLES -->
|
||||
{% endblock %}
|
||||
{% block title %}<title>DNS Control Panel - DOMAIN</title>{% endblock %}
|
||||
|
||||
{% block dashboard_stat %}
|
||||
<!-- BEGIN PAGE HEADER-->
|
||||
<h3 class="page-title">
|
||||
Domain</h3>
|
||||
<div class="page-bar">
|
||||
<ul class="page-breadcrumb">
|
||||
<li>
|
||||
<i class="fa fa-home"></i>
|
||||
<a href="{{ url_for('dashboard') }}">Home</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ url_for('dashboard') }}">Domain</a>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</li>
|
||||
<li>
|
||||
<a href="">{{ domain.name }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- END PAGE HEADER-->
|
||||
<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>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="clearfix">
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<!-- BEGIN RECORD TABLE-->
|
||||
<div class="portlet box blue">
|
||||
<div class="portlet-title">
|
||||
<div class="caption">
|
||||
<i class="fa fa-globe"></i> {{ domain.name }}
|
||||
<input type="hidden" id="domainname" value="{{ domain.name }}">
|
||||
</div>
|
||||
<div class="tools">
|
||||
<a href="javascript:;" class="collapse">
|
||||
</a>
|
||||
<a href="javascript:;" class="reload">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="portlet-body">
|
||||
{% if domain.type != 'Slave' %}
|
||||
<div class="table-toolbar">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="btn-group">
|
||||
<button id="tbl_record_manage_new" class="btn green">
|
||||
Add Record <i class="fa fa-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="btn-group pull-right">
|
||||
<button id="tbl_record_manage_apply" class="btn green">
|
||||
<i class="fa fa-save"></i>Apply Changes
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="table-toolbar">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="btn-group">
|
||||
<button id="tbl_record_update_from_master" class="btn green">
|
||||
Update from Master <i class="fa fa-download"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<table class="table table-striped table-hover table-bordered" id="tbl_record_manage">
|
||||
<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>
|
||||
<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">
|
||||
<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>
|
||||
</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>
|
||||
{% for record in records %}
|
||||
<tr class="odd gradeX">
|
||||
<tr class="odd">
|
||||
<td>
|
||||
{{ (record.name,domain.name)|display_record_name }}
|
||||
</td>
|
||||
@ -139,18 +65,25 @@
|
||||
{% if domain.type != 'Slave' %}
|
||||
<td width="6%">
|
||||
{% if record.is_allowed() %}
|
||||
<a class="btn default btn-xs purple edit" href="javascript:;"> <i class="fa fa-edit"></i></a>
|
||||
<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>
|
||||
{% else %}
|
||||
<a href="#" class="btn default btn-xs purple"> <i class="fa fa-exclamation-circle"></i></a>
|
||||
<!-- TODO: replace this link for slave records -->
|
||||
<a href="#" class="btn default btn-xs purple"> <i class="fa fa-exclamation-circle"></i></a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td width="6%">
|
||||
{% if record.is_allowed() %}
|
||||
<a class="btn default btn-xs red delete" href="javascript:;"> <i class="fa fa-trash"></i></a>
|
||||
<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>
|
||||
{% else %}
|
||||
<!-- TODO: replace this link for slave records -->
|
||||
<a href="#" class="btn default btn-xs red"> <i class="fa fa-exclamation-circle"></i></a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<!-- TODO: replace these links for slave records -->
|
||||
<td width="6%">
|
||||
<a href="#" class="btn default btn-xs purple"> <i class="fa fa-exclamation-circle"></i></a>
|
||||
</td>
|
||||
@ -161,36 +94,178 @@
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END RECORD TABLE-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- /.box-body -->
|
||||
</div>
|
||||
<!-- /.box -->
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
<!-- /.row -->
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
{{ super() }}
|
||||
<!-- BEGIN PAGE LEVEL SCRIPTS -->
|
||||
<script src="{{ url_for('static', filename='global/scripts/metronic.js') }}" type="text/javascript"></script>
|
||||
<script src="{{ url_for('static', filename='admin/layout2/scripts/layout.js') }}" type="text/javascript"></script>
|
||||
<script src="{{ url_for('static', filename='global/plugins/bootbox/bootbox.min.js') }}" type="text/javascript"></script>
|
||||
<!-- END PAGE LEVEL SCRIPTS -->
|
||||
<!-- TABLE PLUGINS -->
|
||||
<script type="text/javascript" src="{{ url_for('static', filename='global/plugins/select2/select2.min.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('static', filename='global/plugins/datatables/media/js/jquery.dataTables.min.js') }}"></script>
|
||||
<script type="text/javascript" src="{{ url_for('static', filename='global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='admin/pages/scripts/table-editable.js') }}"></script>
|
||||
<!-- END TABLE PLUGINS -->
|
||||
{% block extrascripts %}
|
||||
<script>
|
||||
jQuery(document).ready(function() {
|
||||
window.records_allow_edit = {{ editable_records|tojson }};
|
||||
Metronic.init(); // init metronic core componets
|
||||
Layout.init(); // init layout
|
||||
TableEditable.init();
|
||||
});
|
||||
// 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;
|
||||
});
|
||||
|
||||
</script>
|
||||
<!-- END JAVASCRIPTS -->
|
||||
{% 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>
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user