1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

added logic to append &type=physical to interface API query for cable creation - #2585

This commit is contained in:
John Anderson
2018-11-14 23:35:15 -05:00
parent 641254b23a
commit 3c0181ef35
3 changed files with 36 additions and 3 deletions

View File

@ -91,8 +91,9 @@ $(document).ready(function() {
var filter_regex = /\{\{([a-z_]+)\}\}/g;
var match;
var rendered_url = api_url;
var filter_field;
while (match = filter_regex.exec(api_url)) {
var filter_field = $('#id_' + match[1]);
filter_field = $('#id_' + match[1]);
var custom_attr = $('option:selected', filter_field).attr('api-value');
if (custom_attr) {
rendered_url = rendered_url.replace(match[0], custom_attr);
@ -103,6 +104,20 @@ $(document).ready(function() {
}
}
// Account for any conditional URL append strings
$.each(child_field[0].attributes, function(index, attr){
if (attr.name.includes("data-url-conditional-append-")){
var conditional = attr.name.split("data-url-conditional-append-")[1].split("__");
var field = $("#id_" + conditional[0]);
var field_value = conditional[1];
console.log($('option:selected', field).attr('api-value'));
if ($('option:selected', field).attr('api-value') === field_value){
console.log(attr.value);
rendered_url = rendered_url + attr.value;
}
}
})
// If all URL variables have been replaced, make the API call
if (rendered_url.search('{{') < 0) {
console.log(child_name + ": Fetching " + rendered_url);