Skip to content

Commit ab6ca96

Browse files
committed
Added plugin icon to plugin list/detail
1 parent e58815b commit ab6ca96

File tree

7 files changed

+37
-18
lines changed

7 files changed

+37
-18
lines changed

netbox/core/plugins.py

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class Plugin:
4747
The representation of a NetBox plugin in the catalog API.
4848
"""
4949
id: str = ''
50+
icon_url: str = ''
5051
status: str = ''
5152
title_short: str = ''
5253
title_long: str = ''
@@ -193,6 +194,7 @@ def make_plugin_dict():
193194
# Populate plugin data
194195
plugins[data['config_name']] = Plugin(
195196
id=data['id'],
197+
icon_url=data['icon_url'],
196198
status=data['status'],
197199
title_short=data['title_short'],
198200
title_long=data['title_long'],

netbox/core/tables/plugins.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
)
1010

1111

12+
PLUGIN_NAME_TEMPLATE = """
13+
<img class="plugin-icon" src="{{ record.icon_url }}">
14+
<a href="{% url 'core:plugin' record.config_name %}">{{ record.title_long }}</a>
15+
"""
16+
17+
1218
class PluginVersionTable(BaseTable):
1319
version = tables.Column(
1420
verbose_name=_('Version')
@@ -39,8 +45,8 @@ class Meta(BaseTable.Meta):
3945

4046

4147
class CatalogPluginTable(BaseTable):
42-
title_long = tables.Column(
43-
linkify=('core:plugin', [tables.A('config_name')]),
48+
title_long = columns.TemplateColumn(
49+
template_code=PLUGIN_NAME_TEMPLATE,
4450
verbose_name=_('Name')
4551
)
4652
author = tables.Column(

netbox/project-static/dist/netbox.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

netbox/project-static/dist/netbox.js

+9-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

netbox/project-static/dist/netbox.js.map

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

netbox/project-static/styles/custom/_misc.scss

+12
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,15 @@ span.color-label {
7575
.btn-grey, .btn-gray {
7676
@extend .btn-secondary;
7777
}
78+
79+
img.plugin-icon {
80+
max-width: 1.4285em;
81+
height: auto;
82+
}
83+
84+
body[data-bs-theme=dark] {
85+
// Assuming icon is black/white line art, invert it and tone down brightness
86+
img.plugin-icon {
87+
filter: invert(100%) brightness(80%);
88+
}
89+
}

netbox/templates/core/plugin.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% load i18n %}
55
{% load render_table from django_tables2 %}
66

7-
{% block title %}{{ plugin.title_long }}{% endblock %}
7+
{% block title %}<img class="plugin-icon" src="{{ plugin.icon_url }}">&nbsp;{{ plugin.title_long }}{% endblock %}
88

99
{% block object_identifier %}
1010
{% endblock object_identifier %}

0 commit comments

Comments
 (0)