Skip to content

Commit dd810be

Browse files
committed
v0.2.1 - hide normal changelogs
1 parent 032446e commit dd810be

File tree

5 files changed

+37
-9
lines changed

5 files changed

+37
-9
lines changed

README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ Minium version is 4.0.5 of netbox. Otherwise no changelog diff's will show up
3030
For adding to a NetBox Docker setup see
3131
[the general instructions for using netbox-docker with plugins](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins).
3232

33-
While this is still in development and not yet on pypi you can install with pip:
33+
to install from pip:
3434

3535
```bash
36-
pip install git+https://github.com/ITJamie/netbox-changelog-diff-plugin
36+
pip install netbox-changelog-diff-plugin
3737
```
3838

3939
or by adding to your `local_requirements.txt` or `plugin_requirements.txt` (netbox-docker):
@@ -51,7 +51,12 @@ PLUGINS = [
5151
]
5252

5353
PLUGINS_CONFIG = {
54-
"netbox_changelog_diff_plugin": {},
54+
"netbox_changelog_diff_plugin": {
55+
# can be json or yaml, yaml is more readable
56+
"change_log_format": "yaml",
57+
# will hide the native changelog diff's if `True` and only show new ones
58+
"hide_native_diff": False
59+
},
5560
}
5661
```
5762

netbox_changelog_diff_plugin/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__author__ = """Jamie Murphy"""
44
__email__ = "[email protected]"
5-
__version__ = "0.2.0"
5+
__version__ = "0.2.1"
66

77

88
from netbox.plugins import PluginConfig
@@ -16,6 +16,7 @@ class ChangeLogDiffConfig(PluginConfig):
1616
base_url = "netbox_changelog_diff_plugin"
1717
default_settings = {
1818
"change_log_format": "yaml",
19+
"hide_native_diff": False,
1920
}
2021

2122

netbox_changelog_diff_plugin/template_content.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from netbox.plugins import PluginTemplateExtension
22
from .utilities.html_differ import styled_diff
3+
from .utils import get_plugin_setting
34

45

56
class ChangeLogDiffTemplateExtension(PluginTemplateExtension):
@@ -13,8 +14,13 @@ def full_width_page(self):
1314
prechange_data or dict(),
1415
postchange_data or dict(),
1516
)
17+
hide_native_diff = get_plugin_setting("hide_native_diff")
1618
return self.render(
17-
"netbox_changelog_diff_plugin/changelogdiff.html", extra_context={"leftrightdiffhtml": leftrightdiffhtml}
19+
"netbox_changelog_diff_plugin/changelogdiff.html",
20+
extra_context={
21+
"leftrightdiffhtml": leftrightdiffhtml,
22+
"hide_native_diff": hide_native_diff,
23+
},
1824
)
1925

2026

netbox_changelog_diff_plugin/templates/netbox_changelog_diff_plugin/changelogdiff.html

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
{% load helpers %}
22
{% load i18n %}
33

4+
{% if hide_native_diff %}
5+
<script type="text/javascript">
6+
window.onload = function() {
7+
var headers = document.querySelectorAll('h2.card-header');
8+
headers.forEach(function(header) {
9+
if (header.textContent.trim() === 'Pre-Change Data' || header.textContent.trim() === 'Post-Change Data') {
10+
var parentDiv = header.closest('div.card');
11+
if (parentDiv) {
12+
parentDiv.style.display = 'none';
13+
}
14+
}
15+
});
16+
};
17+
</script>
18+
{% endif %}
19+
420
<script type="text/javascript">
521
var styles = `
622
span.left_diff_change {
@@ -59,7 +75,7 @@
5975
<div class="col col-md-6">
6076
<div class="card">
6177
<h5 class="card-header">
62-
{% trans "Pre-Change Data" %}
78+
{% trans "Pre-Change Data (Changelog Diff Plugin)" %}
6379
</h5>
6480
<div class="card-body">
6581
<pre class="change-data" style="padding-top: 0; padding-bottom: 0;">
@@ -71,7 +87,7 @@ <h5 class="card-header">
7187
<div class="col col-md-6">
7288
<div class="card">
7389
<h5 class="card-header" >
74-
{% trans "Post-Change Data" %}
90+
{% trans "Post-Change Data (Changelog Diff Plugin)" %}
7591
</h5>
7692
<div class="card-body">
7793
<pre class="change-data" style="padding-top: 0; padding-bottom: 0;">
@@ -80,4 +96,4 @@ <h5 class="card-header" >
8096
</div>
8197
</div>
8298
</div>
83-
</div>
99+
</div>

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "netbox-changelog-diff-plugin"
10-
version = "0.2.0"
10+
version = "0.2.1"
1111
authors = [
1212
{name = "Jamie Murphy", email = "[email protected]"},
1313
]

0 commit comments

Comments
 (0)