mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Convert table config updates to use REST API
This commit is contained in:
25
netbox/project-static/js/tableconfig.js
Normal file
25
netbox/project-static/js/tableconfig.js
Normal file
@@ -0,0 +1,25 @@
|
||||
$(document).ready(function() {
|
||||
$('form.tableconfigform').submit(function(event) {
|
||||
event.preventDefault();
|
||||
let table_name = this.getAttribute('data-table-name');
|
||||
let data = {"tables": {}};
|
||||
data['tables'][table_name] = {};
|
||||
data['tables'][table_name]['columns'] = $('#id_columns').val();
|
||||
$.ajax({
|
||||
url: netbox_api_path + 'users/config/',
|
||||
async: true,
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
type: 'PATCH',
|
||||
beforeSend: function(xhr, settings) {
|
||||
xhr.setRequestHeader("X-CSRFToken", netbox_csrf_token);
|
||||
},
|
||||
data: JSON.stringify(data),
|
||||
}).done(function () {
|
||||
// Reload the page
|
||||
window.location.reload(true);
|
||||
}).fail(function (xhr, status, error) {
|
||||
alert("Failed: " + error);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user