File tree 5 files changed +37
-9
lines changed
netbox_changelog_diff_plugin
templates/netbox_changelog_diff_plugin
5 files changed +37
-9
lines changed 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
30
30
For adding to a NetBox Docker setup see
31
31
[ the general instructions for using netbox-docker with plugins] ( https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins ) .
32
32
33
- While this is still in development and not yet on pypi you can install with pip:
33
+ to install from pip:
34
34
35
35
``` bash
36
- pip install git+https://github.com/ITJamie/ netbox-changelog-diff-plugin
36
+ pip install netbox-changelog-diff-plugin
37
37
```
38
38
39
39
or by adding to your ` local_requirements.txt ` or ` plugin_requirements.txt ` (netbox-docker):
@@ -51,7 +51,12 @@ PLUGINS = [
51
51
]
52
52
53
53
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
+ },
55
60
}
56
61
```
57
62
Original file line number Diff line number Diff line change 2
2
3
3
__author__ = """Jamie Murphy"""
4
4
5
- __version__ = "0.2.0 "
5
+ __version__ = "0.2.1 "
6
6
7
7
8
8
from netbox .plugins import PluginConfig
@@ -16,6 +16,7 @@ class ChangeLogDiffConfig(PluginConfig):
16
16
base_url = "netbox_changelog_diff_plugin"
17
17
default_settings = {
18
18
"change_log_format" : "yaml" ,
19
+ "hide_native_diff" : False ,
19
20
}
20
21
21
22
Original file line number Diff line number Diff line change 1
1
from netbox .plugins import PluginTemplateExtension
2
2
from .utilities .html_differ import styled_diff
3
+ from .utils import get_plugin_setting
3
4
4
5
5
6
class ChangeLogDiffTemplateExtension (PluginTemplateExtension ):
@@ -13,8 +14,13 @@ def full_width_page(self):
13
14
prechange_data or dict (),
14
15
postchange_data or dict (),
15
16
)
17
+ hide_native_diff = get_plugin_setting ("hide_native_diff" )
16
18
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
+ },
18
24
)
19
25
20
26
Original file line number Diff line number Diff line change 1
1
{% load helpers %}
2
2
{% load i18n %}
3
3
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
+
4
20
< script type ="text/javascript ">
5
21
var styles = `
6
22
span.left_diff_change {
59
75
< div class ="col col-md-6 ">
60
76
< div class ="card ">
61
77
< h5 class ="card-header ">
62
- {% trans "Pre-Change Data" %}
78
+ {% trans "Pre-Change Data (Changelog Diff Plugin) " %}
63
79
</ h5 >
64
80
< div class ="card-body ">
65
81
< pre class ="change-data " style ="padding-top: 0; padding-bottom: 0; ">
@@ -71,7 +87,7 @@ <h5 class="card-header">
71
87
< div class ="col col-md-6 ">
72
88
< div class ="card ">
73
89
< h5 class ="card-header " >
74
- {% trans "Post-Change Data" %}
90
+ {% trans "Post-Change Data (Changelog Diff Plugin) " %}
75
91
</ h5 >
76
92
< div class ="card-body ">
77
93
< pre class ="change-data " style ="padding-top: 0; padding-bottom: 0; ">
@@ -80,4 +96,4 @@ <h5 class="card-header" >
80
96
</ div >
81
97
</ div >
82
98
</ div >
83
- </ div >
99
+ </ div >
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
8
8
[project ]
9
9
name = " netbox-changelog-diff-plugin"
10
- version = " 0.2.0 "
10
+ version = " 0.2.1 "
11
11
authors = [
12
12
{
name =
" Jamie Murphy" ,
email =
" [email protected] " },
13
13
]
You can’t perform that action at this time.
0 commit comments