Update for support of netbox deployments, which are not in the webserver root (e.g. /netbox/)
This commit is contained in:
@@ -66,12 +66,12 @@ class SearchViewSet(ViewSet):
|
|||||||
node = {}
|
node = {}
|
||||||
node["id"] = device.id
|
node["id"] = device.id
|
||||||
node["name"] = device.name
|
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'
|
node["shape"] = 'image'
|
||||||
if device.device_role.slug in settings.PLUGINS_CONFIG["netbox_topology_views"]["device_img"]:
|
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:
|
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():
|
for device_custom_field in device.custom_field_values.all():
|
||||||
if device_custom_field.field.name == "coordinates":
|
if device_custom_field.field.name == "coordinates":
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ var options = {
|
|||||||
},
|
},
|
||||||
nodes: {
|
nodes: {
|
||||||
shape: 'image',
|
shape: 'image',
|
||||||
brokenImage: '/static/netbox_topology_views/img/role-unknown.png',
|
brokenImage: '../../static/netbox_topology_views/img/role-unknown.png',
|
||||||
size: 35,
|
size: 35,
|
||||||
font: {
|
font: {
|
||||||
multi: 'md',
|
multi: 'md',
|
||||||
@@ -46,7 +46,7 @@ function startLoadSearchBar() {
|
|||||||
theme: "bootstrap",
|
theme: "bootstrap",
|
||||||
multiple: true,
|
multiple: true,
|
||||||
ajax: {
|
ajax: {
|
||||||
url: "/api/dcim/device-roles/?brief=true",
|
url: "../../api/dcim/device-roles/?brief=true",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
type: "GET",
|
type: "GET",
|
||||||
data: function (params) {
|
data: function (params) {
|
||||||
@@ -73,7 +73,7 @@ function startLoadSearchBar() {
|
|||||||
theme: "bootstrap",
|
theme: "bootstrap",
|
||||||
multiple: true,
|
multiple: true,
|
||||||
ajax: {
|
ajax: {
|
||||||
url: "/api/dcim/sites/?brief=true",
|
url: "../../api/dcim/sites/?brief=true",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
type: "GET",
|
type: "GET",
|
||||||
data: function (params) {
|
data: function (params) {
|
||||||
@@ -99,7 +99,7 @@ function startLoadSearchBar() {
|
|||||||
var deviceRolesSelect = $('#device-roles');
|
var deviceRolesSelect = $('#device-roles');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url: '/api/plugins/topology-views/preselectdeviceroles/'
|
url: '../../api/plugins/topology-views/preselectdeviceroles/'
|
||||||
}).then(function (data) {
|
}).then(function (data) {
|
||||||
$.each(data.results, function (index, device_role_to_preload) {
|
$.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);
|
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();
|
var value3 = $("#sites").val();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/api/plugins/topology-views/search/search/",
|
url: "../../api/plugins/topology-views/search/search/",
|
||||||
data: JSON.stringify({
|
data: JSON.stringify({
|
||||||
'name': value,
|
'name': value,
|
||||||
'devicerole': value2,
|
'devicerole': value2,
|
||||||
@@ -157,7 +157,7 @@ function handleButtonPress() {
|
|||||||
if ($('#checkSaveCoordinates').is(":checked")) {
|
if ($('#checkSaveCoordinates').is(":checked")) {
|
||||||
nodes.update({ id: node_id, physics: false });
|
nodes.update({ id: node_id, physics: false });
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/api/save_coords",
|
url: "../../api/save_coords",
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: { "X-CSRFToken": csrftoken },
|
headers: { "X-CSRFToken": csrftoken },
|
||||||
|
|||||||
Reference in New Issue
Block a user