mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-25 14:47:46 -06:00
Merge v2.5 work
This commit is contained in:
@@ -429,6 +429,10 @@ table.report th a {
|
||||
}
|
||||
|
||||
/* Misc */
|
||||
.color-block {
|
||||
display: block;
|
||||
width: 80px;
|
||||
}
|
||||
.text-nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
24
netbox/project-static/js/cabletrace.js
Normal file
24
netbox/project-static/js/cabletrace.js
Normal file
@@ -0,0 +1,24 @@
|
||||
$('#cabletrace_modal').on('show.bs.modal', function (event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var obj = button.data('obj');
|
||||
var url = button.data('url');
|
||||
var modal_title = $(this).find('.modal-title');
|
||||
var modal_body = $(this).find('.modal-body');
|
||||
modal_title.text(obj);
|
||||
modal_body.empty();
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
success: function(json) {
|
||||
$.each(json, function(i, segment) {
|
||||
modal_body.append(
|
||||
'<div class="row">' +
|
||||
'<div class="col-md-4 text-center">' + segment[0].device.name + '<br />' + segment[0].name + '</div>' +
|
||||
'<div class="col-md-4 text-center">Cable #' + segment[1].id + '</div>' +
|
||||
'<div class="col-md-4 text-center">' + segment[2].device.name + '<br />' + segment[2].name + '</div>' +
|
||||
'</div><hr />'
|
||||
);
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -91,15 +91,31 @@ $(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]);
|
||||
if (filter_field.val()) {
|
||||
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);
|
||||
} else if (filter_field.val()) {
|
||||
rendered_url = rendered_url.replace(match[0], filter_field.val());
|
||||
} else if (filter_field.attr('nullable') == 'true') {
|
||||
rendered_url = rendered_url.replace(match[0], '0');
|
||||
}
|
||||
}
|
||||
|
||||
// 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];
|
||||
if ($('option:selected', field).attr('api-value') === field_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);
|
||||
|
||||
@@ -42,8 +42,8 @@ $(document).ready(function() {
|
||||
event.preventDefault();
|
||||
search_field.val(ui.item.label);
|
||||
select_fields.val('');
|
||||
select_fields.attr('disabled', 'disabled');
|
||||
real_field.empty();
|
||||
select_fields.attr('disabled', 'disabled');
|
||||
real_field.append($("<option></option>").attr('value', ui.item.value).text(ui.item.label));
|
||||
real_field.change();
|
||||
// Disable parent selection fields
|
||||
|
||||
Reference in New Issue
Block a user