|
@@ -5,9 +5,19 @@
|
|
|
{{ parent() }}
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
+var $fixedIP = false;
|
|
|
+var $initHostTypeId = false;
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
+ {% if object.getFixedAddress() is not null or object.getFixedAddress() != "" %}
|
|
|
+ $fixedIP = "{{object.getFixedAddress()}}";
|
|
|
+ {% endif %}
|
|
|
+
|
|
|
+ {% if object.getHostType() is not null %}
|
|
|
+ $initHostTypeId = {{object.getHostType().getId()}};
|
|
|
+ {% endif %}
|
|
|
+
|
|
|
showHostField();
|
|
|
|
|
|
$("select[id$='hostType']").on('change', showHostField);
|
|
@@ -35,25 +45,31 @@ function updateFixedIPs()
|
|
|
var $hostTypeField = $("select[id$='hostType'] :selected");
|
|
|
var $hostTypeId = $hostTypeField.val();
|
|
|
|
|
|
- if ($hostTypeId) {
|
|
|
- $.ajax({
|
|
|
- url: '{{ path ('post_host_ipv4_range') }}',
|
|
|
- type: 'POST',
|
|
|
- data: {
|
|
|
- id: $hostTypeId,
|
|
|
- },
|
|
|
- success: function(data) {
|
|
|
- $('select[id$="_fixed_address"]').html('<option value=""></option>');
|
|
|
- if (data.ips) {
|
|
|
- $.each(data.ips, function (index, value) {
|
|
|
- $('select[id$="_fixed_address"]').append('<option value="' + value + '">' + value + '</option>');
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
- },
|
|
|
- });
|
|
|
+ var option = '<option value=""></option>';
|
|
|
+
|
|
|
+ if (($hostTypeId == $initHostTypeId) && $fixedIP != false) {
|
|
|
+ option = `<option value="${$fixedIP}" selected>${$fixedIP}</option>`;
|
|
|
+ $("div[id$='_fixed_address'] a span.select2-chosen").html($fixedIP);
|
|
|
+ } else {
|
|
|
+ $("div[id$='_fixed_address'] a span.select2-chosen").html('');
|
|
|
}
|
|
|
+
|
|
|
+ $.ajax({
|
|
|
+ url: '{{ path ('post_host_ipv4_range') }}',
|
|
|
+ type: 'POST',
|
|
|
+ data: {id: $hostTypeId},
|
|
|
+ success: function(data) {
|
|
|
+
|
|
|
+ $('select[id$="_fixed_address"]').html(option);
|
|
|
+ if (data.ips) {
|
|
|
+ $.each(data.ips, function (index, value) {
|
|
|
+ $('select[id$="_fixed_address"]').append('<option value="' + value + '">' + value + '</option>');
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
</script>
|