Update for support of netbox deployments, which are not in the webserver root (e.g. /netbox/)

This commit is contained in:
Johannes Kreuzer
2020-05-14 15:52:47 +02:00
parent d608d63207
commit 8a6f1660f0
2 changed files with 11 additions and 11 deletions
+4 -4
View File
@@ -66,12 +66,12 @@ class SearchViewSet(ViewSet):
node = {}
node["id"] = device.id
node["name"] = device.name
node["label"] = device.name + device.device_type.display_name
node["label"] = device.name + " " + device.device_type.display_name
node["shape"] = 'image'
if device.device_role.slug in settings.PLUGINS_CONFIG["netbox_topology_views"]["device_img"]:
node["image"] = '/static/netbox_topology_views/img/' + device.device_role.slug + ".png"
node["image"] = '../../static/netbox_topology_views/img/' + device.device_role.slug + ".png"
else:
node["image"] = "/static/netbox_topology_views/img/role-unknown.png"
node["image"] = "../../static/netbox_topology_views/img/role-unknown.png"
for device_custom_field in device.custom_field_values.all():
if device_custom_field.field.name == "coordinates":
@@ -86,4 +86,4 @@ class SearchViewSet(ViewSet):
results["nodes"] = nodes
results["edges"] = edges
return Response(results)
return Response(results)
+7 -7
View File
@@ -11,7 +11,7 @@ var options = {
},
nodes: {
shape: 'image',
brokenImage: '/static/netbox_topology_views/img/role-unknown.png',
brokenImage: '../../static/netbox_topology_views/img/role-unknown.png',
size: 35,
font: {
multi: 'md',
@@ -46,7 +46,7 @@ function startLoadSearchBar() {
theme: "bootstrap",
multiple: true,
ajax: {
url: "/api/dcim/device-roles/?brief=true",
url: "../../api/dcim/device-roles/?brief=true",
dataType: "json",
type: "GET",
data: function (params) {
@@ -73,7 +73,7 @@ function startLoadSearchBar() {
theme: "bootstrap",
multiple: true,
ajax: {
url: "/api/dcim/sites/?brief=true",
url: "../../api/dcim/sites/?brief=true",
dataType: "json",
type: "GET",
data: function (params) {
@@ -99,7 +99,7 @@ function startLoadSearchBar() {
var deviceRolesSelect = $('#device-roles');
$.ajax({
type: 'GET',
url: '/api/plugins/topology-views/preselectdeviceroles/'
url: '../../api/plugins/topology-views/preselectdeviceroles/'
}).then(function (data) {
$.each(data.results, function (index, device_role_to_preload) {
var option = new Option(device_role_to_preload.name, device_role_to_preload.id, true, true);
@@ -123,7 +123,7 @@ function handleButtonPress() {
var value3 = $("#sites").val();
$.ajax({
type: "POST",
url: "/api/plugins/topology-views/search/search/",
url: "../../api/plugins/topology-views/search/search/",
data: JSON.stringify({
'name': value,
'devicerole': value2,
@@ -157,7 +157,7 @@ function handleButtonPress() {
if ($('#checkSaveCoordinates').is(":checked")) {
nodes.update({ id: node_id, physics: false });
$.ajax({
url: "/api/save_coords",
url: "../../api/save_coords",
type: 'POST',
dataType: 'json',
headers: { "X-CSRFToken": csrftoken },
@@ -191,4 +191,4 @@ function handleButtonPress() {
},
});
});
}
}