+4
-2
@@ -1,6 +1,7 @@
|
|||||||
# Setup Dev
|
# Setup Dev
|
||||||
+ install docker
|
+ install docker
|
||||||
+ install docker compose
|
+ install docker compose
|
||||||
|
+ install npm
|
||||||
+ clone netbox repo
|
+ clone netbox repo
|
||||||
+ clone netbox_topology_views repo
|
+ clone netbox_topology_views repo
|
||||||
+ create venv: `/usr/bin/python3 -m venv venv`
|
+ create venv: `/usr/bin/python3 -m venv venv`
|
||||||
@@ -8,9 +9,10 @@
|
|||||||
+ install deps: `pip3 install -r requirements.txt`
|
+ install deps: `pip3 install -r requirements.txt`
|
||||||
+ install build tools: `python3 -m pip install --upgrade build setuptools wheel`
|
+ install build tools: `python3 -m pip install --upgrade build setuptools wheel`
|
||||||
|
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
+ in the root of the netbox_topology_views folder run `python3 -m build`
|
+ build the package: `python3 setup.py develop`
|
||||||
+ install the package: `python3 -m pip install ../netbox-topology-views/dist/netbox_topology_views-X.Y.Z-py3-none-any.whl` where X,Y & Z are the version
|
+ build the resources `npm run resources`
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
+ copy configuration.py from dev_setup to the netbox/netbox/ folder
|
+ copy configuration.py from dev_setup to the netbox/netbox/ folder
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class TopologyViewsConfig(PluginConfig):
|
|||||||
name = 'netbox_topology_views'
|
name = 'netbox_topology_views'
|
||||||
verbose_name = 'Topology views'
|
verbose_name = 'Topology views'
|
||||||
description = 'An plugin to render topology maps'
|
description = 'An plugin to render topology maps'
|
||||||
version = '0.5.0'
|
version = '0.5.1'
|
||||||
author = 'Mattijs Vanhaverbeke'
|
author = 'Mattijs Vanhaverbeke'
|
||||||
author_email = 'author@example.com'
|
author_email = 'author@example.com'
|
||||||
base_url = 'topology-views'
|
base_url = 'topology-views'
|
||||||
|
|||||||
@@ -115,6 +115,13 @@ class SearchViewSet(ReadOnlyModelViewSet):
|
|||||||
if regions == []:
|
if regions == []:
|
||||||
regions = None
|
regions = None
|
||||||
|
|
||||||
|
hide_unconnected = request.query_params.get('hide_unconnected', None)
|
||||||
|
if hide_unconnected == "":
|
||||||
|
hide_unconnected = None
|
||||||
|
print(hide_unconnected)
|
||||||
|
if hide_unconnected == 'false':
|
||||||
|
print("ok")
|
||||||
|
|
||||||
devices = self._filter(sites, devicerole, name, tags, regions)
|
devices = self._filter(sites, devicerole, name, tags, regions)
|
||||||
|
|
||||||
nodes = []
|
nodes = []
|
||||||
@@ -124,6 +131,8 @@ class SearchViewSet(ReadOnlyModelViewSet):
|
|||||||
circuit_ids = []
|
circuit_ids = []
|
||||||
for device in devices:
|
for device in devices:
|
||||||
cables = device.get_cables()
|
cables = device.get_cables()
|
||||||
|
if cables.exists():
|
||||||
|
device_has_connections = True
|
||||||
for cable in cables:
|
for cable in cables:
|
||||||
if cable.termination_a_type.name != "circuit termination" and cable.termination_b_type.name != "circuit termination":
|
if cable.termination_a_type.name != "circuit termination" and cable.termination_b_type.name != "circuit termination":
|
||||||
if cable.id not in cable_ids:
|
if cable.id not in cable_ids:
|
||||||
@@ -209,6 +218,10 @@ class SearchViewSet(ReadOnlyModelViewSet):
|
|||||||
title += cable_a_dev_name + " [" + cable_a_name + "]<br>"
|
title += cable_a_dev_name + " [" + cable_a_name + "]<br>"
|
||||||
edge["title"] = title
|
edge["title"] = title
|
||||||
edges.append(edge)
|
edges.append(edge)
|
||||||
|
else:
|
||||||
|
device_has_connections = False
|
||||||
|
|
||||||
|
if hide_unconnected == 'false' or (hide_unconnected == 'true' and device_has_connections is True):
|
||||||
dev_name = device.name
|
dev_name = device.name
|
||||||
if dev_name is None:
|
if dev_name is None:
|
||||||
dev_name = "device name unknown"
|
dev_name = "device name unknown"
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -232,6 +232,7 @@ function handleButtonPress() {
|
|||||||
var value3 = $("#sites").val();
|
var value3 = $("#sites").val();
|
||||||
var value4 = $("#tags").val();
|
var value4 = $("#tags").val();
|
||||||
var value5 = $("#regions").val();
|
var value5 = $("#regions").val();
|
||||||
|
var value6 = $('#checkHideUnconnected').is(":checked");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: "../../api/plugins/topology-views/search/search/",
|
url: "../../api/plugins/topology-views/search/search/",
|
||||||
@@ -240,7 +241,8 @@ function handleButtonPress() {
|
|||||||
'devicerole[]': value2,
|
'devicerole[]': value2,
|
||||||
'sites[]': value3,
|
'sites[]': value3,
|
||||||
'tags[]': value4,
|
'tags[]': value4,
|
||||||
'regions[]': value5
|
'regions[]': value5,
|
||||||
|
'hide_unconnected': value6
|
||||||
},
|
},
|
||||||
headers: { "X-CSRFToken": csrftoken },
|
headers: { "X-CSRFToken": csrftoken },
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
|
|||||||
@@ -53,6 +53,12 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="regions">Regions</label>
|
<label for="regions">Regions</label>
|
||||||
<select class="form-control" multiple="multiple" id="regions"></select>
|
<select class="form-control" multiple="multiple" id="regions"></select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="custom-control custom-checkbox">
|
||||||
|
<input type="checkbox" class="custom-control-input" id="checkHideUnconnected">
|
||||||
|
<label class="custom-control-label" for="checkHideUnconnected">Hide Unconnected</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr class="mb-4">
|
<hr class="mb-4">
|
||||||
<button class="btn btn-primary btn-lg btn-block" type="submit" id="start-search">Search</button>
|
<button class="btn btn-primary btn-lg btn-block" type="submit" id="start-search">Search</button>
|
||||||
|
|||||||
Generated
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "netbox_topology_views",
|
"name": "netbox_topology_views",
|
||||||
"version": "0.5.0",
|
"version": "0.5.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -4772,9 +4772,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"y18n": {
|
"y18n": {
|
||||||
"version": "3.2.1",
|
"version": "3.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.2.tgz",
|
||||||
"integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=",
|
"integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"yallist": {
|
"yallist": {
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "netbox_topology_views",
|
"name": "netbox_topology_views",
|
||||||
"version": "0.5.0",
|
"version": "0.5.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"resources": "gulp build",
|
"resources": "gulp build",
|
||||||
"resources_dev": "gulp build_dev"
|
"resources_dev": "gulp build_dev"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='netbox-topology-views',
|
name='netbox-topology-views',
|
||||||
version='0.5.0',
|
version='0.5.1',
|
||||||
description='An NetBox plugin to create Topology maps',
|
description='An NetBox plugin to create Topology maps',
|
||||||
url='https://github.com/mattieserver/netbox-topology-views',
|
url='https://github.com/mattieserver/netbox-topology-views',
|
||||||
author='Mattijs Vanhaverbeke',
|
author='Mattijs Vanhaverbeke',
|
||||||
|
|||||||
Reference in New Issue
Block a user