Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a57e1f79ab | ||
|
|
6e142bdb74 | ||
|
|
79cb8d8e2e | ||
|
|
1c9d4d8a1e | ||
|
|
6fc32b9bfa | ||
|
|
e0624effc2 | ||
|
|
fe94765c15 | ||
|
|
ffd91e2cf5 | ||
|
|
44e82c0286 | ||
|
|
33d7157b12 | ||
|
|
5c4c6be745 | ||
|
|
5e53066ba7 | ||
|
|
a1d155fdbc | ||
|
|
ab944fdcef | ||
|
|
f72ca57ac7 | ||
|
|
8a6f1660f0 | ||
|
|
d608d63207 | ||
|
|
4d161fe6ac | ||
|
|
c6a6893c10 | ||
|
|
b2430d1723 |
@@ -0,0 +1,201 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
@@ -1,17 +1,57 @@
|
|||||||
# netbox-topology-views
|
# Netbox Topology Views Plugin
|
||||||
|
|
||||||
## preview
|
Create topology views/maps from your devices in netbox.
|
||||||
|
Support to filter on name, site and device role.
|
||||||
|
|
||||||
|
## Preview
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## install
|
## Install
|
||||||
|
|
||||||
Add 'netbox_topology_views' to the PLUGINS array in your django configuration file.
|
Run `pip install netbox-topology-views` in your virtual env.
|
||||||
Then run python3 manage.py collectstatic --no-input
|
|
||||||
|
Add 'netbox_topology_views' to the PLUGINS array in your django configuration file.
|
||||||
|
|
||||||
|
Then run `python3 manage.py collectstatic --no-input`
|
||||||
|
|
||||||
|
### Custom field: coordinates
|
||||||
|
|
||||||
There is also support for custom fiels.
|
There is also support for custom fiels.
|
||||||
|
|
||||||
If you create a custom field "coordinates" for "dcim > device" with type "text" and name "coordinates" you will see the same layout every time.
|
If you create a custom field "coordinates" for "dcim > device" with type "text" and name "coordinates" you will see the same layout every time.
|
||||||
|
|
||||||
## use
|
The coordinates can then be provided as: "X;Y"
|
||||||
|
|
||||||
go to /plugins/topology-views/ view your topologies
|
## Configure
|
||||||
|
|
||||||
|
If you want to override the default values configure the `PLUGINS_CONFIG` in your `netbox configuration.py`.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
```
|
||||||
|
PLUGINS_CONFIG = {
|
||||||
|
'netbox_topology_views': {
|
||||||
|
'device_img': 'router,switch,firewall',
|
||||||
|
'preselected_device_roles': 'Router, Firewall'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| Setting | Default value | Description |
|
||||||
|
| ------------- |-------------| -----|
|
||||||
|
| device_img | 'access-switch,core-switch,firewall,router,distribution-switch,backup,storage,wan-network,wireless-ap,server,internal-switch,isp-cpe-material,non-racked-devices,power-units' | The slug of the device roles that you have a image for. |
|
||||||
|
| preselected_device_roles | 'Firewall,Router,Distribution Switch,Core Switch,Internal Switch,Access Switch,Server,Storage,Backup,Wireless AP' | The full name of the device roles you want to pre select in the global view. Note that this is case sensitive|
|
||||||
|
| allow_coordinates_saving | False | (bool) Set to true if you use the custom coordinates fields and want to save the coordinates |
|
||||||
|
| ignore_cable_type | 'power outlet,power port' | The cable types that you want to ignore in the views |
|
||||||
|
| preselected_tags | '' | The name of tags you want to preload |
|
||||||
|
|
||||||
|
|
||||||
|
### Custom Images
|
||||||
|
|
||||||
|
You upload you own custom images to the netbox static dir (`static/netbox_topology_views/img/`).
|
||||||
|
These images need to be named after de device role slug and have the .png format/extension.
|
||||||
|
If you add your own image you also need to add the slug to the `device_img` setting.
|
||||||
|
|
||||||
|
## Use
|
||||||
|
|
||||||
|
Go to the plugins tab in the navbar and click topology or go to NETBOX_URL/plugins/topology-views/ view your topologies
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ var jsVendorFiles = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
var cssVendorFiles = [
|
var cssVendorFiles = [
|
||||||
'node_modules/vis-network/styles/vis-network.min.css',
|
'node_modules/vis-network/dist/dist/vis-network.min.css',
|
||||||
];
|
];
|
||||||
var sassFiles = './netbox_topology_views/static_dev/css/*.scss',
|
var sassFiles = './netbox_topology_views/static_dev/css/*.scss',
|
||||||
cssDest = './netbox_topology_views/static/netbox_topology_views/css/';
|
cssDest = './netbox_topology_views/static/netbox_topology_views/css/';
|
||||||
|
|||||||
@@ -4,15 +4,17 @@ class TopologyViewsConfig(PluginConfig):
|
|||||||
name = 'netbox_topology_views'
|
name = 'netbox_topology_views'
|
||||||
verbose_name = 'Topology views'
|
verbose_name = 'Topology views'
|
||||||
description = 'An plugin to render toplogoy maps'
|
description = 'An plugin to render toplogoy maps'
|
||||||
version = '0.2'
|
version = '0.4.2'
|
||||||
author = 'Mattijs Vanhaverbeke'
|
author = 'Mattijs Vanhaverbeke'
|
||||||
author_email = 'author@example.com'
|
author_email = 'author@example.com'
|
||||||
base_url = 'topology-views'
|
base_url = 'topology-views'
|
||||||
required_settings = []
|
required_settings = []
|
||||||
default_settings = {
|
default_settings = {
|
||||||
'preselected_device_roles': 'Firewall,Router,Distribution Switch,Core Switch,Internal Switch,Access Switch,Server,Storage,Backup,Wireless AP',
|
'preselected_device_roles': 'Firewall,Router,Distribution Switch,Core Switch,Internal Switch,Access Switch,Server,Storage,Backup,Wireless AP',
|
||||||
'IGNORE_CABLE_TYPE': 'dcim.poweroutlet,dcim.powerport',
|
'ignore_cable_type': 'power outlet,power port',
|
||||||
'device_img': 'access-switch,core-switch,firewall,router,distribution-switch,backup,storage,wan-network,wireless-ap,server,internal-switch,isp-cpe-material,non-racked-devices,power-units'
|
'device_img': 'access-switch,core-switch,firewall,router,distribution-switch,backup,storage,wan-network,wireless-ap,server,internal-switch,isp-cpe-material,non-racked-devices,power-units',
|
||||||
|
'allow_coordinates_saving': False,
|
||||||
|
'preselected_tags' : ''
|
||||||
}
|
}
|
||||||
|
|
||||||
config = TopologyViewsConfig
|
config = TopologyViewsConfig
|
||||||
|
|||||||
@@ -1,10 +1,24 @@
|
|||||||
from rest_framework.serializers import ModelSerializer
|
from rest_framework.serializers import ModelSerializer
|
||||||
|
|
||||||
from dcim.models import DeviceRole
|
from dcim.models import DeviceRole, Device
|
||||||
|
from extras.models import Tag
|
||||||
|
|
||||||
class PreDeviceRoleSerializer(ModelSerializer):
|
class PreDeviceRoleSerializer(ModelSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = DeviceRole
|
model = DeviceRole
|
||||||
fields = ('id', 'name')
|
fields = ('id', 'name')
|
||||||
|
|
||||||
|
class PreTagSerializer(ModelSerializer):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Tag
|
||||||
|
fields = ('id', 'name')
|
||||||
|
|
||||||
|
|
||||||
|
class TopologyDummySerializer(ModelSerializer):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Device
|
||||||
|
fields = ('id', 'name')
|
||||||
|
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
from rest_framework import routers
|
from rest_framework import routers
|
||||||
|
|
||||||
from .views import PreSelectDeviceRolesViewSet, SearchViewSet
|
from .views import PreSelectDeviceRolesViewSet, SearchViewSet, SaveCoordsViewSet, PreSelectTagsViewSet
|
||||||
|
|
||||||
router = routers.DefaultRouter()
|
router = routers.DefaultRouter()
|
||||||
router.register('preselectdeviceroles', PreSelectDeviceRolesViewSet)
|
router.register('preselectdeviceroles', PreSelectDeviceRolesViewSet)
|
||||||
|
router.register('preselecttags', PreSelectTagsViewSet)
|
||||||
router.register('search', SearchViewSet, basename='search')
|
router.register('search', SearchViewSet, basename='search')
|
||||||
|
router.register('save-coords', SaveCoordsViewSet, basename='save_coords')
|
||||||
|
|
||||||
urlpatterns = router.urls
|
urlpatterns = router.urls
|
||||||
@@ -1,26 +1,88 @@
|
|||||||
from rest_framework.viewsets import ModelViewSet, ViewSet, ReadOnlyModelViewSet
|
from rest_framework.viewsets import ModelViewSet, ViewSet, ReadOnlyModelViewSet, GenericViewSet
|
||||||
from rest_framework.decorators import action
|
from rest_framework.decorators import action
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
|
||||||
from .serializers import PreDeviceRoleSerializer
|
from .serializers import PreDeviceRoleSerializer, TopologyDummySerializer, PreTagSerializer
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from utilities.api import IsAuthenticatedOrLoginNotRequired
|
from utilities.api import IsAuthenticatedOrLoginNotRequired
|
||||||
|
|
||||||
from dcim.models import DeviceRole, Device, Cable
|
from dcim.models import DeviceRole, Device, Cable
|
||||||
|
from extras.models import Tag, CustomField, CustomFieldValue
|
||||||
|
|
||||||
|
ignore_cable_type_raw = settings.PLUGINS_CONFIG["netbox_topology_views"]["ignore_cable_type"]
|
||||||
|
ignore_cable_type = ignore_cable_type_raw.split(",")
|
||||||
|
|
||||||
|
preselected_device_roles_raw = settings.PLUGINS_CONFIG["netbox_topology_views"]["preselected_device_roles"]
|
||||||
|
preselected_device_roles = preselected_device_roles_raw.split(",")
|
||||||
|
|
||||||
|
preselected_tags_raw = settings.PLUGINS_CONFIG["netbox_topology_views"]["preselected_tags"]
|
||||||
|
preselected_tags = preselected_tags_raw.split(",")
|
||||||
|
|
||||||
|
|
||||||
class PreSelectDeviceRolesViewSet(ReadOnlyModelViewSet):
|
class PreSelectDeviceRolesViewSet(ReadOnlyModelViewSet):
|
||||||
preselected_device_roles_raw = settings.PLUGINS_CONFIG["netbox_topology_views"]["preselected_device_roles"]
|
|
||||||
preselected_device_roles = preselected_device_roles_raw.split(",")
|
|
||||||
queryset = DeviceRole.objects.filter(name__in=preselected_device_roles)
|
queryset = DeviceRole.objects.filter(name__in=preselected_device_roles)
|
||||||
serializer_class = PreDeviceRoleSerializer
|
serializer_class = PreDeviceRoleSerializer
|
||||||
|
|
||||||
class SearchViewSet(ViewSet):
|
class PreSelectTagsViewSet(ReadOnlyModelViewSet):
|
||||||
_ignore_model_permissions = True
|
queryset = Tag.objects.filter(name__in=preselected_tags)
|
||||||
permission_classes = [IsAuthenticatedOrLoginNotRequired]
|
serializer_class = PreTagSerializer
|
||||||
|
|
||||||
def _filter(self, site, role, name):
|
class SaveCoordsViewSet(GenericViewSet):
|
||||||
|
queryset = Device.objects.all()
|
||||||
|
serializer_class = TopologyDummySerializer
|
||||||
|
|
||||||
|
@action(detail=False, methods=['post'])
|
||||||
|
def save_coords(self, request):
|
||||||
|
results = {}
|
||||||
|
if settings.PLUGINS_CONFIG["netbox_topology_views"]["allow_coordinates_saving"]:
|
||||||
|
try:
|
||||||
|
cfCoords = CustomField.objects.get(name='coordinates')
|
||||||
|
except CustomField.DoesNotExist:
|
||||||
|
results["status"] = "coords custom field not created"
|
||||||
|
return Response(status=500)
|
||||||
|
|
||||||
|
obj_type = ContentType.objects.get_for_model(Device)
|
||||||
|
|
||||||
|
device_id = None
|
||||||
|
x_coord = None
|
||||||
|
y_coord = None
|
||||||
|
if "node_id" in request.data:
|
||||||
|
if request.data["node_id"]:
|
||||||
|
device_id = request.data["node_id"]
|
||||||
|
if "x" in request.data:
|
||||||
|
if request.data["x"]:
|
||||||
|
x_coord = request.data["x"]
|
||||||
|
if "y" in request.data:
|
||||||
|
if request.data["y"]:
|
||||||
|
y_coord = request.data["y"]
|
||||||
|
|
||||||
|
actual_device= Device.objects.get(id=device_id)
|
||||||
|
try:
|
||||||
|
cfvCoords = CustomFieldValue.objects.get(obj_type=obj_type, obj_id=actual_device.pk, field__name='coordinates')
|
||||||
|
cfvCoords.value = "%s;%s" % (x_coord,y_coord)
|
||||||
|
cfvCoords.save()
|
||||||
|
results["status"] = "coords set"
|
||||||
|
except CustomFieldValue.DoesNotExist:
|
||||||
|
cfvCoords = CustomFieldValue(field=cfCoords, obj_type=obj_type, obj_id=actual_device.id)
|
||||||
|
cfvCoords.value = "%s;%s" % (x_coord,y_coord)
|
||||||
|
cfvCoords.save()
|
||||||
|
results["status"] = "coords set for first time"
|
||||||
|
|
||||||
|
return Response(results)
|
||||||
|
else:
|
||||||
|
results["status"] = "not allowed to save coords"
|
||||||
|
return Response(results, status=500)
|
||||||
|
|
||||||
|
class SearchViewSet(GenericViewSet):
|
||||||
|
#_ignore_model_permissions = True
|
||||||
|
#permission_classes = [IsAuthenticatedOrLoginNotRequired]
|
||||||
|
|
||||||
|
queryset = Device.objects.all()
|
||||||
|
serializer_class = TopologyDummySerializer
|
||||||
|
|
||||||
|
def _filter(self, site, role, name, tags):
|
||||||
filter_devices = Device.objects.all()
|
filter_devices = Device.objects.all()
|
||||||
if name is not None:
|
if name is not None:
|
||||||
filter_devices = filter_devices.filter(name__contains=name)
|
filter_devices = filter_devices.filter(name__contains=name)
|
||||||
@@ -28,6 +90,8 @@ class SearchViewSet(ViewSet):
|
|||||||
filter_devices = filter_devices.filter(site__id__in=site)
|
filter_devices = filter_devices.filter(site__id__in=site)
|
||||||
if role is not None:
|
if role is not None:
|
||||||
filter_devices = filter_devices.filter(device_role__id__in=role)
|
filter_devices = filter_devices.filter(device_role__id__in=role)
|
||||||
|
if tags is not None:
|
||||||
|
filter_devices = filter_devices.filter(tags__id__in=tags)
|
||||||
return filter_devices
|
return filter_devices
|
||||||
|
|
||||||
|
|
||||||
@@ -36,6 +100,7 @@ class SearchViewSet(ViewSet):
|
|||||||
name = None
|
name = None
|
||||||
sites = None
|
sites = None
|
||||||
devicerole = None
|
devicerole = None
|
||||||
|
tags = None
|
||||||
if "devicerole" in request.data:
|
if "devicerole" in request.data:
|
||||||
if request.data["devicerole"]:
|
if request.data["devicerole"]:
|
||||||
devicerole = request.data["devicerole"]
|
devicerole = request.data["devicerole"]
|
||||||
@@ -45,8 +110,12 @@ class SearchViewSet(ViewSet):
|
|||||||
if "name" in request.data:
|
if "name" in request.data:
|
||||||
if request.data["name"]:
|
if request.data["name"]:
|
||||||
name = request.data["name"]
|
name = request.data["name"]
|
||||||
|
if "tags" in request.data:
|
||||||
|
if request.data["tags"]:
|
||||||
|
tags = request.data["tags"]
|
||||||
|
|
||||||
|
devices = self._filter(sites, devicerole, name, tags)
|
||||||
|
|
||||||
devices = self._filter(sites, devicerole, name)
|
|
||||||
nodes = []
|
nodes = []
|
||||||
edges = []
|
edges = []
|
||||||
edge_ids = 0
|
edge_ids = 0
|
||||||
@@ -54,24 +123,29 @@ class SearchViewSet(ViewSet):
|
|||||||
for device in devices:
|
for device in devices:
|
||||||
cables = device.get_cables()
|
cables = device.get_cables()
|
||||||
for cable in cables:
|
for cable in cables:
|
||||||
if cable.id not in cable_ids:
|
if cable.termination_a_type.name != "circuit termination" and cable.termination_b_type.name != "circuit termination":
|
||||||
cable_ids.append(cable.id)
|
if cable.id not in cable_ids:
|
||||||
edge_ids += 1
|
if cable.termination_a_type.name not in ignore_cable_type and cable.termination_b_type.name not in ignore_cable_type:
|
||||||
edge = {}
|
cable_ids.append(cable.id)
|
||||||
edge["id"] = edge_ids
|
edge_ids += 1
|
||||||
edge["from"] = cable.termination_a.device.id
|
edge = {}
|
||||||
edge["to"] = cable.termination_b.device.id
|
edge["id"] = edge_ids
|
||||||
edge["title"] = "Connection between <br> " + cable.termination_a.device.name + " [" + cable.termination_a.name + "]<br>" + cable.termination_b.device.name + " [" + cable.termination_b.name + "]"
|
edge["from"] = cable.termination_a.device.id
|
||||||
edges.append(edge)
|
edge["to"] = cable.termination_b.device.id
|
||||||
|
edge["title"] = "Connection between <br> " + cable.termination_a.device.name + " [" + cable.termination_a.name + "]<br>" + cable.termination_b.device.name + " [" + cable.termination_b.name + "]"
|
||||||
|
edges.append(edge)
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
#circuittermination not supported for now
|
||||||
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":
|
||||||
@@ -86,4 +160,4 @@ class SearchViewSet(ViewSet):
|
|||||||
results["nodes"] = nodes
|
results["nodes"] = nodes
|
||||||
results["edges"] = edges
|
results["edges"] = edges
|
||||||
|
|
||||||
return Response(results)
|
return Response(results)
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
|||||||
var graph=null,container=null,csrftoken=null,nodes=new vis.DataSet,edges=new vis.DataSet,options={interaction:{hover:!0,hoverConnectedEdges:!0,multiselect:!0},nodes:{shape:"image",brokenImage:"/static/netbox_topology_views/img/role-unknown.png",size:35,font:{multi:"md",face:"helvetica"}},edges:{length:100,width:2,font:{face:"helvetica"}},physics:{solver:"forceAtlas2Based"}};function iniPlotboxIndex(){document.addEventListener("DOMContentLoaded",function(){container=document.getElementById("visgraph"),csrftoken=jQuery("[name=csrfmiddlewaretoken]").val(),startLoadSearchBar(),handleButtonPress()},!1)}function startLoadSearchBar(){$("#device-roles").select2({allowClear:!0,placeholder:"---------",theme:"bootstrap",multiple:!0,ajax:{url:"/api/dcim/device-roles/?brief=true",dataType:"json",type:"GET",data:function(e){return{term:e.term}},processResults:function(e){return{results:$.map(e.results,function(e){return{text:e.name,id:e.id}})}}}}),$("#sites").select2({allowClear:!0,placeholder:"---------",theme:"bootstrap",multiple:!0,ajax:{url:"/api/dcim/sites/?brief=true",dataType:"json",type:"GET",data:function(e){return{term:e.term}},processResults:function(e){return{results:$.map(e.results,function(e){return{text:e.name,id:e.id}})}}}});var n=$("#device-roles");$.ajax({type:"GET",url:"/api/plugins/topology-views/preselectdeviceroles/"}).then(function(e){$.each(e.results,function(e,t){var a=new Option(t.name,t.id,!0,!0);n.append(a).trigger("change"),n.trigger({type:"select2:select",params:{data:t}})})})}function handleButtonPress(){$("#search-form").submit(function(e){$("#status").html('<span class="badge badge-pill badge-info">Loading data</span>'),e.preventDefault();var t=$("#name").val(),a=$("#device-roles").val(),n=$("#sites").val();$.ajax({type:"POST",url:"/api/plugins/topology-views/search/search/",data:JSON.stringify({name:t,devicerole:a,sites:n}),headers:{"X-CSRFToken":csrftoken},contentType:"application/json; charset=utf-8",dataType:"json",success:function(e){$("#status").html('<span class="badge badge-pill badge-info">Drawing network</span>'),graph=null,nodes=new vis.DataSet,edges=new vis.DataSet,graph=new vis.Network(container,{nodes:nodes,edges:edges},options),$.each(e.nodes,function(e,t){nodes.add(t)}),$.each(e.edges,function(e,t){edges.add(t)}),graph.fit(),graph.on("afterDrawing",function(){$("#status").html('<span class="badge badge-pill badge-success">Ready</span>')}),graph.on("dragEnd",function(e){dragged=this.getPositions(e.nodes),$.each(dragged,function(e,t){$("#coordstatus").html(""),$("#checkSaveCoordinates").is(":checked")&&(nodes.update({id:e,physics:!1}),$.ajax({url:"/api/save_coords",type:"POST",dataType:"json",headers:{"X-CSRFToken":csrftoken},contentType:"application/json; charset=utf-8",data:JSON.stringify({node_id:e,x:t.x,y:t.y}),error:function(e){$("#coordstatus").html('<span class="badge badge-pill badge-warning">Failed to update coordinates</span>')},success:function(e){$("#coordstatus").html('<span class="badge badge-pill badge-success">Updated coordinates</span>'),$.ajax({url:"/api/reload_devices",type:"GET",headers:{"X-CSRFToken":csrftoken},success:function(e){}})}}))})})},error:function(e){$("#status").html('<span class="badge badge-pill badge-warning">Something went wrong</span>')}})})}
|
var graph=null,container=null,csrftoken=null,nodes=new vis.DataSet,edges=new vis.DataSet,options={interaction:{hover:!0,hoverConnectedEdges:!0,multiselect:!1},nodes:{shape:"image",brokenImage:"../../static/netbox_topology_views/img/role-unknown.png",size:35,font:{multi:"md",face:"helvetica"}},edges:{length:100,width:2,font:{face:"helvetica"}},physics:{solver:"forceAtlas2Based"}};function iniPlotboxIndex(){document.addEventListener("DOMContentLoaded",function(){container=document.getElementById("visgraph"),csrftoken=jQuery("[name=csrfmiddlewaretoken]").val(),startLoadSearchBar(),handleButtonPress()},!1)}function startLoadSearchBar(){$("#device-roles").select2({allowClear:!0,placeholder:"---------",theme:"bootstrap",multiple:!0,ajax:{url:"../../api/dcim/device-roles/?brief=true",dataType:"json",type:"GET",data:function(e){return{q:e.term}},processResults:function(e){return{results:$.map(e.results,function(e){return{text:e.name,id:e.id}})}}}}),$("#sites").select2({allowClear:!0,placeholder:"---------",theme:"bootstrap",multiple:!0,ajax:{url:"../../api/dcim/sites/?brief=true",dataType:"json",type:"GET",data:function(e){return{q:e.term}},processResults:function(e){return{results:$.map(e.results,function(e){return{text:e.name,id:e.id}})}}}}),$("#tags").select2({allowClear:!0,placeholder:"---------",theme:"bootstrap",multiple:!0,ajax:{url:"../../api/extras/tags/?brief=true",dataType:"json",type:"GET",data:function(e){return{q:e.term}},processResults:function(e){return{results:$.map(e.results,function(e){return{text:e.name,id:e.id}})}}}});var s=$("#device-roles");$.ajax({type:"GET",url:"../../api/plugins/topology-views/preselectdeviceroles/"}).then(function(e){$.each(e.results,function(e,t){var a=new Option(t.name,t.id,!0,!0);s.append(a).trigger("change"),s.trigger({type:"select2:select",params:{data:t}})})});var n=$("#tags");$.ajax({type:"GET",url:"../../api/plugins/topology-views/preselecttags/"}).then(function(e){$.each(e.results,function(e,t){var a=new Option(t.name,t.id,!0,!0);n.append(a).trigger("change"),n.trigger({type:"select2:select",params:{data:t}})})})}function handleButtonPress(){$("#search-form").submit(function(e){$("#status").html('<span class="label label-info">Loading data</span>'),e.preventDefault();var t=$("#name").val(),a=$("#device-roles").val(),s=$("#sites").val(),n=$("#tags").val();$.ajax({type:"POST",url:"../../api/plugins/topology-views/search/search/",data:JSON.stringify({name:t,devicerole:a,sites:s,tags:n}),headers:{"X-CSRFToken":csrftoken},contentType:"application/json; charset=utf-8",dataType:"json",success:function(e){$("#status").html('<span class="label label-info">Drawing network</span>'),graph=null,nodes=new vis.DataSet,edges=new vis.DataSet,graph=new vis.Network(container,{nodes:nodes,edges:edges},options),$.each(e.nodes,function(e,t){nodes.add(t)}),$.each(e.edges,function(e,t){edges.add(t)}),graph.fit(),graph.on("afterDrawing",function(){$("#status").html('<span class="label label-success">Ready</span>')}),graph.on("dragEnd",function(e){dragged=this.getPositions(e.nodes),$.each(dragged,function(e,t){$("#coordstatus").html(""),$("#checkSaveCoordinates").is(":checked")&&$.ajax({url:"../../api/plugins/topology-views/save-coords/save_coords/",type:"POST",dataType:"json",headers:{"X-CSRFToken":csrftoken},contentType:"application/json; charset=utf-8",data:JSON.stringify({node_id:e,x:t.x,y:t.y}),error:function(e){$("#coordstatus").html('<span class="label label-warning">Failed to update coordinates</span>')},success:function(e){$("#coordstatus").html('<span class="label label-success">Updated coordinates</span>')}})})})},error:function(e){$("#status").html('<span class="label label-warning">Something went wrong</span>')}})})}
|
||||||
File diff suppressed because one or more lines are too long
@@ -7,11 +7,11 @@ var options = {
|
|||||||
interaction: {
|
interaction: {
|
||||||
hover: true,
|
hover: true,
|
||||||
hoverConnectedEdges: true,
|
hoverConnectedEdges: true,
|
||||||
multiselect: true
|
multiselect: false
|
||||||
},
|
},
|
||||||
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,12 +46,12 @@ 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) {
|
||||||
var queryParameters = {
|
var queryParameters = {
|
||||||
term: params.term
|
q: params.term
|
||||||
}
|
}
|
||||||
return queryParameters;
|
return queryParameters;
|
||||||
},
|
},
|
||||||
@@ -73,13 +73,40 @@ 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) {
|
||||||
|
|
||||||
var queryParameters = {
|
var queryParameters = {
|
||||||
term: params.term
|
q: params.term
|
||||||
|
}
|
||||||
|
return queryParameters;
|
||||||
|
},
|
||||||
|
processResults: function (data) {
|
||||||
|
return {
|
||||||
|
results: $.map(data.results, function (item) {
|
||||||
|
return {
|
||||||
|
text: item.name,
|
||||||
|
id: item.id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#tags').select2({
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: "---------",
|
||||||
|
theme: "bootstrap",
|
||||||
|
multiple: true,
|
||||||
|
ajax: {
|
||||||
|
url: "../../api/extras/tags/?brief=true",
|
||||||
|
dataType: "json",
|
||||||
|
type: "GET",
|
||||||
|
data: function (params) {
|
||||||
|
var queryParameters = {
|
||||||
|
q: params.term
|
||||||
}
|
}
|
||||||
return queryParameters;
|
return queryParameters;
|
||||||
},
|
},
|
||||||
@@ -99,7 +126,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);
|
||||||
@@ -112,28 +139,47 @@ function startLoadSearchBar() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var tagsSelect = $('#tags');
|
||||||
|
$.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: '../../api/plugins/topology-views/preselecttags/'
|
||||||
|
}).then(function (data) {
|
||||||
|
$.each(data.results, function (index, tags_to_preload) {
|
||||||
|
var option = new Option(tags_to_preload.name, tags_to_preload.id, true, true);
|
||||||
|
tagsSelect.append(option).trigger('change');
|
||||||
|
tagsSelect.trigger({
|
||||||
|
type: 'select2:select',
|
||||||
|
params: {
|
||||||
|
data: tags_to_preload
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleButtonPress() {
|
function handleButtonPress() {
|
||||||
$("#search-form").submit(function (event) {
|
$("#search-form").submit(function (event) {
|
||||||
$("#status").html('<span class="badge badge-pill badge-info">Loading data</span>');
|
$("#status").html('<span class="label label-info">Loading data</span>');
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var value = $("#name").val();
|
var value = $("#name").val();
|
||||||
var value2 = $("#device-roles").val();
|
var value2 = $("#device-roles").val();
|
||||||
var value3 = $("#sites").val();
|
var value3 = $("#sites").val();
|
||||||
|
var value4 = $("#tags").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,
|
||||||
'sites': value3
|
'sites': value3,
|
||||||
|
'tags': value4
|
||||||
}),
|
}),
|
||||||
headers: { "X-CSRFToken": csrftoken },
|
headers: { "X-CSRFToken": csrftoken },
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (data_result) {
|
success: function (data_result) {
|
||||||
$("#status").html('<span class="badge badge-pill badge-info">Drawing network</span>');
|
$("#status").html('<span class="label label-info">Drawing network</span>');
|
||||||
graph = null;
|
graph = null;
|
||||||
nodes = new vis.DataSet();
|
nodes = new vis.DataSet();
|
||||||
edges = new vis.DataSet();
|
edges = new vis.DataSet();
|
||||||
@@ -147,7 +193,7 @@ function handleButtonPress() {
|
|||||||
graph.fit();
|
graph.fit();
|
||||||
|
|
||||||
graph.on('afterDrawing', function () {
|
graph.on('afterDrawing', function () {
|
||||||
$("#status").html('<span class="badge badge-pill badge-success">Ready</span>');
|
$("#status").html('<span class="label label-success">Ready</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
graph.on("dragEnd", function (params) {
|
graph.on("dragEnd", function (params) {
|
||||||
@@ -155,9 +201,9 @@ function handleButtonPress() {
|
|||||||
$.each(dragged, function (node_id, coordinates) {
|
$.each(dragged, function (node_id, coordinates) {
|
||||||
$("#coordstatus").html('');
|
$("#coordstatus").html('');
|
||||||
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/plugins/topology-views/save-coords/save_coords/",
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
headers: { "X-CSRFToken": csrftoken },
|
headers: { "X-CSRFToken": csrftoken },
|
||||||
@@ -168,18 +214,10 @@ function handleButtonPress() {
|
|||||||
'y': coordinates.y
|
'y': coordinates.y
|
||||||
}),
|
}),
|
||||||
error: function (error_result) {
|
error: function (error_result) {
|
||||||
$("#coordstatus").html('<span class="badge badge-pill badge-warning">Failed to update coordinates</span>');
|
$("#coordstatus").html('<span class="label label-warning">Failed to update coordinates</span>');
|
||||||
},
|
},
|
||||||
success: function (data_result) {
|
success: function (data_result) {
|
||||||
$("#coordstatus").html('<span class="badge badge-pill badge-success">Updated coordinates</span>');
|
$("#coordstatus").html('<span class="label label-success">Updated coordinates</span>');
|
||||||
$.ajax({
|
|
||||||
url: '/api/reload_devices',
|
|
||||||
type: 'GET',
|
|
||||||
headers: { "X-CSRFToken": csrftoken },
|
|
||||||
success: function (data) {
|
|
||||||
//nothing
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -187,8 +225,8 @@ function handleButtonPress() {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: function (error_result) {
|
error: function (error_result) {
|
||||||
$("#status").html('<span class="badge badge-pill badge-warning">Something went wrong</span>');
|
$("#status").html('<span class="label label-warning">Something went wrong</span>');
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<strong>Search</strong>
|
<strong>Search</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<form id="search-form" class="form">
|
<form id="search-form" class="form" autocomplete="off">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name">Name</label>
|
<label for="name">Name</label>
|
||||||
@@ -37,6 +37,10 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="sites">Sites</label>
|
<label for="sites">Sites</label>
|
||||||
<select class="form-control" multiple="multiple" id="sites"></select>
|
<select class="form-control" multiple="multiple" id="sites"></select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="tags">Tags</label>
|
||||||
|
<select class="form-control" multiple="multiple" id="tags"></select>
|
||||||
</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>
|
||||||
@@ -45,6 +49,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% if config.allow_coordinates_saving == True %}
|
||||||
<div class="panel panel-default mt-3">
|
<div class="panel panel-default mt-3">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<strong>Settings</strong>
|
<strong>Settings</strong>
|
||||||
@@ -59,6 +64,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
from django.shortcuts import get_object_or_404, render
|
from django.shortcuts import get_object_or_404, render
|
||||||
from django.views.generic import View
|
from django.views.generic import View
|
||||||
|
from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||||
|
|
||||||
|
class TopologyHomeView(PermissionRequiredMixin, View):
|
||||||
|
permission_required = ('dcim.view_site', 'dcim.view_device')
|
||||||
|
|
||||||
class TopologyHomeView(View):
|
|
||||||
"""
|
"""
|
||||||
Show the home page
|
Show the home page
|
||||||
"""
|
"""
|
||||||
|
|||||||
+2
-4
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "netbox_topology_views",
|
"name": "netbox_topology_views",
|
||||||
"version": "0.2",
|
"version": "0.4.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"resources": "gulp build",
|
"resources": "gulp build",
|
||||||
"resources_dev": "gulp build_dev"
|
"resources_dev": "gulp build_dev"
|
||||||
@@ -13,8 +13,6 @@
|
|||||||
"gulp-concat": "^2.6.1",
|
"gulp-concat": "^2.6.1",
|
||||||
"gulp-sass": "^4.0.2",
|
"gulp-sass": "^4.0.2",
|
||||||
"gulp-uglify": "^3.0.2",
|
"gulp-uglify": "^3.0.2",
|
||||||
"vis-data": "^6.2.3",
|
"vis-network": "^7.6.4"
|
||||||
"vis-util": "^1.1.8",
|
|
||||||
"vis-network": "^6.4.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='netbox-topology-views',
|
name='netbox-topology-views',
|
||||||
version='0.2',
|
version='0.4.2',
|
||||||
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