Mini Shell
{# vim: ts=2:sw=2:et:ft=jinja-html #}
{% extends "base.html.jinja" %}
{% from "bootstrap_macros.html.jinja" import checkbox, header_card, select, header_input_group without context %}
{% block body %}
{% macro task_config(task_conf) %}
{# caller has to be evalulated before we can start another call #}
{% set content=caller() %}
<div class="mb-3">
{% call header_card(task_conf.label) %}
{{ checkbox("{}-enabled".format(task_conf.task), "Enabled", task_conf.enabled) }}
<div class="mt-3">
<div class="input-group">
<span class="input-group-text">Interval</span>
<input id="{{ task_conf.task }}-interval" type="number" class="form-control" min="1" max="30" step="1" value="{{ task_conf.interval }}">
<span class="input-group-text">days</span>
</div>
</div>
{{ content }}
{% endcall %}
</div>
{% endmacro %}
<script type="text/javascript">
function save(){
var button = document.getElementById("save-btn");
var alert = document.getElementById("save-alert");
button.disabled = true;
alert.textContent = "Loading...";
set_alert(alert, "light");
var form_data = new FormData();
form_data.append("files-enabled", document.getElementById("files-enabled").checked);
form_data.append("mysql-enabled", document.getElementById("mysql-enabled").checked);
form_data.append("pgsql-enabled", document.getElementById("pgsql-enabled").checked);
form_data.append("files-interval", document.getElementById("files-interval").value);
form_data.append("mysql-interval", document.getElementById("mysql-interval").value);
form_data.append("pgsql-interval", document.getElementById("pgsql-interval").value);
form_data.append("files-include", document.getElementById("files-include").value);
form_data.append("files-exclude", document.getElementById("files-exclude").value);
form_data.append("loglevel", document.getElementById("loglevel").value);
form_data.append("max-load", document.getElementById("max-load").value);
form_data.append("max-cpus", document.getElementById("max-cpus").value);
fetch(
"{{ url_for('config_page') }}", {
method: 'post',
body: form_data,
}
).then((response) => {
if (response.status != 200) {
alert.textContent = response.statusText;
set_alert(alert, "danger");
return null;
}
return response.json();
}).then((res) => {
button.disabled = false;
if (res === null ){
return;
}
alert.textContent = res['text'];
if (res['accepted']){
set_alert(alert, "success");
} else {
set_alert(alert, "danger");
}
}).catch((error) => {
button.disabled = false;
set_alert(alert, "danger");
alert.textContent = error;
});
}
function set_alert(alert, state){
alert.classList.remove('d-none');
alert.classList.remove('alert-light');
alert.classList.remove('alert-danger');
alert.classList.remove('alert-success');
alert.classList.add('alert-'.concat(state));
}
</script>
<div class="mb-3">
<div id="save-alert" class="alert d-none" role="alert" style="white-space: pre; overflow: auto"></div>
<button onclick="save()" id="save-btn" class="btn btn-primary">Save</button>
</div>
{% call task_config(conf.files) %}
{% call header_input_group("Include", "Paths to backup. Please specify these as full paths, one per line.", group_class="mb-3 mt-3") %}
<textarea id="files-include" class="form-control">{{ '\n'.join(conf.files.include) }}</textarea>
{% endcall %}
{% call header_input_group("Exclude", "These are the subdirectories of above to skip.") %}
<textarea id="files-exclude" class="form-control">{{ '\n'.join(conf.files.exclude) }}</textarea>
{% endcall %}
{% endcall %}
{% call task_config(conf.mysql) %}
{% endcall %}
{% call task_config(conf.pgsql) %}
{% endcall %}
{% call header_card("Tuning") %}
{{ select(
"loglevel",
{
'DEBUG': 'DEBUG: Shows all messages',
'INFO': 'INFO: Shows info, warning, error, & critical messages',
'WARNING': 'WARNING: Shows warning, error, & critical messages',
'ERROR': 'ERROR: Shows error & critical messages',
'CRITICAL': 'CRITICAL: Only shows critical messages'
},
conf.loglevel,
"This is the verbosity of the log at /var/log/bakmgr.log. INFO is recommended."
) }}
{% call header_input_group("Max Load", "Backup tasks can pause and resume based on server load. To disable this behavior, set max_load to 0.0") %}
<input id="max-load" type="number" value="{{ conf.max_load }}" step="0.1" min="0"/>
{% endcall %}
{% if not conf.is_vps %}
{% call header_input_group("Max CPUs", "This sets how many CPU cores backups can use. Set it to 0 to allow it to use all CPU cores on the system") %}
<input id="max-cpus" type="number" value="{{ conf.max_cpus }}" step="1" min="0"/>
{% endcall %}
{% endif %}
{% endcall %}
{% endblock %}
Zerion Mini Shell 1.0