File tree Expand file tree Collapse file tree
netbox_changelog_diff_plugin
templates/netbox_changelog_diff_plugin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,10 +30,10 @@ Minium version is 4.0.5 of netbox. Otherwise no changelog diff's will show up
3030For 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
3939or by adding to your ` local_requirements.txt ` or ` plugin_requirements.txt ` (netbox-docker):
@@ -51,7 +51,12 @@ PLUGINS = [
5151]
5252
5353PLUGINS_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
Original file line number Diff line number Diff line change 22
33__author__ = """Jamie Murphy"""
44__email__ = "git@jam.ie"
5- __version__ = "0.2.0 "
5+ __version__ = "0.2.1 "
66
77
88from 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
Original file line number Diff line number Diff line change 11from netbox .plugins import PluginTemplateExtension
22from .utilities .html_differ import styled_diff
3+ from .utils import get_plugin_setting
34
45
56class 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
Original file line number Diff line number Diff line change 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 = `
622span.left_diff_change {
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 >
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77
88[project ]
99name = " netbox-changelog-diff-plugin"
10- version = " 0.2.0 "
10+ version = " 0.2.1 "
1111authors = [
1212 {name = " Jamie Murphy" , email = " git@jam.ie" },
1313]
You can’t perform that action at this time.
0 commit comments