mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-12-30 15:05:39 +00:00
6c8a3ac36c
For a setting to be useful, the code has to be able to make sense of it anyway. For this reason it makes sense, that the available settings are defined within the code, rather than in the database, where a missing row has previously caused problems. Instead, settings are now written to the database, when they are changed. So instead of relying on the database initialization process to create all available settings for us in the database, the supported settings and their defaults are now in a `defaults` dict in the Setting class. With this in place, we can stop populating the `setting` table as a part of database initialization and it will be much easier to support new settings in the future (we no longer need to do anything to the database, to achieve that). Another benefit is that any changes to default values will take effect automatically, unless the admin has already modified that setting to his/her liking. To make it easier to get the value of a setting, falling back to defaults etc, a new function `get` has been added to the Setting class. Call it as `Setting().get('setting_name'), and it will take care of returning a setting from the database or return the default value for that setting, if nothing was found. The `get` function returns `None`, if the setting passed to the function, does not exist in the `Setting.defaults` dict - Indicating that we don't know of a setting by that name.
90 lines
3.6 KiB
HTML
90 lines
3.6 KiB
HTML
{% extends "base.html" %} {% block title %}
|
|
<title>DNS Control Panel - Settings</title>
|
|
{% endblock %} {% block dashboard_stat %}
|
|
<!-- Content Header (Page header) -->
|
|
<section class="content-header">
|
|
<h1>
|
|
Settings <small>PowerDNS-Admin settings</small>
|
|
</h1>
|
|
<ol class="breadcrumb">
|
|
<li><a href="{{ url_for('dashboard') }}"><i
|
|
class="fa fa-dashboard"></i> Home</a></li>
|
|
<li class="active">Settings</li>
|
|
</ol>
|
|
</section>
|
|
{% endblock %} {% block content %}
|
|
<section class="content">
|
|
<div class="row">
|
|
<div class="col-xs-12">
|
|
<div class="box">
|
|
<div class="box-header">
|
|
<h3 class="box-title">Settings Management</h3>
|
|
</div>
|
|
<div class="box-body">
|
|
<table id="tbl_settings" class="table table-bordered table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Value</th>
|
|
<th>Change</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for setting_name, setting_value in settings.items() %}
|
|
<tr class="odd ">
|
|
<td>{{ setting_name }}</td>
|
|
{% if setting_value == "True" or setting_value == "False" %}
|
|
<td>{{ setting_value }}</td>
|
|
{% else %}
|
|
<td><input name="value" id="value" value="{{ setting_value }}"></td>
|
|
{% endif %}
|
|
<td width="6%">
|
|
{% if setting_value == "True" or setting_value == "False" %}
|
|
<button type="button" class="btn btn-flat btn-warning setting-toggle-button" id="{{ setting_name }}">
|
|
Toggle <i class="fa fa-info"></i>
|
|
</button>
|
|
{% else %}
|
|
<button type="button" class="btn btn-flat btn-warning setting-save-button" id="{{ setting_name }}">
|
|
Save <i class="fa fa-info"></i>
|
|
</button>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- /.box-body -->
|
|
</div>
|
|
<!-- /.box -->
|
|
</div>
|
|
<!-- /.col -->
|
|
</div>
|
|
<!-- /.row -->
|
|
</section>
|
|
{% endblock %}
|
|
{% block extrascripts %}
|
|
<script>
|
|
// set up history data table
|
|
$("#tbl_settings").DataTable({
|
|
"paging" : true,
|
|
"lengthChange" : false,
|
|
"searching" : true,
|
|
"ordering" : true,
|
|
"info" : true,
|
|
"autoWidth" : false
|
|
});
|
|
$(document.body).on('click', '.setting-toggle-button', function() {
|
|
var setting = $(this).prop('id');
|
|
applyChanges('', $SCRIPT_ROOT + '/admin/setting/' + setting + '/toggle', false, true)
|
|
});
|
|
|
|
$(document.body).on('click', '.setting-save-button', function() {
|
|
var setting = $(this).prop('id');
|
|
var value = $(this).parents('tr').find('#value')[0].value;
|
|
var postdata = {'value': value};
|
|
applyChanges(postdata, $SCRIPT_ROOT + '/admin/setting/' + setting + '/edit', false, true)
|
|
});
|
|
</script>
|
|
{% endblock %}
|