15 files changed
+393
-52
No files matched your search
@@ -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.
|
||||
@@ -18,8 +18,11 @@ Then run `python3 manage.py collectstatic --no-input`
|
||||
### Custom field: coordinates
|
||||
|
||||
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.
|
||||
|
||||
The coordinates can then be provided as: "X;Y"
|
||||
|
||||
## Configure
|
||||
|
||||
If you want to override the default values configure the `PLUGINS_CONFIG` in your `netbox configuration.py`.
|
||||
@@ -37,7 +40,11 @@ PLUGINS_CONFIG = {
|
||||
| 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. |
|
||||
| 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 | 'poweroutlet,powerport' | The cable types that you want to ignore in the views |
|
||||
| preselected_tags | '' | The name of tags you want to preload |
|
||||
|
||||
|
||||
### Custom Images
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ var jsVendorFiles = [
|
||||
];
|
||||
|
||||
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',
|
||||
cssDest = './netbox_topology_views/static/netbox_topology_views/css/';
|
||||
|
||||
@@ -4,15 +4,17 @@ class TopologyViewsConfig(PluginConfig):
|
||||
name = 'netbox_topology_views'
|
||||
verbose_name = 'Topology views'
|
||||
description = 'An plugin to render toplogoy maps'
|
||||
version = '0.3'
|
||||
version = '0.4.0'
|
||||
author = 'Mattijs Vanhaverbeke'
|
||||
author_email = '[email protected]'
|
||||
base_url = 'topology-views'
|
||||
required_settings = []
|
||||
default_settings = {
|
||||
'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',
|
||||
'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'
|
||||
'ignore_cable_type': 'poweroutlet,powerport',
|
||||
'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
|
||||
@@ -1,10 +1,24 @@
|
||||
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 Meta:
|
||||
model = DeviceRole
|
||||
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 .views import PreSelectDeviceRolesViewSet, SearchViewSet
|
||||
from .views import PreSelectDeviceRolesViewSet, SearchViewSet, SaveCoordsViewSet, PreSelectTagsViewSet
|
||||
|
||||
router = routers.DefaultRouter()
|
||||
router.register('preselectdeviceroles', PreSelectDeviceRolesViewSet)
|
||||
router.register('preselecttags', PreSelectTagsViewSet)
|
||||
router.register('search', SearchViewSet, basename='search')
|
||||
router.register('save-coords', SaveCoordsViewSet, basename='save_coords')
|
||||
|
||||
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.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 utilities.api import IsAuthenticatedOrLoginNotRequired
|
||||
|
||||
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):
|
||||
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)
|
||||
serializer_class = PreDeviceRoleSerializer
|
||||
|
||||
class SearchViewSet(ViewSet):
|
||||
_ignore_model_permissions = True
|
||||
permission_classes = [IsAuthenticatedOrLoginNotRequired]
|
||||
class PreSelectTagsViewSet(ReadOnlyModelViewSet):
|
||||
queryset = Tag.objects.filter(name__in=preselected_tags)
|
||||
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()
|
||||
if name is not None:
|
||||
filter_devices = filter_devices.filter(name__contains=name)
|
||||
@@ -28,6 +90,8 @@ class SearchViewSet(ViewSet):
|
||||
filter_devices = filter_devices.filter(site__id__in=site)
|
||||
if role is not None:
|
||||
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
|
||||
|
||||
|
||||
@@ -36,6 +100,7 @@ class SearchViewSet(ViewSet):
|
||||
name = None
|
||||
sites = None
|
||||
devicerole = None
|
||||
tags = None
|
||||
if "devicerole" in request.data:
|
||||
if request.data["devicerole"]:
|
||||
devicerole = request.data["devicerole"]
|
||||
@@ -45,8 +110,12 @@ class SearchViewSet(ViewSet):
|
||||
if "name" in request.data:
|
||||
if 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 = []
|
||||
edges = []
|
||||
edge_ids = 0
|
||||
@@ -55,14 +124,15 @@ class SearchViewSet(ViewSet):
|
||||
cables = device.get_cables()
|
||||
for cable in cables:
|
||||
if cable.id not in cable_ids:
|
||||
cable_ids.append(cable.id)
|
||||
edge_ids += 1
|
||||
edge = {}
|
||||
edge["id"] = edge_ids
|
||||
edge["from"] = cable.termination_a.device.id
|
||||
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)
|
||||
if cable.termination_a_type.name not in ignore_cable_type:
|
||||
cable_ids.append(cable.id)
|
||||
edge_ids += 1
|
||||
edge = {}
|
||||
edge["id"] = edge_ids
|
||||
edge["from"] = cable.termination_a.device.id
|
||||
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)
|
||||
node = {}
|
||||
node["id"] = device.id
|
||||
node["name"] = device.name
|
||||
|
||||
@@ -1 +1 @@
|
||||
.vis-overlay{position:absolute;top:0;right:0;bottom:0;left:0;z-index:10}.vis-active{box-shadow:0 0 10px #86d5f8}div.vis-network div.vis-navigation div.vis-button{width:34px;height:34px;-moz-border-radius:17px;border-radius:17px;position:absolute;display:inline-block;background-position:2px 2px;background-repeat:no-repeat;cursor:pointer;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}div.vis-network div.vis-navigation div.vis-button:hover{box-shadow:0 0 3px 3px rgba(56,207,21,.3)}div.vis-network div.vis-navigation div.vis-button:active{box-shadow:0 0 1px 3px rgba(56,207,21,.95)}div.vis-network div.vis-navigation div.vis-button.vis-up{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3N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qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAABphJREFUeNqcV2twU9cR/nbPlVTHxpKRbNnBLyEbPyJisLEcPwgwUMKQtjNJAzNJZkgNNJOmJaZAaDKlxaXDTIBAcJtOOzSYKSkdiimhAdIMjyT4bYgBYxA2BgcUQPLrCiGDR4qt2x+yXTASFt1/957d7zt3z3d39xDCMQWUfgAz/RI/T4pSTAJpAGL8rECAXX7QFQGq9wOHOxYO1oCgjAdJj1wtB095Giv9TFuZAIWHAziATMPhTAwiHgUkYPXFJu92lMP/2MTpB1AKUCVEgNAcleUo1M+2F8TO6crSTncb1QleAOj2OTSX3Ge1p+Va42m5JrnzbnsCE8Ov+EHgpa0LPLvCJjZ/whuIlN8wAcXG+e1LUn9hm238QU84p1Ld83nsXvuO7Lq+LzKYGAT6/dn58m/HJTYf4O3EShkT8Irpzab1Uz9sGevT5+tWn+j6NB4A5hp/5NSr43xjfd5rW5tT9e3OAhCBiCua5/WsDEls/hdvYklZSwDefmrT8eXmtzuDkb5YZ33p9ndylICAVjWxf39xw/5g5Luv/9H84ZWNcwNLine truncated
|
||||
.vis-overlay{position:absolute;top:0;right:0;bottom:0;left:0;z-index:10}.vis-active{box-shadow:0 0 10px #86d5f8}div.vis-configuration{position:relative;display:block;float:left;font-size:12px}div.vis-configuration-wrapper{display:block;width:700px}div.vis-configuration-wrapper:after{clear:both;content:"";display:block}div.vis-configuration.vis-config-option-container{display:block;width:495px;background-color:#fff;border:2px solid #f7f8fa;border-radius:4px;margin-top:20px;left:10px;padding-left:5px}div.vis-configuration.vis-config-button{display:block;width:495px;height:25px;vertical-align:middle;line-height:25px;background-color:#f7f8fa;border:2px solid #ceced0;border-radius:4px;margin-top:20px;left:10px;padding-left:5px;cursor:pointer;margin-bottom:30px}div.vis-configuration.vis-config-button.hover{background-color:#4588e6;border:2px solid #214373;color:#fff}div.vis-configuration.vis-config-item{display:block;float:left;width:495px;height:25px;vertical-align:middle;line-height:25px}div.vis-configuration.vis-config-item.vis-config-s2{left:10px;background-color:#f7f8fa;padding-left:5px;border-radius:3px}div.vis-configuration.vis-config-item.vis-config-s3{left:20px;background-color:#e4e9f0;padding-left:5px;border-radius:3px}div.vis-configuration.vis-config-item.vis-config-s4{left:30px;background-color:#cfd8e6;padding-left:5px;border-radius:3px}div.vis-configuration.vis-config-header{font-size:18px;font-weight:700}div.vis-configuration.vis-config-label{width:120px;height:25px;line-height:25px}div.vis-configuration.vis-config-label.vis-config-s3{width:110px}div.vis-configuration.vis-config-label.vis-config-s4{width:100px}div.vis-configuration.vis-config-colorBlock{top:1px;width:30px;height:19px;border:1px solid #444;border-radius:2px;padding:0;margin:0;cursor:pointer}input.vis-configuration.vis-config-checkbox{left:-5px}input.vis-configuration.vis-config-rangeinput{position:relative;top:-5px;width:60px;padding:1px;margin:0;pointer-events:none}input.vis-configuration.vis-config-range{-webkit-appearance:none;border:0 solid #fff;background-color:transparent;width:300px;height:20px}input.vis-configuration.vis-config-range::-webkit-slider-runnable-track{width:300px;height:5px;background:#dedede;background:-moz-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#dedede),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#dedede,#c8c8c8 99%);background:-o-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:linear-gradient(180deg,#dedede 0,#c8c8c8 99%);border:1px solid #999;box-shadow:0 0 3px 0 #aaa;border-radius:3px}input.vis-configuration.vis-config-range::-webkit-slider-thumb{-webkit-appearance:none;border:1px solid #14334b;height:17px;width:17px;border-radius:50%;background:#3876c2;background:-moz-linear-gradient(top,#3876c2 0,#385380 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#3876c2),color-stop(100%,#385380));background:-webkit-linear-gradient(top,#3876c2,#385380);background:-o-linear-gradient(top,#3876c2 0,#385380 100%);background:-ms-linear-gradient(top,#3876c2 0,#385380 100%);background:linear-gradient(180deg,#3876c2 0,#385380);box-shadow:0 0 1px 0 #111927;margin-top:-7px}input.vis-configuration.vis-config-range:focus{outline:0}input.vis-configuration.vis-config-range:focus::-webkit-slider-runnable-track{background:#9d9d9d;background:-moz-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#9d9d9d),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#9d9d9d,#c8c8c8 99%);background:-o-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:linear-gradient(180deg,#9d9d9d 0,#c8c8c8 99%)}input.vis-configuration.vis-config-range::-moz-range-track{width:300px;height:10px;background:#dedede;background:-moz-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#dedede),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#dedede,#c8c8c8 99%);background:-o-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:linear-gradient(180deg,#dedede 0,#c8c8c8 99%);border:1px solid #999;box-shadow:0 0 3px 0 #aaa;border-radius:3px}input.vis-configuration.vis-config-range::-moz-range-thumb{border:none;height:16px;width:16px;border-radius:50%;background:#385380}input.vis-configuration.vis-config-range:-moz-focusring{outline:1px solid #fff;outline-offset:-1px}input.vis-configuration.vis-config-range::-ms-track{width:300px;height:5px;background:0 0;border-color:transparent;border-width:6px 0;color:transparent}input.vis-configuration.vis-config-range::-ms-fill-lower{background:#777;border-radius:10px}input.vis-configuration.vis-config-range::-ms-fill-upper{background:#ddd;border-radius:10px}input.vis-configuration.vis-coLine truncated
|
||||
@@ -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{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}})}}}}),$("#tags").select2({allowClear:!0,placeholder:"---------",theme:"bootstrap",multiple:!0,ajax:{url:"../../api/extras/tags/?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 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>')}})})}
|
||||
@@ -1 +1 @@
|
||||
!function(t,g){"object"==typeof exports&&"undefined"!=typeof module?g(exports):"function"==typeof define&&define.amd?define(["exports"],g):g((t=t||self).vis=t.vis||{})}(this,function(t){"use strict";var g="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t,g){return t(g={exports:{}},g.exports),g.exports}function A(t){return t&&t.default||t}function I(t){return t&&t.Math==Math&&t}function a(t){try{return!!t()}catch(t){return!0}}function y(t,g){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:g}}function C(t){return k.call(t).slice(8,-1)}function o(t){if(null==t)throw TypeError("Can't call method on "+t);return t}function r(t){return O(o(t))}function d(t){return"object"==typeof t?null!==t:"function"==typeof t}function i(t,g){if(!d(t))return t;var e,A;if(g&&"function"==typeof(e=t.toString)&&!d(A=e.call(t)))return A;if("function"==typeof(e=t.valueOf)&&!d(A=e.call(t)))return A;if(!g&&"function"==typeof(e=t.toString)&&!d(A=e.call(t)))return A;throw TypeError("Can't convert object to primitive value")}function f(t,g){return N.call(t,g)}function n(t){return Z?E.createElement(t):{}}function s(t,g){var e=S[R(t)];return e==L||e!=F&&("function"==typeof g?a(g):!!g)}function l(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function");return t}function m(A,I,t){if(l(A),void 0===I)return A;switch(t){case 0:return function(){return A.call(I)};case 1:return function(t){return A.call(I,t)};case 2:return function(t,g){return A.call(I,t,g)};case 3:return function(t,g,e){return A.call(I,t,g,e)}}return function(){return A.apply(I,arguments)}}function c(t){if(!d(t))throw TypeError(String(t)+" is not an object");return t}function p(A){function t(t,g,e){if(this instanceof A){switch(arguments.length){case 0:return new A;case 1:return new A(t);case 2:return new A(t,g)}return new A(t,g,e)}return A.apply(this,arguments)}return t.prototype=A.prototype,t}function b(t,g){var e,A,I,C,i,n,o,r,s=t.target,a=t.global,d=t.stat,l=t.proto,c=a?v:d?v[s]:(v[s]||{}).prototype,h=a?Y:Y[s]||(Y[s]={}),u=h.prototype;for(I in g)e=!Q(a?I:s+(d?".":"#")+I,t.forced)&&c&&f(c,I),i=h[I],e&&(n=t.noTargetGet?(r=P(c,I))&&r.value:c[I]),C=e&&n?n:g[I],e&&typeof i==typeof C||(o=t.bind&&e?m(C,v):t.wrap&&e?p(C):l&&"function"==typeof C?m(Function.call,C):C,(t.sham||C&&C.sham||i&&i.sham)&&j(o,"sham",!0),h[I]=o,l&&(f(Y,A=s+"Prototype")||j(Y,A,{}),Y[A][I]=C,t.real&&u&&!u[I]&&j(u,I,C)))}var v=I("object"==typeof globalThis&&globalThis)||I("object"==typeof window&&window)||I("object"==typeof self&&self)||I("object"==typeof g&&g)||Function("return this")(),h=!a(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),u={}.propertyIsEnumerable,w=Object.getOwnPropertyDescriptor,x={f:w&&!u.call({1:2},1)?function(t){var g=w(this,t);return!!g&&g.enumerable}:u},k={}.toString,D="".split,O=a(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==C(t)?D.call(t,""):Object(t)}:Object,N={}.hasOwnProperty,E=v.document,Z=d(E)&&d(E.createElement),M=!h&&!a(function(){return 7!=Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}),T=Object.getOwnPropertyDescriptor,G={f:h?T:function(t,g){if(t=r(t),g=i(g,!0),M)try{return T(t,g)}catch(t){}if(f(t,g))return y(!x.f.call(t,g),t[g])}},B=/#|\.prototype\./,R=s.normalize=function(t){return String(t).replace(B,".").toLowerCase()},S=s.data={},F=s.NATIVE="N",L=s.POLYFILL="P",Q=s,Y={},W=Object.defineProperty,z={f:h?W:function(t,g,e){if(c(t),g=i(g,!0),c(e),M)try{return W(t,g,e)}catch(t){}if("get"in e||"set"in e)throw TypeError("Accessors not supported");return"value"in e&&(t[g]=e.value),t}},j=h?function(t,g,e){return z.f(t,g,y(1,e))}:function(t,g,e){return t[g]=e,t},P=G.f,V=[].slice,X={},U=Function.bind||function(g){var e=l(this),A=V.call(arguments,1),I=function(){var t=A.concat(V.call(arguments));return this instanceof I?function(t,g,e){if(!(g in X)){for(var A=[],I=0;I<g;I++)A[I]="a["+I+"]";X[g]=Function("C,a","return new C("+A.join(",")+")")}return X[g](t,e)}(e,t.length,t):e.apply(g,t)};return d(e.prototype)&&(I.prototype=e.prototype),I};b({target:"Function",proto:!0},{bind:U});function _(t){return Y[t+"Prototype"]}var H=_("Function").bind,J=Function.prototype,K=function(t){var g=t.bind;return t===J||t instanceof Function&&g===J.bind?H:g};function q(t,g,e,A){t.beginPath(),t.arc(g,e,A,0,2*Math.PI,!1),t.closePath()}function $(t,g,e,A,I,C){var i=Math.PI/180;A-2*C<0&&(C=A/2),I-2*C<0&&(C=I/2),t.beginPath(),t.moveTo(g+C,e),t.lineTo(g+A-C,e),t.arc(g+A-C,e+C,C,270*i,360*i,!1),t.lineTo(g+A,e+I-C),t.arc(g+A-C,e+I-C,C,0,90*i,!1),t.lineTo(g+C,e+I),t.arc(g+C,e+I-C,C,90*i,180*i,!1),t.lineTo(g,e+C),t.arc(g+C,e+C,C,180*i,270*i,!1),t.closePath()}function tt(t,g,e,A,I){var C=A/2*.5522848,i=I/2*.5522848,n=g+A,o=e+I,r=g+A/2,s=e+I/2;t.beginPath(),t.moveTo(g,s),t.bezierCurveTo(g,s-i,r-C,e,r,e),t.bezierCurveTo(r+C,e,n,s-i,n,s),t.bezierCurveTo(n,s+i,r+C,o,r,o),t.bezierCurveTo(r-C,o,Line truncated
|
||||
!function(g,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((g=g||self).vis=g.vis||{})}(this,function(g){"use strict";var eC="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}function e(g,t){return g(t={exports:{}},t.exports),t.exports}function A(g){return g&&g.default||g}function I(g){return g&&g.Math==Math&&g}function a(g){try{return!!g()}catch(g){return!0}}function v(g,t){return{enumerable:!(1&g),configurable:!(2&g),writable:!(4&g),value:t}}function C(g){return k.call(g).slice(8,-1)}function o(g){if(null==g)throw TypeError("Can't call method on "+g);return g}function r(g){return O(o(g))}function d(g){return"object"==typeof g?null!==g:"function"==typeof g}function i(g,t){if(!d(g))return g;var e,A;if(t&&"function"==typeof(e=g.toString)&&!d(A=e.call(g)))return A;if("function"==typeof(e=g.valueOf)&&!d(A=e.call(g)))return A;if(!t&&"function"==typeof(e=g.toString)&&!d(A=e.call(g)))return A;throw TypeError("Can't convert object to primitive value")}function p(g,t){return N.call(g,t)}function n(g){return M?Z.createElement(g):{}}function s(g,t){var e=F[R(g)];return e==L||e!=S&&("function"==typeof t?a(t):!!t)}function l(g){if("function"!=typeof g)throw TypeError(String(g)+" is not a function");return g}function y(A,I,g){if(l(A),void 0===I)return A;switch(g){case 0:return function(){return A.call(I)};case 1:return function(g){return A.call(I,g)};case 2:return function(g,t){return A.call(I,g,t)};case 3:return function(g,t,e){return A.call(I,g,t,e)}}return function(){return A.apply(I,arguments)}}function h(g){if(!d(g))throw TypeError(String(g)+" is not an object");return g}function f(A){function g(g,t,e){if(this instanceof A){switch(arguments.length){case 0:return new A;case 1:return new A(g);case 2:return new A(g,t)}return new A(g,t,e)}return A.apply(this,arguments)}return g.prototype=A.prototype,g}function m(g,t){var e,A,I,C,i,n,o,r,s=g.target,a=g.global,d=g.stat,l=g.proto,h=a?b:d?b[s]:(b[s]||{}).prototype,c=a?Y:Y[s]||(Y[s]={}),u=c.prototype;for(I in t)e=!Q(a?I:s+(d?".":"#")+I,g.forced)&&h&&p(h,I),i=c[I],e&&(n=g.noTargetGet?(r=j(h,I))&&r.value:h[I]),C=e&&n?n:t[I],e&&typeof i==typeof C||(o=g.bind&&e?y(C,b):g.wrap&&e?f(C):l&&"function"==typeof C?y(Function.call,C):C,(g.sham||C&&C.sham||i&&i.sham)&&P(o,"sham",!0),c[I]=o,l&&(p(Y,A=s+"Prototype")||P(Y,A,{}),Y[A][I]=C,g.real&&u&&!u[I]&&P(u,I,C)))}var b=I("object"==typeof globalThis&&globalThis)||I("object"==typeof window&&window)||I("object"==typeof self&&self)||I("object"==typeof eC&&eC)||Function("return this")(),c=!a(function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}),u={}.propertyIsEnumerable,w=Object.getOwnPropertyDescriptor,x={f:w&&!u.call({1:2},1)?function(g){var t=w(this,g);return!!t&&t.enumerable}:u},k={}.toString,D="".split,O=a(function(){return!Object("z").propertyIsEnumerable(0)})?function(g){return"String"==C(g)?D.call(g,""):Object(g)}:Object,N={}.hasOwnProperty,Z=b.document,M=d(Z)&&d(Z.createElement),E=!c&&!a(function(){return 7!=Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}),G=Object.getOwnPropertyDescriptor,T={f:c?G:function(g,t){if(g=r(g),t=i(t,!0),E)try{return G(g,t)}catch(g){}if(p(g,t))return v(!x.f.call(g,t),g[t])}},B=/#|\.prototype\./,R=s.normalize=function(g){return String(g).replace(B,".").toLowerCase()},F=s.data={},S=s.NATIVE="N",L=s.POLYFILL="P",Q=s,Y={},W=Object.defineProperty,z={f:c?W:function(g,t,e){if(h(g),t=i(t,!0),h(e),E)try{return W(g,t,e)}catch(g){}if("get"in e||"set"in e)throw TypeError("Accessors not supported");return"value"in e&&(g[t]=e.value),g}},P=c?function(g,t,e){return z.f(g,t,v(1,e))}:function(g,t,e){return g[t]=e,g},j=T.f,V=[].slice,X={},U=Function.bind||function(t){var e=l(this),A=V.call(arguments,1),I=function(){var g=A.concat(V.call(arguments));return this instanceof I?function(g,t,e){if(!(t in X)){for(var A=[],I=0;I<t;I++)A[I]="a["+I+"]";X[t]=Function("C,a","return new C("+A.join(",")+")")}return X[t](g,e)}(e,g.length,g):e.apply(t,g)};return d(e.prototype)&&(I.prototype=e.prototype),I};m({target:"Function",proto:!0},{bind:U});function _(g){return Y[g+"Prototype"]}var H=_("Function").bind,J=Function.prototype,K=function(g){var t=g.bind;return g===J||g instanceof Function&&t===J.bind?H:t};function q(g,t,e,A){g.beginPath(),g.arc(t,e,A,0,2*Math.PI,!1),g.closePath()}function $(g,t,e,A,I,C){var i=Math.PI/180;A-2*C<0&&(C=A/2),I-2*C<0&&(C=I/2),g.beginPath(),g.moveTo(t+C,e),g.lineTo(t+A-C,e),g.arc(t+A-C,e+C,C,270*i,360*i,!1),g.lineTo(t+A,e+I-C),g.arc(t+A-C,e+I-C,C,0,90*i,!1),g.lineTo(t+C,e+I),g.arc(t+C,e+I-C,C,90*i,180*i,!1),g.lineTo(t,e+C),g.arc(t+C,e+C,C,180*i,270*i,!1),g.closePath()}function gg(g,t,e,A,I){var C=A/2*.5522848,i=I/2*.5522848,n=t+A,o=e+I,r=t+A/2,s=e+I/2;g.beginPath(),g.moveTo(t,s),g.bezierCurveTo(t,Line truncated
|
||||
@@ -7,7 +7,7 @@ var options = {
|
||||
interaction: {
|
||||
hover: true,
|
||||
hoverConnectedEdges: true,
|
||||
multiselect: true
|
||||
multiselect: false
|
||||
},
|
||||
nodes: {
|
||||
shape: 'image',
|
||||
@@ -95,6 +95,33 @@ function startLoadSearchBar() {
|
||||
}
|
||||
}
|
||||
});
|
||||
$('#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 = {
|
||||
term: params.term
|
||||
}
|
||||
return queryParameters;
|
||||
},
|
||||
processResults: function (data) {
|
||||
return {
|
||||
results: $.map(data.results, function (item) {
|
||||
return {
|
||||
text: item.name,
|
||||
id: item.id
|
||||
}
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var deviceRolesSelect = $('#device-roles');
|
||||
$.ajax({
|
||||
@@ -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() {
|
||||
$("#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();
|
||||
var value = $("#name").val();
|
||||
var value2 = $("#device-roles").val();
|
||||
var value3 = $("#sites").val();
|
||||
var value4 = $("#tags").val();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "../../api/plugins/topology-views/search/search/",
|
||||
data: JSON.stringify({
|
||||
'name': value,
|
||||
'devicerole': value2,
|
||||
'sites': value3
|
||||
'sites': value3,
|
||||
'tags': value4
|
||||
}),
|
||||
headers: { "X-CSRFToken": csrftoken },
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
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;
|
||||
nodes = new vis.DataSet();
|
||||
edges = new vis.DataSet();
|
||||
@@ -147,7 +193,7 @@ function handleButtonPress() {
|
||||
graph.fit();
|
||||
|
||||
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) {
|
||||
@@ -155,9 +201,9 @@ function handleButtonPress() {
|
||||
$.each(dragged, function (node_id, coordinates) {
|
||||
$("#coordstatus").html('');
|
||||
if ($('#checkSaveCoordinates').is(":checked")) {
|
||||
nodes.update({ id: node_id, physics: false });
|
||||
//nodes.update({ id: node_id, physics: false });
|
||||
$.ajax({
|
||||
url: "../../api/save_coords",
|
||||
url: "../../api/plugins/topology-views/save-coords/save_coords/",
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
headers: { "X-CSRFToken": csrftoken },
|
||||
@@ -168,18 +214,10 @@ function handleButtonPress() {
|
||||
'y': coordinates.y
|
||||
}),
|
||||
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) {
|
||||
$("#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 (data) {
|
||||
//nothing
|
||||
},
|
||||
});
|
||||
$("#coordstatus").html('<span class="label label-success">Updated coordinates</span>');
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -187,7 +225,7 @@ function handleButtonPress() {
|
||||
});
|
||||
},
|
||||
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>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<form id="search-form" class="form">
|
||||
<form id="search-form" class="form" autocomplete="off">
|
||||
{% csrf_token %}
|
||||
<div class="form-group">
|
||||
<label for="name">Name</label>
|
||||
@@ -37,6 +37,10 @@
|
||||
<div class="form-group">
|
||||
<label for="sites">Sites</label>
|
||||
<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>
|
||||
<hr class="mb-4">
|
||||
<button class="btn btn-primary btn-lg btn-block" type="submit" id="start-search">Search</button>
|
||||
@@ -45,6 +49,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
{% if config.allow_coordinates_saving == True %}
|
||||
<div class="panel panel-default mt-3">
|
||||
<div class="panel-heading">
|
||||
<strong>Settings</strong>
|
||||
@@ -59,6 +64,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
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
|
||||
"""
|
||||
|
||||
+2
-4
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "netbox_topology_views",
|
||||
"version": "0.2",
|
||||
"version": "0.4.0",
|
||||
"scripts": {
|
||||
"resources": "gulp build",
|
||||
"resources_dev": "gulp build_dev"
|
||||
@@ -13,8 +13,6 @@
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-sass": "^4.0.2",
|
||||
"gulp-uglify": "^3.0.2",
|
||||
"vis-data": "^6.2.3",
|
||||
"vis-util": "^1.1.8",
|
||||
"vis-network": "^6.4.4"
|
||||
"vis-network": "^7.6.4"
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='netbox-topology-views',
|
||||
version='0.3',
|
||||
version='0.4.0',
|
||||
description='An NetBox plugin to create Topology maps',
|
||||
url='https://github.com/mattieserver/netbox-topology-views',
|
||||
author='Mattijs Vanhaverbeke',
|
||||
|
||||
Reference in new issue
Block a user