netbox-device-view 0.1.9__tar.gz → 0.1.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/PKG-INFO +2 -2
  2. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/template_content.py +6 -1
  3. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/templates/netbox_device_view/deviceview.html +1 -5
  4. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/utils.py +23 -13
  5. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view.egg-info/PKG-INFO +2 -2
  6. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/setup.py +1 -1
  7. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/MANIFEST.in +0 -0
  8. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/README.md +0 -0
  9. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/__init__.py +0 -0
  10. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/api/__init__.py +0 -0
  11. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/api/serializers.py +0 -0
  12. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/api/urls.py +0 -0
  13. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/api/views.py +0 -0
  14. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/filtersets.py +0 -0
  15. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/forms.py +0 -0
  16. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/migrations/0001_initial.py +0 -0
  17. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/migrations/__init__.py +0 -0
  18. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/models.py +0 -0
  19. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/navigation.py +0 -0
  20. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/static/netbox_device_view/css/device_view.css +0 -0
  21. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/tables.py +0 -0
  22. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/templates/netbox_device_view/ports.html +0 -0
  23. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/urls.py +0 -0
  24. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view/views.py +0 -0
  25. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view.egg-info/SOURCES.txt +0 -0
  26. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view.egg-info/dependency_links.txt +0 -0
  27. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view.egg-info/not-zip-safe +0 -0
  28. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/netbox_device_view.egg-info/top_level.txt +0 -0
  29. {netbox_device_view-0.1.9 → netbox_device_view-0.1.11}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: netbox-device-view
3
- Version: 0.1.9
3
+ Version: 0.1.11
4
4
  Summary: NetBox Device View plugin
5
5
  Home-page: https://github.com/peterbaumert/netbox-device-view
6
6
  Author: Peter Baumert
@@ -1,11 +1,16 @@
1
1
  from netbox.plugins import PluginTemplateExtension
2
2
  from .utils import prepare
3
3
  from django.conf import settings
4
+ from dcim.models import Device
4
5
 
5
6
 
6
7
  class Ports(PluginTemplateExtension):
7
8
  def page(self):
8
9
  obj = self.context["object"]
10
+
11
+ if not isinstance(obj, Device):
12
+ return ""
13
+
9
14
  request = self.context["request"]
10
15
  url = request.build_absolute_uri(obj.get_absolute_url())
11
16
 
@@ -31,7 +36,7 @@ class DevicePorts(Ports):
31
36
  model = "dcim.device"
32
37
 
33
38
  def full_width_page(self):
34
- if settings.PLUGINS_CONFIG["netbox_device_view"]["show_on_device_tab"] == False:
39
+ if not settings.PLUGINS_CONFIG["netbox_device_view"]["show_on_device_tab"]:
35
40
  return ""
36
41
  return self.page()
37
42
 
@@ -60,11 +60,7 @@
60
60
  {% endfor %}
61
61
  {% endif %}
62
62
  "
63
- style="grid-area: {{ int.stylename }};
64
- {% if cable_colors == "on" and int.cable.color != "" %}
65
- background-color: #{{ int.cable.color }}
66
- {% endif %}
67
- "
63
+ style="grid-area: {{ int.stylename }}{% if cable_colors == 'on' and int.cable.color != '' %}; background-color: #{{ int.cable.color }}{% endif %}"
68
64
  data-bs-toggle="tooltip"
69
65
  data-bs-html="true"
70
66
  data-bs-custom-class="device-view-tooltip"
@@ -10,19 +10,27 @@ def process_interfaces(interfaces, ports_chassis, dev):
10
10
  for itf in interfaces:
11
11
  if itf.type == "virtual" or itf.type == "lag":
12
12
  continue
13
- regex = r"^(?P<type>([a-zA-Z\-_]*))(\/|(?P<dev>[0-9]+).|\s)?((?P<module>[0-9]+).|\s)?((?P<port>[0-9]+))$"
14
- matches = re.search(regex, itf.name.lower())
15
- if matches:
16
- itf.stylename = (
17
- (matches["type"] or "")
18
- + (matches["module"] or "")
19
- + "-"
20
- + matches["port"]
21
- )
22
- else:
23
- itf.stylename = re.sub(r"[^.a-zA-Z\d]", "-", itf.name.lower())
24
- if itf.stylename.isdigit():
13
+ # Convert to lowercase and replace common separators with hyphens
14
+ # This replaces the original regex matching and if/else block
15
+ stylename = re.sub(r"[/\.\s\+]+", "-", itf.name.lower())
16
+
17
+ # Clean up multiple hyphens and leading/trailing hyphens
18
+ stylename = re.sub(r"-+", "-", stylename).strip("-")
19
+
20
+ # If the name becomes empty after cleaning, use a fallback
21
+ if not stylename:
22
+ stylename = f"iface-{itf.pk}" # Use a unique fallback
23
+
24
+ # Assign the generated stylename back to the object property
25
+ itf.stylename = stylename
26
+
27
+ # Check if the stylename exists and starts with a digit or a hyphen
28
+ # This replaces the original 'if itf.stylename.isdigit():' line
29
+ if itf.stylename and (
30
+ itf.stylename[0].isdigit() or itf.stylename[0] == "-"
31
+ ):
25
32
  itf.stylename = f"p{itf.stylename}"
33
+
26
34
  if dev not in ports_chassis:
27
35
  ports_chassis[dev] = []
28
36
  ports_chassis[dev].append(itf)
@@ -55,7 +63,9 @@ def prepare(obj):
55
63
  device_type=obj.device_type
56
64
  ).grid_template_area
57
65
  modules[1] = obj.modules.all()
58
- ports_chassis = process_interfaces(obj.interfaces.all(), ports_chassis, 1)
66
+ ports_chassis = process_interfaces(
67
+ obj.interfaces.all(), ports_chassis, obj.name
68
+ )
59
69
  ports_chassis = process_ports(obj.frontports.all(), ports_chassis, "Front")
60
70
  ports_chassis = process_ports(obj.rearports.all(), ports_chassis, "Rear")
61
71
  ports_chassis = process_ports(
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: netbox-device-view
3
- Version: 0.1.9
3
+ Version: 0.1.11
4
4
  Summary: NetBox Device View plugin
5
5
  Home-page: https://github.com/peterbaumert/netbox-device-view
6
6
  Author: Peter Baumert
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name="netbox-device-view",
8
- version="0.1.9",
8
+ version="0.1.11",
9
9
  description="NetBox Device View plugin",
10
10
  packages=find_packages(),
11
11
  author="Peter Baumert",