diff --git a/app/static/js/hosts.js b/app/static/js/hosts.js index 01e17b5495e6ed61223e19f5559760d8838cb263..9bfc6c6466416a5354234b7da4c83b0d028b1172 100644 --- a/app/static/js/hosts.js +++ b/app/static/js/hosts.js @@ -12,7 +12,17 @@ $(document).ready(function() { ); } + // Select the IOC tag by default depending on the device type + function update_default_tags(device_type) { + var ioc_device_types = ["PhysicalMachine", "VirtualMachine", "MicroTCA", "VME"]; + var is_ioc_selected = $.inArray(device_type, ioc_device_types) > -1; + $("#tags option").filter(function() { + return this.text == "IOC"; + }).prop("selected", is_ioc_selected).change(); + } + // And check / uncheck random_mac checkbox + // and update default tags function update_device_type_attributes() { var device_type = $("#device_type_id option:selected").text(); if( device_type.startsWith("Virtual") ) { @@ -20,6 +30,7 @@ $(document).ready(function() { } else { $("#random_mac").prop("checked", false).change(); } + update_default_tags(device_type); } // If random_mac is checked, generate a random address @@ -55,8 +66,8 @@ $(document).ready(function() { set_default_ip(); }); - // On register and edit host first page load - if( $("#hostForm").length || $("#editHostForm").length ) { + // On register host first page load + if( $("#hostForm").length ) { update_device_type_attributes(); }