Commit bb9f818b by Őry Máté

network: add magic buttons to HostForm

parent c3c23feb
...@@ -21,7 +21,7 @@ from django.utils.translation import ugettext_lazy as _ ...@@ -21,7 +21,7 @@ from django.utils.translation import ugettext_lazy as _
from crispy_forms.helper import FormHelper from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Fieldset, Div, Submit, BaseInput from crispy_forms.layout import Layout, Fieldset, Div, Submit, BaseInput
from crispy_forms.bootstrap import FormActions from crispy_forms.bootstrap import FormActions, AppendedText
from firewall.models import (Host, Vlan, Domain, Group, Record, BlacklistItem, from firewall.models import (Host, Vlan, Domain, Group, Record, BlacklistItem,
Rule, VlanGroup, SwitchPort) Rule, VlanGroup, SwitchPort)
...@@ -122,8 +122,10 @@ class HostForm(ModelForm): ...@@ -122,8 +122,10 @@ class HostForm(ModelForm):
Fieldset( Fieldset(
_('Network'), _('Network'),
'vlan', 'vlan',
'ipv4', AppendedText('ipv4',
'ipv6', '<i class="fa fa-magic" id="ipv4-magic"></i>'),
AppendedText('ipv6',
'<i class="fa fa-magic" id="ipv6-magic"></i>'),
'shared_ip', 'shared_ip',
'external_ipv4', 'external_ipv4',
), ),
......
...@@ -30,4 +30,23 @@ function getURLParameter(name) { ...@@ -30,4 +30,23 @@ function getURLParameter(name) {
$(function() { $(function() {
$("[title]").tooltip(); $("[title]").tooltip();
$("#ipv6-magic").click(function() {
$.ajax({url: window.location,
data: {ipv4: $("[name=ipv4]").val(),
vlan: $("[name=vlan]").val()},
success: function(data) {
$("[name=ipv6]").val(data["ipv6"]);
}});
});
$("#ipv4-magic").click(function() {
$.ajax({url: window.location,
data: {vlan: $("[name=vlan]").val()},
success: function(data) {
$("[name=ipv4]").val(data["ipv4"]);
if (!$("[name=ipv6]").val()) {
$("[name=ipv6]").val(data["ipv6"]);
}
}});
});
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment