Skip to content
Snippets Groups Projects
Commit fd380108 authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Set the IOC tag by default based on device type

JIRA INFRA-302
parent f3dcad2b
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,17 @@ $(document).ready(function() { ...@@ -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 check / uncheck random_mac checkbox
// and update default tags
function update_device_type_attributes() { function update_device_type_attributes() {
var device_type = $("#device_type_id option:selected").text(); var device_type = $("#device_type_id option:selected").text();
if( device_type.startsWith("Virtual") ) { if( device_type.startsWith("Virtual") ) {
...@@ -20,6 +30,7 @@ $(document).ready(function() { ...@@ -20,6 +30,7 @@ $(document).ready(function() {
} else { } else {
$("#random_mac").prop("checked", false).change(); $("#random_mac").prop("checked", false).change();
} }
update_default_tags(device_type);
} }
// If random_mac is checked, generate a random address // If random_mac is checked, generate a random address
...@@ -55,8 +66,8 @@ $(document).ready(function() { ...@@ -55,8 +66,8 @@ $(document).ready(function() {
set_default_ip(); set_default_ip();
}); });
// On register and edit host first page load // On register host first page load
if( $("#hostForm").length || $("#editHostForm").length ) { if( $("#hostForm").length ) {
update_device_type_attributes(); update_device_type_attributes();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment