mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-29 11:56:25 -06:00
HTML cleanup and add copy-to-clipboard button
This commit is contained in:
parent
b0663305b7
commit
4655372585
@ -43,6 +43,16 @@ MODULEBAY_STATUS = """
|
|||||||
{% badge record.installed_module.get_status_display bg_color=record.installed_module.get_status_color %}
|
{% badge record.installed_module.get_status_display bg_color=record.installed_module.get_status_color %}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
MACADDRESS_LINK = """
|
||||||
|
{% if record.pk %}
|
||||||
|
<a href="{{ record.get_absolute_url }}" id="macaddress_{{ record.pk }}">{{ record.mac_address }}</a>
|
||||||
|
{% endif %}
|
||||||
|
"""
|
||||||
|
|
||||||
|
MACADDRESS_COPY_BUTTON = """
|
||||||
|
{% copy_content record.pk prefix="macaddress_" %}
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Device roles
|
# Device roles
|
||||||
@ -599,9 +609,9 @@ class BaseInterfaceTable(NetBoxTable):
|
|||||||
|
|
||||||
|
|
||||||
class MACAddressTable(NetBoxTable):
|
class MACAddressTable(NetBoxTable):
|
||||||
mac_address = tables.Column(
|
mac_address = tables.TemplateColumn(
|
||||||
verbose_name=_('MAC Address'),
|
template_code=MACADDRESS_LINK,
|
||||||
linkify=True
|
verbose_name=_('MAC Address')
|
||||||
)
|
)
|
||||||
assigned_object = tables.Column(
|
assigned_object = tables.Column(
|
||||||
linkify=True,
|
linkify=True,
|
||||||
@ -625,6 +635,9 @@ class MACAddressTable(NetBoxTable):
|
|||||||
tags = columns.TagColumn(
|
tags = columns.TagColumn(
|
||||||
url_name='dcim:macaddress_list'
|
url_name='dcim:macaddress_list'
|
||||||
)
|
)
|
||||||
|
actions = columns.ActionsColumn(
|
||||||
|
extra_buttons=MACADDRESS_COPY_BUTTON
|
||||||
|
)
|
||||||
|
|
||||||
class Meta(DeviceComponentTable.Meta):
|
class Meta(DeviceComponentTable.Meta):
|
||||||
model = models.MACAddress
|
model = models.MACAddress
|
||||||
|
@ -2548,7 +2548,6 @@ class MACAddressListView(generic.ObjectListView):
|
|||||||
filterset = filtersets.MACAddressFilterSet
|
filterset = filtersets.MACAddressFilterSet
|
||||||
filterset_form = forms.MACAddressFilterForm
|
filterset_form = forms.MACAddressFilterForm
|
||||||
table = tables.MACAddressTable
|
table = tables.MACAddressTable
|
||||||
template_name = 'dcim/component_list.html'
|
|
||||||
|
|
||||||
|
|
||||||
@register_model_view(MACAddress)
|
@register_model_view(MACAddress)
|
||||||
@ -2632,13 +2631,6 @@ class InterfaceView(generic.ObjectView):
|
|||||||
orderable=False
|
orderable=False
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get MAC addresses
|
|
||||||
mac_addresses_table = tables.MACAddressTable(
|
|
||||||
data=instance.mac_addresses,
|
|
||||||
exclude=('assigned_object',),
|
|
||||||
orderable=False
|
|
||||||
)
|
|
||||||
|
|
||||||
# Get assigned VLANs and annotate whether each is tagged or untagged
|
# Get assigned VLANs and annotate whether each is tagged or untagged
|
||||||
vlans = []
|
vlans = []
|
||||||
if instance.untagged_vlan is not None:
|
if instance.untagged_vlan is not None:
|
||||||
@ -2665,7 +2657,6 @@ class InterfaceView(generic.ObjectView):
|
|||||||
'vdc_table': vdc_table,
|
'vdc_table': vdc_table,
|
||||||
'bridge_interfaces_table': bridge_interfaces_table,
|
'bridge_interfaces_table': bridge_interfaces_table,
|
||||||
'child_interfaces_table': child_interfaces_table,
|
'child_interfaces_table': child_interfaces_table,
|
||||||
'mac_addresses_table': mac_addresses_table,
|
|
||||||
'vlan_table': vlan_table,
|
'vlan_table': vlan_table,
|
||||||
'vlan_translation_table': vlan_translation_table,
|
'vlan_translation_table': vlan_translation_table,
|
||||||
}
|
}
|
||||||
|
@ -358,7 +358,7 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<h2 class="card-header">
|
<h2 class="card-header">
|
||||||
{% trans "MAC Addresses" %}
|
{% trans "MAC Addresses" %}
|
||||||
{% if perms.ipam.add_macaddress %}
|
{% if perms.dcim.add_macaddress %}
|
||||||
<div class="card-actions">
|
<div class="card-actions">
|
||||||
<a href="{% url 'dcim:macaddress_add' %}?device={{ object.device.pk }}&interface={{ object.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-ghost-primary btn-sm">
|
<a href="{% url 'dcim:macaddress_add' %}?device={{ object.device.pk }}&interface={{ object.pk }}&return_url={{ object.get_absolute_url }}" class="btn btn-ghost-primary btn-sm">
|
||||||
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> {% trans "Add MAC Address" %}
|
<span class="mdi mdi-plus-thick" aria-hidden="true"></span> {% trans "Add MAC Address" %}
|
||||||
|
@ -10,6 +10,13 @@
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<h2 class="card-header">{% trans "MAC Address" %}</h2>
|
<h2 class="card-header">{% trans "MAC Address" %}</h2>
|
||||||
<table class="table table-hover attr-table">
|
<table class="table table-hover attr-table">
|
||||||
|
<tr>
|
||||||
|
<th scope="row">{% trans "MAC Address" %}</th>
|
||||||
|
<td>
|
||||||
|
<span id="macaddress_{{ object.pk }}">{{ object.mac_address|placeholder }}</span>
|
||||||
|
{% copy_content object.pk prefix="macaddress_" %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">{% trans "Description" %}</th>
|
<th scope="row">{% trans "Description" %}</th>
|
||||||
<td>{{ object.description|placeholder }}</td>
|
<td>{{ object.description|placeholder }}</td>
|
||||||
@ -18,9 +25,7 @@
|
|||||||
<th scope="row">{% trans "Assignment" %}</th>
|
<th scope="row">{% trans "Assignment" %}</th>
|
||||||
<td>
|
<td>
|
||||||
{% if object.assigned_object %}
|
{% if object.assigned_object %}
|
||||||
{% if object.assigned_object.parent_object %}
|
{{ object.assigned_object.parent_object|linkify }} /
|
||||||
{{ object.assigned_object.parent_object|linkify }} /
|
|
||||||
{% endif %}
|
|
||||||
{{ object.assigned_object|linkify }}
|
{{ object.assigned_object|linkify }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ ''|placeholder }}
|
{{ ''|placeholder }}
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
{% extends 'generic/object_edit.html' %}
|
|
||||||
{% load static %}
|
|
||||||
{% load form_helpers %}
|
|
||||||
{% load i18n %}
|
|
||||||
|
|
||||||
{% block title %}{% trans "Bulk Add MAC Addresses" %}{% endblock %}
|
|
||||||
|
|
||||||
{% block tabs %}
|
|
||||||
{% include 'ipam/inc/ipaddress_edit_header.html' with active_tab='bulk_add' %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block form %}
|
|
||||||
<div class="field-group my-5">
|
|
||||||
<div class="row">
|
|
||||||
<h2 class="col-9 offset-3">{% trans "MAC Addresses" %}</h2>
|
|
||||||
</div>
|
|
||||||
{% render_field form.pattern %}
|
|
||||||
{% render_field model_form.description %}
|
|
||||||
{% render_field model_form.tags %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if model_form.custom_fields %}
|
|
||||||
<div class="field-group my-5">
|
|
||||||
<div class="row">
|
|
||||||
<h2 class="col-9 offset-3">{% trans "Custom Fields" %}</h2>
|
|
||||||
</div>
|
|
||||||
{% render_custom_fields model_form %}
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
Loading…
Reference in New Issue
Block a user