added base functions and api

This commit is contained in:
mattijs vanhaverbeke
2020-04-16 14:22:42 +02:00
parent a4807b306b
commit ac76d70c57
11 changed files with 111 additions and 25 deletions
+8 -8
View File
@@ -11,7 +11,7 @@ var options = {
},
nodes: {
shape: 'image',
brokenImage: '/static/assets/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/device_roles",
url: "/api/dcim/device-roles/?brief=true",
dataType: "json",
type: "GET",
data: function (params) {
@@ -57,7 +57,7 @@ function startLoadSearchBar() {
},
processResults: function (data) {
return {
results: $.map(data, function (item) {
results: $.map(data.results, function (item) {
return {
text: item.name,
id: item.id
@@ -73,7 +73,7 @@ function startLoadSearchBar() {
theme: "bootstrap",
multiple: true,
ajax: {
url: "/api/sites",
url: "/api/dcim/sites/?brief=true",
dataType: "json",
type: "GET",
data: function (params) {
@@ -85,7 +85,7 @@ function startLoadSearchBar() {
},
processResults: function (data) {
return {
results: $.map(data, function (item) {
results: $.map(data.results, function (item) {
return {
text: item.name,
id: item.id
@@ -99,9 +99,9 @@ function startLoadSearchBar() {
var deviceRolesSelect = $('#device-roles');
$.ajax({
type: 'GET',
url: '/api/preselect_device_roles'
url: '/api/plugins/topology-views/preselectdeviceroles/'
}).then(function (data) {
$.each(data.data, 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);
deviceRolesSelect.append(option).trigger('change');
deviceRolesSelect.trigger({
@@ -123,7 +123,7 @@ function handleButtonPress() {
var value3 = $("#sites").val();
$.ajax({
type: "POST",
url: "/api/search",
url: "/api/plugins/topology-views/search/search/",
data: JSON.stringify({
'name': value,
'devicerole': value2,