mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
first version of java script based dynamic provider selection
This commit is contained in:
parent
f35ab6a3b4
commit
874d0bea18
@ -70,15 +70,44 @@ class TrimmedCharField(forms.CharField):
|
|||||||
|
|
||||||
class ConfigureForm(forms.Form):
|
class ConfigureForm(forms.Form):
|
||||||
"""Form to configure the dynamic DNS client"""
|
"""Form to configure the dynamic DNS client"""
|
||||||
enabled = forms.BooleanField(label=_('Enable dynamicdns'),
|
enabled = forms.BooleanField(label=_('Enable Dynamic DNS'),
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
|
dynamicdns_service = forms.ChoiceField(label=_('Service type'),
|
||||||
|
help_text=_('Please choose a update protocol according to your provider.\
|
||||||
|
We recommend the GnudIP protocol. If your provider does not \
|
||||||
|
support the GnudIP protocol or your provider is not listed \
|
||||||
|
you may use the update URL of your provider.'),
|
||||||
|
choices=(('1', 'GnudIP'),
|
||||||
|
('2', 'noip.com'),
|
||||||
|
('3', 'selfhost.bz'),
|
||||||
|
('4', 'other Update URL')))
|
||||||
|
|
||||||
dynamicdns_server = TrimmedCharField(
|
dynamicdns_server = TrimmedCharField(
|
||||||
label=_('Server Address'),
|
label=_('GnudIP Server Address'),
|
||||||
help_text=_('Example: gnudip.provider.org'),
|
help_text=_('Example: gnudip.provider.org'),
|
||||||
validators=[
|
validators=[
|
||||||
validators.RegexValidator(r'^[\w-]{1,63}(\.[\w-]{1,63})*$',
|
validators.RegexValidator(r'^[\w-]{1,63}(\.[\w-]{1,63})*$',
|
||||||
_('Invalid server name'))])
|
_('Invalid server name'))])
|
||||||
|
|
||||||
|
dynamicdns_update_url = TrimmedCharField(
|
||||||
|
label=_('Update URL'),
|
||||||
|
required=False,
|
||||||
|
help_text=_('The Variables $User, $Pass, $IP, $Domain may be used \
|
||||||
|
within this URL.</br> Example URL: </br> \
|
||||||
|
https://some.tld/up.php?us=$User&pw=$Pass&ip=$IP&dom=$Domain'),
|
||||||
|
validators=[
|
||||||
|
validators.URLValidator(schemes=['http', 'https'])])
|
||||||
|
|
||||||
|
disable_SSL_cert_check = forms.BooleanField(
|
||||||
|
label=_('accept all SSL certificates'),
|
||||||
|
help_text=_('use this option if your provider uses\
|
||||||
|
self signed certificates'),
|
||||||
|
required=False)
|
||||||
|
|
||||||
|
use_http_basic_auth = forms.BooleanField(
|
||||||
|
label=_('use HTTP basic authentication'),
|
||||||
|
required=False)
|
||||||
|
|
||||||
dynamicdns_domain = TrimmedCharField(
|
dynamicdns_domain = TrimmedCharField(
|
||||||
label=_('Domain Name'),
|
label=_('Domain Name'),
|
||||||
@ -96,7 +125,8 @@ class ConfigureForm(forms.Form):
|
|||||||
label=_('Password'), widget=forms.PasswordInput(),
|
label=_('Password'), widget=forms.PasswordInput(),
|
||||||
required=False,
|
required=False,
|
||||||
help_text=_('You should have been requested to select a password \
|
help_text=_('You should have been requested to select a password \
|
||||||
when you created the account.'))
|
when you created the account. Leave this field empty \
|
||||||
|
if you want to keep your previous configured password.'))
|
||||||
|
|
||||||
showpw = forms.BooleanField(label=_('show password'),
|
showpw = forms.BooleanField(label=_('show password'),
|
||||||
required=False,
|
required=False,
|
||||||
|
|||||||
@ -21,25 +21,123 @@
|
|||||||
{% load bootstrap %}
|
{% load bootstrap %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h3>Configuration</h3>
|
|
||||||
<form class="form" method="post">
|
<form class="form" method="post">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
{{ form|bootstrap }}
|
{% include 'bootstrapform/field.html' with field=form.enabled %}
|
||||||
|
|
||||||
<input type="submit" class="btn btn-primary btn-md" value="Update setup"/>
|
<div id='dynamicdns-post-enabled-form'
|
||||||
|
style='display: {{ form.enabled.value|yesno:'block,none' }};'>
|
||||||
|
<h3>Dynamic DNS type</h3>
|
||||||
|
{% include 'bootstrapform/field.html' with field=form.dynamicdns_service %}
|
||||||
|
<div id='dynamicdns-gnudip'>
|
||||||
|
{% include 'bootstrapform/field.html' with field=form.dynamicdns_server %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id='dynamicdns-updateurl'>
|
||||||
|
{% include 'bootstrapform/field.html' with field=form.dynamicdns_update_url %}
|
||||||
|
{% include 'bootstrapform/field.html' with field=form.disable_SSL_cert_check %}
|
||||||
|
{% include 'bootstrapform/field.html' with field=form.use_http_basic_auth %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>Account Information</h3>
|
||||||
|
{% include 'bootstrapform/field.html' with field=form.dynamicdns_domain %}
|
||||||
|
{% include 'bootstrapform/field.html' with field=form.dynamicdns_user %}
|
||||||
|
{% include 'bootstrapform/field.html' with field=form.dynamicdns_secret %}
|
||||||
|
{% include 'bootstrapform/field.html' with field=form.showpw %}
|
||||||
|
|
||||||
|
<h3>IP check URL</h3>
|
||||||
|
{% include 'bootstrapform/field.html' with field=form.dynamicdns_ipurl %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="submit" class="btn btn-primary" value="Update setup"/>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block page_js %}
|
{% block page_js %}
|
||||||
<script type="text/javascript">
|
|
||||||
function show_pass()
|
|
||||||
{
|
|
||||||
if(document.getElementById('id_dynamicdns-showpw').checked){
|
<script type="text/javascript">
|
||||||
document.getElementById("id_dynamicdns-dynamicdns_secret").type='text';}
|
|
||||||
else
|
window.onload = function() {hide()}
|
||||||
document.getElementById("id_dynamicdns-dynamicdns_secret").type='password';
|
|
||||||
}
|
(function($) {
|
||||||
</script>
|
|
||||||
|
$('#id_dynamicdns-enabled').change(function() {
|
||||||
|
if ($('#id_dynamicdns-enabled').prop('checked')) {
|
||||||
|
$('#dynamicdns-post-enabled-form').show('slow');
|
||||||
|
} else {
|
||||||
|
$('#dynamicdns-post-enabled-form').hide('slow');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#id_dynamicdns-dynamicdns_service').change(function() {
|
||||||
|
//$(this).find('option:selected').text() == GnudIP
|
||||||
|
if ($(this).val() == 1){
|
||||||
|
$('#dynamicdns-updateurl').hide();
|
||||||
|
$('#dynamicdns-gnudip').show('slow');
|
||||||
|
$('#id_dynamicdns-dynamicdns_update_url').val("");
|
||||||
|
}
|
||||||
|
if ($(this).val() == 2){
|
||||||
|
$('#dynamicdns-updateurl').show('slow');
|
||||||
|
$('#dynamicdns-gnudip').hide();
|
||||||
|
$('#id_dynamicdns-dynamicdns_server').val("");
|
||||||
|
$('#id_dynamicdns-dynamicdns_update_url').val("https://noip.com/update.php?user=$user&pass=$pass&domain=$domain&IP=foo$ip");
|
||||||
|
}
|
||||||
|
if ($(this).val() == 3){
|
||||||
|
$('#dynamicdns-updateurl').show('slow');
|
||||||
|
$('#dynamicdns-gnudip').hide();
|
||||||
|
$('#id_dynamicdns-dynamicdns_server').val("");
|
||||||
|
$('#id_dynamicdns-dynamicdns_update_url').val("https://selfhost.bz/update.php?user=$user&pass=$pass&domain=$domain&IP=foo$ip");
|
||||||
|
}
|
||||||
|
if ($(this).val() == 4){
|
||||||
|
$('#dynamicdns-updateurl').show('slow');
|
||||||
|
$('#dynamicdns-gnudip').hide();
|
||||||
|
$('#id_dynamicdns-dynamicdns_server').val("");
|
||||||
|
$('#id_dynamicdns-dynamicdns_update_url').val("https://example.com/update.php?user=$user&pass=$pass&domain=$domain&IP=foo$ip");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})(jQuery);
|
||||||
|
|
||||||
|
function show_pass()
|
||||||
|
{
|
||||||
|
if(document.getElementById('id_dynamicdns-showpw').checked){
|
||||||
|
document.getElementById("id_dynamicdns-dynamicdns_secret").type='text';}
|
||||||
|
else
|
||||||
|
document.getElementById("id_dynamicdns-dynamicdns_secret").type='password';
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide()
|
||||||
|
{
|
||||||
|
if ($('#id_dynamicdns-enabled').prop('checked')) {
|
||||||
|
//$(this).find('option:selected').text() == GnudIP
|
||||||
|
if ($(this).val() == 1){
|
||||||
|
$('#dynamicdns-updateurl').hide();
|
||||||
|
$('#id_dynamicdns-dynamicdns_update_url').val("");
|
||||||
|
}
|
||||||
|
if ($(this).val() == 2){
|
||||||
|
$('#dynamicdns-gnudip').hide();
|
||||||
|
$('#id_dynamicdns-dynamicdns_server').val("");
|
||||||
|
$('#id_dynamicdns-dynamicdns_update_url').val("https://noip.com/update.php?user=$user&pass=$pass&domain=$domain&IP=foo$ip");
|
||||||
|
}
|
||||||
|
if ($(this).val() == 3){
|
||||||
|
$('#dynamicdns-gnudip').hide();
|
||||||
|
$('#id_dynamicdns-dynamicdns_server').val("");
|
||||||
|
$('#id_dynamicdns-dynamicdns_update_url').val("https://selfhost.bz/update.php?user=$user&pass=$pass&domain=$domain&IP=foo$ip");
|
||||||
|
}
|
||||||
|
if ($(this).val() == 4){
|
||||||
|
$('#dynamicdns-gnudip').hide();
|
||||||
|
$('#id_dynamicdns-dynamicdns_server').val("");
|
||||||
|
$('#id_dynamicdns-dynamicdns_update_url').val("https://example.com/update.php?user=$user&pass=$pass&domain=$domain&IP=foo$ip");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$('#dynamicdns-post-enabled-form').hide('slow');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user