Merge branch 'mattieserver:master' into update-git-ignore
This commit is contained in:
15 files changed
+283
-224
No files matched your search
@@ -0,0 +1,21 @@
|
||||
<!--
|
||||
IMPORTANT:
|
||||
==========
|
||||
Thank you for contributing to NetBox Topology Views! Please
|
||||
note that our contribution guidelines require a feature
|
||||
request or bug report to be labeled "status: accepted". This
|
||||
helps avoid waste time and effort on a proposed change that
|
||||
we might not be able to accept.
|
||||
|
||||
Please prefix the title of your pull request according to
|
||||
it's type. You should use "Closes #FEATURE_ID: ..." for feature
|
||||
requests and "Fixes #ISSUE_ID: ..." for issues. This helps
|
||||
us closing issues automatically after merging.
|
||||
|
||||
To sum it up:
|
||||
1. Create Bug Report or Feature Request
|
||||
2. Wait until the issue has been labeled "status: accepted"
|
||||
3. Start working on the issue in a seperate branch
|
||||
3. Create a pull request and name the title with a prefix
|
||||
according to the issue ID.
|
||||
-->
|
||||
@@ -1,93 +0,0 @@
|
||||
name: Docker
|
||||
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '35 10 * * *'
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
# Publish semver tags as releases.
|
||||
tags: [ 'v*.*.*' ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
|
||||
env:
|
||||
# Use docker.io for Docker Hub if empty
|
||||
REGISTRY: ghcr.io
|
||||
# github.repository as <account>/<repo>
|
||||
IMAGE_NAME: ${{ github.repository }}
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
# This is used to complete the identity challenge
|
||||
# with sigstore/fulcio when running outside of PRs.
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Install the cosign tool except on PR
|
||||
# https://github.com/sigstore/cosign-installer
|
||||
- name: Install cosign
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: sigstore/cosign-installer@7e0881f8fe90b25e305bbf0309761e9314607e25
|
||||
with:
|
||||
cosign-release: 'v1.9.0'
|
||||
|
||||
|
||||
# Workaround: https://github.com/docker/build-push-action/issues/461
|
||||
- name: Setup Docker buildx
|
||||
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
|
||||
|
||||
# Login against a Docker registry except on PR
|
||||
# https://github.com/docker/login-action
|
||||
- name: Log into registry ${{ env.REGISTRY }}
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Extract metadata (tags, labels) for Docker
|
||||
# https://github.com/docker/metadata-action
|
||||
- name: Extract Docker metadata
|
||||
id: meta
|
||||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
|
||||
with:
|
||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
|
||||
# Build and push Docker image with Buildx (don't push on PR)
|
||||
# https://github.com/docker/build-push-action
|
||||
- name: Build and push Docker image
|
||||
id: build-and-push
|
||||
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
|
||||
with:
|
||||
context: .
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
|
||||
# Sign the resulting Docker image digest except on PRs.
|
||||
# This will only write to the public Rekor transparency log when the Docker
|
||||
# repository is public to avoid leaking data. If you would like to publish
|
||||
# transparency data even for private images, pass --force to cosign below.
|
||||
# https://github.com/sigstore/cosign
|
||||
- name: Sign the published Docker image
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
env:
|
||||
COSIGN_EXPERIMENTAL: "true"
|
||||
# This step uses the identity token to provision an ephemeral certificate
|
||||
# against the sigstore community Fulcio instance.
|
||||
run: cosign sign ${{ steps.meta.outputs.tags }}@${{ steps.build-and-push.outputs.digest }}
|
||||
@@ -1,4 +0,0 @@
|
||||
FROM netboxcommunity/netbox:latest
|
||||
|
||||
COPY ./docker/plugin_requirements.txt /
|
||||
RUN /opt/netbox/venv/bin/pip install --no-warn-script-location -r /plugin_requirements.txt
|
||||
@@ -12,6 +12,8 @@ Support to filter on name, site, tag and device role.
|
||||
|
||||
## Install
|
||||
|
||||
**_NOTE:_** For docker please see: [Docker install](https://github.com/netbox-community/netbox-docker/wiki/Using-Netbox-Plugins)
|
||||
|
||||
The plugin is available as a Python package and can be installed with pip.
|
||||
|
||||
Run `pip install netbox-topology-views` in your virtual env.
|
||||
@@ -44,6 +46,7 @@ python3 manage.py collectstatic --no-input
|
||||
|
||||
| netbox version | netbox-topology-views version |
|
||||
| -------------- | ----------------------------- |
|
||||
| >= 3.4.0 | >= v3.X.X |
|
||||
| >= 3.3.0 | >= v3.0.0 |
|
||||
| >= 3.2.0 | >= v1.1.0 |
|
||||
| >= 3.1.8 | >= v1.0.0 |
|
||||
@@ -85,6 +88,9 @@ PLUGINS_CONFIG = {
|
||||
| ignore_cable_type | [] | The cable types that you want to ignore in the views |
|
||||
| preselected_tags | [] | The name of tags you want to preload |
|
||||
| draw_default_layout | False | (bool) Set to True if you want to load draw the topology on the initial load (when you go to the topology plugin page) |
|
||||
| hide_single_cable_logical_conns | False | (bool) Set to True if you want to hide duplicate cables & logical connections |
|
||||
|
||||
|
||||
|
||||
### Custom Images
|
||||
|
||||
@@ -94,6 +100,31 @@ To change image with associated device use the `Images` page - it allows to map
|
||||
|
||||
Go to the plugins tab in the navbar and click topology or go to `$NETBOX_URL/plugins/netbox_topology_views/` to view your topologies
|
||||
|
||||
Select your options for the topology view:
|
||||
|
||||

|
||||
|
||||
<dl>
|
||||
<dt>Hide Unconnected</dt>
|
||||
<dd>Hide devices which have no connections.</dd>
|
||||
<dt>Save Coordinates</dt>
|
||||
<dd>Save the coordinates of devices in the topology view.</dd>
|
||||
<dd>Please read the "Configure" chapter to set the allow_coordinates_saving option to True.</dd>
|
||||
<dt>Show Cables</dt>
|
||||
<dd>Show cable connections between devices, including cables connected to interfaces, front / rear ports, etc., in the topology view</dd>
|
||||
<dt>Show Logical Connections</dt>
|
||||
<dd>Show logical connections between interfaces (referred to as Interface Connections in NetBox) in the topology view. Where the path between
|
||||
interfaces includes multiple cables (e.g., via patch panels), only the end interface connections are shown, not the
|
||||
intermediate front / rear port connections, etc. This is similar to what was referred to as 'end-to-end' connections in previous versions. </dd>
|
||||
<dd><i>Selecting both 'Show Cables' and 'Show Logical Interfaces' will sometimes result in a topology view with 2 cables per connection as these devices are diretly connected. Select only one of the options or set `hide_single_cable_logical_conns` to True.</i></dd>
|
||||
<dt>Show Circuit Terminations</dt>
|
||||
<dd>Show connections which end at a circuit termination in the topology view.</dd>
|
||||
<dt>Show Wireless Links</dt>
|
||||
<dd>Show wireless connections in the topology view.</dd>
|
||||
<dt>Show Power Feeds</dt>
|
||||
<dd>Show power connections from power feeds in the topology view.</dd>
|
||||
</dl>
|
||||
|
||||
### Update
|
||||
|
||||
Run `pip install netbox-topology-views --upgrade` in your venv.
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 9.9 KiB |
@@ -1 +0,0 @@
|
||||
netbox-topology-views
|
||||
@@ -29,6 +29,7 @@ class TopologyViewsConfig(PluginConfig):
|
||||
"always_save_coordinates": False,
|
||||
"preselected_tags": [],
|
||||
"draw_default_layout": False,
|
||||
"hide_single_cable_logical_conns": False,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,10 +31,14 @@ class DeviceFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
None,
|
||||
(
|
||||
"q",
|
||||
"filter_id",
|
||||
"hide_unconnected",
|
||||
"save_coords",
|
||||
"show_cables",
|
||||
"show_circuit",
|
||||
"show_logical_connections",
|
||||
"show_power",
|
||||
"show_wireless",
|
||||
),
|
||||
),
|
||||
(
|
||||
@@ -103,6 +107,15 @@ class DeviceFilterForm(TenancyFilterForm, NetBoxModelFilterSetForm):
|
||||
hide_unconnected = forms.BooleanField(
|
||||
label=_("Hide Unconnected"), required=False, initial=False
|
||||
)
|
||||
show_logical_connections = forms.BooleanField(
|
||||
label =_("Show Logical Connections"), required=False, initial=False
|
||||
)
|
||||
show_cables = forms.BooleanField(
|
||||
label =_("Show Cables"), required=False, initial=False
|
||||
)
|
||||
show_wireless = forms.BooleanField(
|
||||
label =_("Show Wireless Links"), required=False, initial=False
|
||||
)
|
||||
show_circuit = forms.BooleanField(
|
||||
label=_("Show Circuit Terminations"), required=False, initial=False
|
||||
)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from extras.plugins import PluginMenuItem
|
||||
from extras.plugins import PluginMenu, PluginMenuItem
|
||||
|
||||
menu_items = (
|
||||
PluginMenuItem(link="plugins:netbox_topology_views:home", link_text="Topology"),
|
||||
PluginMenuItem(
|
||||
link="plugins:netbox_topology_views:images", link_text="Topology Images"
|
||||
menu = PluginMenu(
|
||||
label='Topology Views',
|
||||
groups=(
|
||||
('Topology', (PluginMenuItem(link="plugins:netbox_topology_views:home", link_text="Topology"),),),
|
||||
('CUSTOMIZATION', (PluginMenuItem(link="plugins:netbox_topology_views:images", link_text="Topology Images"),),),
|
||||
),
|
||||
)
|
||||
@@ -1 +1 @@
|
||||
#visgraph{height:70vh}html[data-netbox-color-mode=dark] #visgraph{background-color:#212529}.image-dropdown img{width:64px;height:64px}.image-dropdown-content{display:flex;flex-wrap:wrap;gap:.5rem;padding-inline:.5rem;width:50vw;max-width:32rem}.image-dropdown-content>img{cursor:pointer}
|
||||
#visgraph{height:64vh}html[data-netbox-color-mode=dark] #visgraph{background-color:#212529}.image-dropdown img{width:64px;height:64px}.image-dropdown-content{display:flex;flex-wrap:wrap;gap:.5rem;padding-inline:.5rem;width:50vw;max-width:32rem}.image-dropdown-content>img{cursor:pointer}
|
||||
@@ -20,7 +20,7 @@
|
||||
`,Z()):M+=z,Z();if(z!='"')throw ie('End of string " expected');Z(),oe=te.IDENTIFIER;return}for(oe=te.UNKNOWN;z!="";)M+=z,Z();throw new SyntaxError('Syntax error in part "'+vo(M,30)+'"')}function ra(){var n={};if(sa(),V(),M==="strict"&&(n.strict=!0,V()),(M==="graph"||M==="digraph")&&(n.type=M,V()),oe===te.IDENTIFIER&&(n.id=M,V()),M!="{")throw ie("Angle bracket { expected");if(V(),mo(n),M!="}")throw ie("Angle bracket } expected");if(V(),M!=="")throw ie("End of file expected");return V(),delete n.node,delete n.edge,delete n.graph,n}function mo(n){for(;M!==""&&M!="}";)aa(n),M===";"&&V()}function aa(n){var e=yo(n);if(e){bo(n,e);return}var t=da(n);if(!t){if(oe!=te.IDENTIFIER)throw ie("Identifier expected");var i=M;if(V(),M==="="){if(V(),oe!=te.IDENTIFIER)throw ie("Identifier expected");n[i]=M,V()}else ha(n,i)}}function yo(n){var e=null;if(M==="subgraph"&&(e={},e.type="subgraph",V(),oe===te.IDENTIFIER&&(e.id=M,V())),M==="{"){if(V(),e||(e={}),e.parent=n,e.node=n.node,e.edge=n.edge,e.graph=n.graph,mo(e),M!="}")throw ie("Angle bracket } expected");V(),delete e.node,delete e.edge,delete e.graph,delete e.parent,n.subgraphs||(n.subgraphs=[]),n.subgraphs.push(e)}return e}function da(n){return M==="node"?(V(),n.node=xt(),"node"):M==="edge"?(V(),n.edge=xt(),"edge"):M==="graph"?(V(),n.graph=xt(),"graph"):null}function ha(n,e){var t={id:e},i=xt();i&&(t.attr=i),po(n,t),bo(n,e)}function bo(n,e){for(;M==="->"||M==="--";){var t,i=M;V();var s=yo(n);if(s)t=s;else{if(oe!=te.IDENTIFIER)throw ie("Identifier or subgraph expected");t=M,po(n,{id:t}),V()}var o=xt(),r=go(n,e,t,i,o);na(n,r),e=t}}function xt(){for(var n,e=null,t={dashed:!0,solid:!1,dotted:[1,5]},i={dot:"circle",box:"box",crow:"crow",curve:"curve",icurve:"inv_curve",normal:"triangle",inv:"inv_triangle",diamond:"diamond",tee:"bar",vee:"vee"},s=new Array,o=new Array;M==="[";){for(V(),e={};M!==""&&M!="]";){if(oe!=te.IDENTIFIER)throw ie("Attribute name expected");var r=M;if(V(),M!="=")throw ie("Equal sign = expected");if(V(),oe!=te.IDENTIFIER)throw ie("Attribute value expected");var a=M;r==="style"&&(a=t[a]);var d;r==="arrowhead"&&(d=i[a],r="arrows",a={to:{enabled:!0,type:d}}),r==="arrowtail"&&(d=i[a],r="arrows",a={from:{enabled:!0,type:d}}),s.push({attr:e,name:r,value:a}),o.push(r),V(),M==","&&V()}if(M!="]")throw ie("Bracket ] expected");V()}if(o.includes("dir")){var h={};for(h.arrows={},n=0;n<s.length;n++)if(s[n].name==="arrows")if(s[n].value.to!=null)h.arrows.to=n;else if(s[n].value.from!=null)h.arrows.from=n;else throw ie("Invalid value of arrows");else s[n].name==="dir"&&(h.dir=n);var l=s[h.dir].value;if(!o.includes("arrows"))if(l==="both")s.push({attr:s[h.dir].attr,name:"arrows",value:{to:{enabled:!0}}}),h.arrows.to=s.length-1,s.push({attr:s[h.dir].attr,name:"arrows",value:{from:{enabled:!0}}}),h.arrows.from=s.length-1;else if(l==="forward")s.push({attr:s[h.dir].attr,name:"arrows",value:{to:{enabled:!0}}}),h.arrows.to=s.length-1;else if(l==="back")s.push({attr:s[h.dir].attr,name:"arrows",value:{from:{enabled:!0}}}),h.arrows.from=s.length-1;else if(l==="none")s.push({attr:s[h.dir].attr,name:"arrows",value:""}),h.arrows.to=s.length-1;else throw ie('Invalid dir type "'+l+'"');var c,u;if(l==="both")h.arrows.to&&h.arrows.from?(u=s[h.arrows.to].value.to.type,c=s[h.arrows.from].value.from.type,s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}},s.splice(h.arrows.from,1)):h.arrows.to?(u=s[h.arrows.to].value.to.type,c="arrow",s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.arrows.from&&(u="arrow",c=s[h.arrows.from].value.from.type,s[h.arrows.from]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}});else if(l==="back")h.arrows.to&&h.arrows.from?(u="",c=s[h.arrows.from].value.from.type,s[h.arrows.from]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.arrows.to?(u="",c="arrow",h.arrows.from=h.arrows.to,s[h.arrows.from]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.arrows.from&&(u="",c=s[h.arrows.from].value.from.type,s[h.arrows.to]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}),s[h.arrows.from]={attr:s[h.arrows.from].attr,name:s[h.arrows.from].name,value:{from:{enabled:!0,type:s[h.arrows.from].value.from.type}}};else if(l==="none"){var p;h.arrows.to?p=h.arrows.to:p=h.arrows.from,s[p]={attr:s[p].attr,name:s[p].name,value:""}}else if(l==="forward")h.arrows.to&&h.arrows.from?(u=s[h.arrows.to].value.to.type,c="",s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:u},from:{enabled:!0,type:c}}}):h.arrows.to?(u=s[h.arrows.to].value.to.type,c="",s[h.arrows.to]={attr:s[h.arrows.to].attr,name:s[h.arrows.to].name,value:{to:{enabled:!0,type:u},from:{en
Line truncated
|
||||
`),e=e.replace(/\r/g,`
|
||||
`);let i=String(e).split(`
|
||||
`),s=i.length;if(t.multi)for(let o=0;o<s;o++){let r=this.splitBlocks(i[o],t.multi);if(r!==void 0){if(r.length===0){this.lines.newLine("");continue}if(t.maxWdt>0)for(let a=0;a<r.length;a++){let d=r[a].mod,h=r[a].text;this.splitStringIntoLines(h,d,!0)}else for(let a=0;a<r.length;a++){let d=r[a].mod,h=r[a].text;this.lines.append(h,d)}this.lines.newLine()}}else if(t.maxWdt>0)for(let o=0;o<s;o++)this.splitStringIntoLines(i[o]);else for(let o=0;o<s;o++)this.lines.newLine(i[o]);return this.lines.finalize()}decodeMarkupSystem(e){let t="none";return e==="markdown"||e==="md"?t="markdown":(e===!0||e==="html")&&(t="html"),t}splitHtmlBlocks(e){let t=new Pi(e),i=s=>/&/.test(s)?(t.replace(t.text,"<","<")||t.replace(t.text,"&","&")||t.add("&"),!0):!1;for(;t.position<t.text.length;){let s=t.text.charAt(t.position);t.parseWS(s)||/</.test(s)&&(t.parseStartTag("bold","<b>")||t.parseStartTag("ital","<i>")||t.parseStartTag("mono","<code>")||t.parseEndTag("bold","</b>")||t.parseEndTag("ital","</i>")||t.parseEndTag("mono","</code>"))||i(s)||t.add(s),t.position++}return t.emitBlock(),t.blocks}splitMarkdownBlocks(e){let t=new Pi(e),i=!0,s=o=>/\\/.test(o)?(t.position<this.text.length+1&&(t.position++,o=this.text.charAt(t.position),/ \t/.test(o)?t.spacing=!0:(t.add(o),i=!1)),!0):!1;for(;t.position<t.text.length;){let o=t.text.charAt(t.position);t.parseWS(o)||s(o)||(i||t.spacing)&&(t.parseStartTag("bold","*")||t.parseStartTag("ital","_")||t.parseStartTag("mono","`"))||t.parseEndTag("bold","*","afterBold")||t.parseEndTag("ital","_","afterItal")||t.parseEndTag("mono","`","afterMono")||(t.add(o),i=!1),t.position++}return t.emitBlock(),t.blocks}splitBlocks(e,t){let i=this.decodeMarkupSystem(t);if(i==="none")return[{text:e,mod:"normal"}];if(i==="markdown")return this.splitMarkdownBlocks(e);if(i==="html")return this.splitHtmlBlocks(e)}overMaxWidth(e){let t=this.ctx.measureText(e).width;return this.lines.curWidth()+t>this.parent.fontOptions.maxWdt}getLongestFit(e){let t="",i=0;for(;i<e.length;){let o=t+(t===""?"":" ")+e[i];if(this.overMaxWidth(o))break;t=o,i++}return i}getLongestFitWord(e){let t=0;for(;t<e.length&&!this.overMaxWidth(e.slice(0,t));)t++;return t}splitStringIntoLines(e,t="normal",i=!1){this.parent.getFormattingValues(this.ctx,this.selected,this.hover,t),e=e.replace(/^( +)/g,"$1\r"),e=e.replace(/([^\r][^ ]*)( +)/g,"$1\r$2\r");let s=e.split("\r");for(;s.length>0;){let o=this.getLongestFit(s);if(o===0){let r=s[0],a=this.getLongestFitWord(r);this.lines.newLine(r.slice(0,a),t),s[0]=r.slice(a)}else{let r=o;s[o-1]===" "?o--:s[r]===" "&&r++;let a=s.slice(0,o).join("");o==s.length&&i?this.lines.append(a,t):this.lines.newLine(a,t),s=s.slice(r)}}}},Xt=["bold","ital","boldital","mono"],Ye=class{constructor(e,t,i=!1){this.body=e,this.pointToSelf=!1,this.baseSize=void 0,this.fontOptions={},this.setOptions(t),this.size={top:0,left:0,width:0,height:0,yLine:0},this.isEdgeLabel=i}setOptions(e){if(this.elementOptions=e,this.initFontOptions(e.font),Yt(e.label)?this.labelDirty=!0:e.label=void 0,e.font!==void 0&&e.font!==null){if(typeof e.font=="string")this.baseSize=this.fontOptions.size;else if(typeof e.font=="object"){let t=e.font.size;t!==void 0&&(this.baseSize=t)}}}initFontOptions(e){if(A(Xt,t=>{this.fontOptions[t]={}}),Ye.parseFontString(this.fontOptions,e)){this.fontOptions.vadjust=0;return}A(e,(t,i)=>{t!=null&&typeof t!="object"&&(this.fontOptions[i]=t)})}static parseFontString(e,t){if(!t||typeof t!="string")return!1;let i=t.split(" ");return e.size=+i[0].replace("px",""),e.face=i[1],e.color=i[2],!0}constrain(e){let t={constrainWidth:!1,maxWdt:-1,minWdt:-1,constrainHeight:!1,minHgt:-1,valign:"middle"},i=xe(e,"widthConstraint");if(typeof i=="number")t.maxWdt=Number(i),t.minWdt=Number(i);else if(typeof i=="object"){let o=xe(e,["widthConstraint","maximum"]);typeof o=="number"&&(t.maxWdt=Number(o));let r=xe(e,["widthConstraint","minimum"]);typeof r=="number"&&(t.minWdt=Number(r))}let s=xe(e,"heightConstraint");if(typeof s=="number")t.minHgt=Number(s);else if(typeof s=="object"){let o=xe(e,["heightConstraint","minimum"]);typeof o=="number"&&(t.minHgt=Number(o));let r=xe(e,["heightConstraint","valign"]);typeof r=="string"&&(r==="top"||r==="bottom")&&(t.valign=r)}return t}update(e,t){this.setOptions(e,!0),this.propagateFonts(t),j(this.fontOptions,this.constrain(t)),this.fontOptions.chooser=Oi("label",t)}adjustSizes(e){let t=e?e.right+e.left:0;this.fontOptions.constrainWidth&&(this.fontOptions.maxWdt-=t,this.fontOptions.minWdt-=t);let i=e?e.top+e.bottom:0;this.fontOptions.constrainHeight&&(this.fontOptions.minHgt-=i)}addFontOptionsToPile(e,t){for(let i=0;i<t.length;++i)this.addFontToPile(e,t[i])}addFontToPile(e,t){if(t===void 0||t.font===void 0||t.font===null)return;let i=t.font;e.push(i)}getBasicOptions(e){let t={};for(let i=0;i<e.length;++i){let s=e[i],o={};Ye.parseFontString(o,s)&&(s=o),A(s,(r,a)=>{r!==void 0&&(Object.prototype.hasOwnProperty.call(t,a)||(Xt.indexOf(a)!==-1?t[a]={}:t[a]=r))})}return t}getFontOption(e,t,i){let s;for(let o=0;
Line truncated
|
||||
`),s=i.length;if(t.multi)for(let o=0;o<s;o++){let r=this.splitBlocks(i[o],t.multi);if(r!==void 0){if(r.length===0){this.lines.newLine("");continue}if(t.maxWdt>0)for(let a=0;a<r.length;a++){let d=r[a].mod,h=r[a].text;this.splitStringIntoLines(h,d,!0)}else for(let a=0;a<r.length;a++){let d=r[a].mod,h=r[a].text;this.lines.append(h,d)}this.lines.newLine()}}else if(t.maxWdt>0)for(let o=0;o<s;o++)this.splitStringIntoLines(i[o]);else for(let o=0;o<s;o++)this.lines.newLine(i[o]);return this.lines.finalize()}decodeMarkupSystem(e){let t="none";return e==="markdown"||e==="md"?t="markdown":(e===!0||e==="html")&&(t="html"),t}splitHtmlBlocks(e){let t=new Pi(e),i=s=>/&/.test(s)?(t.replace(t.text,"<","<")||t.replace(t.text,"&","&")||t.add("&"),!0):!1;for(;t.position<t.text.length;){let s=t.text.charAt(t.position);t.parseWS(s)||/</.test(s)&&(t.parseStartTag("bold","<b>")||t.parseStartTag("ital","<i>")||t.parseStartTag("mono","<code>")||t.parseEndTag("bold","</b>")||t.parseEndTag("ital","</i>")||t.parseEndTag("mono","</code>"))||i(s)||t.add(s),t.position++}return t.emitBlock(),t.blocks}splitMarkdownBlocks(e){let t=new Pi(e),i=!0,s=o=>/\\/.test(o)?(t.position<this.text.length+1&&(t.position++,o=this.text.charAt(t.position),/ \t/.test(o)?t.spacing=!0:(t.add(o),i=!1)),!0):!1;for(;t.position<t.text.length;){let o=t.text.charAt(t.position);t.parseWS(o)||s(o)||(i||t.spacing)&&(t.parseStartTag("bold","*")||t.parseStartTag("ital","_")||t.parseStartTag("mono","`"))||t.parseEndTag("bold","*","afterBold")||t.parseEndTag("ital","_","afterItal")||t.parseEndTag("mono","`","afterMono")||(t.add(o),i=!1),t.position++}return t.emitBlock(),t.blocks}splitBlocks(e,t){let i=this.decodeMarkupSystem(t);if(i==="none")return[{text:e,mod:"normal"}];if(i==="markdown")return this.splitMarkdownBlocks(e);if(i==="html")return this.splitHtmlBlocks(e)}overMaxWidth(e){let t=this.ctx.measureText(e).width;return this.lines.curWidth()+t>this.parent.fontOptions.maxWdt}getLongestFit(e){let t="",i=0;for(;i<e.length;){let o=t+(t===""?"":" ")+e[i];if(this.overMaxWidth(o))break;t=o,i++}return i}getLongestFitWord(e){let t=0;for(;t<e.length&&!this.overMaxWidth(e.slice(0,t));)t++;return t}splitStringIntoLines(e,t="normal",i=!1){this.parent.getFormattingValues(this.ctx,this.selected,this.hover,t),e=e.replace(/^( +)/g,"$1\r"),e=e.replace(/([^\r][^ ]*)( +)/g,"$1\r$2\r");let s=e.split("\r");for(;s.length>0;){let o=this.getLongestFit(s);if(o===0){let r=s[0],a=this.getLongestFitWord(r);this.lines.newLine(r.slice(0,a),t),s[0]=r.slice(a)}else{let r=o;s[o-1]===" "?o--:s[r]===" "&&r++;let a=s.slice(0,o).join("");o==s.length&&i?this.lines.append(a,t):this.lines.newLine(a,t),s=s.slice(r)}}}},Xt=["bold","ital","boldital","mono"],Ye=class{constructor(e,t,i=!1){this.body=e,this.pointToSelf=!1,this.baseSize=void 0,this.fontOptions={},this.setOptions(t),this.size={top:0,left:0,width:0,height:0,yLine:0},this.isEdgeLabel=i}setOptions(e){if(this.elementOptions=e,this.initFontOptions(e.font),Yt(e.label)?this.labelDirty=!0:e.label=void 0,e.font!==void 0&&e.font!==null){if(typeof e.font=="string")this.baseSize=this.fontOptions.size;else if(typeof e.font=="object"){let t=e.font.size;t!==void 0&&(this.baseSize=t)}}}initFontOptions(e){if(A(Xt,t=>{this.fontOptions[t]={}}),Ye.parseFontString(this.fontOptions,e)){this.fontOptions.vadjust=0;return}A(e,(t,i)=>{t!=null&&typeof t!="object"&&(this.fontOptions[i]=t)})}static parseFontString(e,t){if(!t||typeof t!="string")return!1;let i=t.split(" ");return e.size=+i[0].replace("px",""),e.face=i[1],e.color=i[2],!0}constrain(e){let t={constrainWidth:!1,maxWdt:-1,minWdt:-1,constrainHeight:!1,minHgt:-1,valign:"middle"},i=xe(e,"widthConstraint");if(typeof i=="number")t.maxWdt=Number(i),t.minWdt=Number(i);else if(typeof i=="object"){let o=xe(e,["widthConstraint","maximum"]);typeof o=="number"&&(t.maxWdt=Number(o));let r=xe(e,["widthConstraint","minimum"]);typeof r=="number"&&(t.minWdt=Number(r))}let s=xe(e,"heightConstraint");if(typeof s=="number")t.minHgt=Number(s);else if(typeof s=="object"){let o=xe(e,["heightConstraint","minimum"]);typeof o=="number"&&(t.minHgt=Number(o));let r=xe(e,["heightConstraint","valign"]);typeof r=="string"&&(r==="top"||r==="bottom")&&(t.valign=r)}return t}update(e,t){this.setOptions(e,!0),this.propagateFonts(t),j(this.fontOptions,this.constrain(t)),this.fontOptions.chooser=Oi("label",t)}adjustSizes(e){let t=e?e.right+e.left:0;this.fontOptions.constrainWidth&&(this.fontOptions.maxWdt-=t,this.fontOptions.minWdt-=t);let i=e?e.top+e.bottom:0;this.fontOptions.constrainHeight&&(this.fontOptions.minHgt-=i)}addFontOptionsToPile(e,t){for(let i=0;i<t.length;++i)this.addFontToPile(e,t[i])}addFontToPile(e,t){if(t===void 0||t.font===void 0||t.font===null)return;let i=t.font;e.push(i)}getBasicOptions(e){let t={};for(let i=0;i<e.length;++i){let s=e[i],o={};Ye.parseFontString(o,s)&&(s=o),A(s,(r,a)=>{r!==void 0&&(Object.prototype.hasOwnProperty.call(t,a)||(Xt.indexOf(a)!==-1?t[a]={}:t[a]=r))})}return t}getFontOption(e,t,i){let s;for(let o=0;
Line truncated
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#visgraph {
|
||||
height: 70vh;
|
||||
height: 64vh;
|
||||
}
|
||||
|
||||
html[data-netbox-color-mode=dark] #visgraph {
|
||||
|
||||
@@ -100,9 +100,16 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
||||
})
|
||||
|
||||
graph.on('doubleClick', (params) => {
|
||||
params.nodes.forEach((node) => {
|
||||
window.open(nodes.get(node).href, '_blank')
|
||||
})
|
||||
if (params.nodes.length > 0) {
|
||||
params.nodes.forEach((node) => {
|
||||
window.open(nodes.get(node).href, '_blank')
|
||||
})
|
||||
}
|
||||
else {
|
||||
params.edges.forEach((edge) => {
|
||||
window.open(edges.get(edge).href, '_blank')
|
||||
})
|
||||
}
|
||||
})
|
||||
})()
|
||||
|
||||
|
||||
@@ -48,6 +48,12 @@
|
||||
{% with config=settings.PLUGINS_CONFIG.netbox_topology_views %}
|
||||
<div class="tab-content">
|
||||
|
||||
{# Applied filters #}
|
||||
{% if filter_form %}
|
||||
{% applied_filters model filter_form request.GET %}
|
||||
<hr style="margin-top: 0px;">
|
||||
{% endif %}
|
||||
|
||||
<div class="tab-pane show active" id="networks" role="tabpanel" aria-labelledby="network-tab">
|
||||
<div class="panel-body">
|
||||
<div id="visgraph"></div>
|
||||
|
||||
+192
-115
@@ -9,6 +9,7 @@ from dcim.models import (
|
||||
Cable,
|
||||
CableTermination,
|
||||
Device,
|
||||
device_components,
|
||||
DeviceRole,
|
||||
FrontPort,
|
||||
Interface,
|
||||
@@ -177,6 +178,7 @@ def create_edge(
|
||||
cable: Optional[Cable] = None,
|
||||
wireless: Optional[Dict] = None,
|
||||
power: Optional[bool] = None,
|
||||
interface: Optional[bool] = None,
|
||||
):
|
||||
cable_a_name = (
|
||||
"device A name unknown"
|
||||
@@ -217,12 +219,21 @@ def create_edge(
|
||||
edge["dashes"] = [5, 5, 3, 3]
|
||||
title = "Power Connection"
|
||||
|
||||
elif interface is not None:
|
||||
title = "Interface Connection"
|
||||
edge["width"] = 3
|
||||
edge["dashes"] = [1, 10, 1, 10]
|
||||
edge["arrows"] = {"to": {"enabled": True, "scaleFactor": 0.5}, "from": {"enabled": True, "scaleFactor": 0.5}}
|
||||
edge["color"] = '#f1c232'
|
||||
|
||||
edge[
|
||||
"title"
|
||||
] = f"{title} between<br>{cable_a_dev_name} [{cable_a_name}]<br>{cable_b_dev_name} [{cable_b_name}]"
|
||||
|
||||
if cable is not None and cable.color != "":
|
||||
edge["color"] = "#" + cable.color
|
||||
if cable is not None:
|
||||
edge["href"] = cable.get_absolute_url()
|
||||
if hasattr(cable, 'color') and cable.color != "":
|
||||
edge["color"] = "#" + cable.color
|
||||
|
||||
return edge
|
||||
|
||||
@@ -251,8 +262,11 @@ def get_topology_data(
|
||||
queryset: QuerySet,
|
||||
hide_unconnected: bool,
|
||||
save_coords: bool,
|
||||
show_cables: bool,
|
||||
show_circuit: bool,
|
||||
show_logical_connections: bool,
|
||||
show_power: bool,
|
||||
show_wireless: bool,
|
||||
):
|
||||
if not queryset:
|
||||
return None
|
||||
@@ -266,9 +280,15 @@ def get_topology_data(
|
||||
nodes_powerfeed: Dict[int, PowerFeed] = {}
|
||||
nodes_provider_networks = {}
|
||||
cable_ids = DefaultDict(dict)
|
||||
interface_ids = DefaultDict(dict)
|
||||
ignore_cable_type = settings.PLUGINS_CONFIG["netbox_topology_views"][
|
||||
"ignore_cable_type"
|
||||
]
|
||||
hide_single_cable_logical_conns = bool(
|
||||
settings.PLUGINS_CONFIG["netbox_topology_views"][
|
||||
"hide_single_cable_logical_conns"
|
||||
]
|
||||
)
|
||||
|
||||
device_ids = [d.pk for d in queryset]
|
||||
site_ids = [d.site_id for d in queryset]
|
||||
@@ -314,6 +334,7 @@ def get_topology_data(
|
||||
edges.append(
|
||||
create_edge(
|
||||
edge_id=edge_ids,
|
||||
cable=circuit_termination.cable,
|
||||
circuit=circuit_model,
|
||||
termination_a=termination_a,
|
||||
termination_b=termination_b,
|
||||
@@ -345,15 +366,6 @@ def get_topology_data(
|
||||
for d in nodes_circuits.values():
|
||||
nodes.append(create_node(d, save_coords))
|
||||
|
||||
links: QuerySet[CableTermination] = CableTermination.objects.filter(
|
||||
Q(_device_id__in=device_ids)
|
||||
).select_related("termination_type")
|
||||
|
||||
wlan_links: QuerySet[WirelessLink] = WirelessLink.objects.filter(
|
||||
Q(_interface_a_device_id__in=device_ids)
|
||||
& Q(_interface_b_device_id__in=device_ids)
|
||||
)
|
||||
|
||||
if show_power:
|
||||
power_panels_ids = PowerPanel.objects.filter(
|
||||
Q(site_id__in=site_ids)
|
||||
@@ -407,112 +419,154 @@ def get_topology_data(
|
||||
for d in nodes_powerpanel.values():
|
||||
nodes.append(create_node(d, save_coords))
|
||||
|
||||
for link in links:
|
||||
if link.termination_type.name in ignore_cable_type:
|
||||
continue
|
||||
|
||||
# Normal device cables
|
||||
if link.termination_type.name in supported_termination_types:
|
||||
complete_link = False
|
||||
if link.cable_end == "A":
|
||||
if link.cable_id not in cable_ids:
|
||||
cable_ids[link.cable_id] = {}
|
||||
else:
|
||||
if "B" in cable_ids[link.cable_id]:
|
||||
if cable_ids[link.cable_id]["B"] is not None:
|
||||
complete_link = True
|
||||
elif link.cable_end == "B":
|
||||
if link.cable_id not in cable_ids:
|
||||
cable_ids[link.cable_id] = {}
|
||||
else:
|
||||
if "A" in cable_ids[link.cable_id]:
|
||||
if cable_ids[link.cable_id]["A"] is not None:
|
||||
complete_link = True
|
||||
else:
|
||||
print("Unkown cable end")
|
||||
cable_ids[link.cable_id][link.cable_end] = link
|
||||
|
||||
if complete_link:
|
||||
edge_ids += 1
|
||||
if isinstance(cable_ids[link.cable_id]["B"], CableTermination):
|
||||
if cable_ids[link.cable_id]["B"]._device_id not in nodes_devices:
|
||||
nodes_devices[
|
||||
cable_ids[link.cable_id]["B"]._device_id
|
||||
] = cable_ids[link.cable_id]["B"].termination.device
|
||||
termination_b = {
|
||||
"termination_name": cable_ids[link.cable_id][
|
||||
"B"
|
||||
].termination.name,
|
||||
"termination_device_name": cable_ids[link.cable_id][
|
||||
"B"
|
||||
].termination.device.name,
|
||||
"device_id": cable_ids[link.cable_id][
|
||||
"B"
|
||||
].termination.device_id,
|
||||
}
|
||||
else:
|
||||
termination_b = cable_ids[link.cable_id]["B"]
|
||||
|
||||
if isinstance(cable_ids[link.cable_id]["A"], CableTermination):
|
||||
if cable_ids[link.cable_id]["A"]._device_id not in nodes_devices:
|
||||
nodes_devices[
|
||||
cable_ids[link.cable_id]["A"]._device_id
|
||||
] = cable_ids[link.cable_id]["A"].termination.device
|
||||
termination_a = {
|
||||
"termination_name": cable_ids[link.cable_id][
|
||||
"A"
|
||||
].termination.name,
|
||||
"termination_device_name": cable_ids[link.cable_id][
|
||||
"A"
|
||||
].termination.device.name,
|
||||
"device_id": cable_ids[link.cable_id][
|
||||
"A"
|
||||
].termination.device_id,
|
||||
}
|
||||
else:
|
||||
termination_a = cable_ids[link.cable_id]["A"]
|
||||
|
||||
edges.append(
|
||||
create_edge(
|
||||
edge_id=edge_ids,
|
||||
cable=link.cable,
|
||||
termination_a=termination_a,
|
||||
termination_b=termination_b,
|
||||
)
|
||||
)
|
||||
|
||||
for wlan_link in wlan_links:
|
||||
if wlan_link.interface_a.device_id not in nodes_devices:
|
||||
nodes_devices[
|
||||
wlan_link.interface_a.device.pk
|
||||
] = wlan_link.interface_a.device
|
||||
if wlan_link.interface_b.device_id not in nodes_devices:
|
||||
nodes_devices[
|
||||
wlan_link.interface_b.device.pk
|
||||
] = wlan_link.interface_b.device
|
||||
|
||||
termination_a = {
|
||||
"termination_name": wlan_link.interface_a.name,
|
||||
"termination_device_name": wlan_link.interface_a.device.name,
|
||||
"device_id": wlan_link.interface_a.device_id,
|
||||
}
|
||||
termination_b = {
|
||||
"termination_name": wlan_link.interface_b.name,
|
||||
"termination_device_name": wlan_link.interface_b.device.name,
|
||||
"device_id": wlan_link.interface_b.device_id,
|
||||
}
|
||||
wireless = {"ssid": wlan_link.ssid}
|
||||
|
||||
edge_ids += 1
|
||||
edges.append(
|
||||
create_edge(
|
||||
edge_id=edge_ids,
|
||||
termination_a=termination_a,
|
||||
termination_b=termination_b,
|
||||
wireless=wireless,
|
||||
)
|
||||
if show_logical_connections:
|
||||
interfaces = Interface.objects.filter(
|
||||
Q(_path__is_complete=True) & Q(device_id__in=device_ids)
|
||||
)
|
||||
|
||||
for interface in interfaces:
|
||||
# print('{} {} {} {}'.format(interface.device.name, interface.name, interface._path.destinations[0].device.name, interface._path.destinations[0].name))
|
||||
for destination in interface._path.destinations:
|
||||
if isinstance(destination, device_components.Interface):
|
||||
if destination.device.id not in device_ids:
|
||||
# print('Destination interface not in device queryset, ignoring')
|
||||
continue
|
||||
|
||||
if destination.id in interface_ids:
|
||||
# we've already captured the destination interface, ignore this connection
|
||||
# print('Destination interface already exists, ignoring')
|
||||
continue
|
||||
|
||||
if hide_single_cable_logical_conns and interface.cable_id==destination.cable_id and show_cables:
|
||||
# interface connection is the same as the cable connection, ignore this connection
|
||||
continue
|
||||
|
||||
interface_ids[interface.id]=interface
|
||||
edge_ids += 1
|
||||
termination_a = { "termination_name": interface.name, "termination_device_name": interface.device.name, "device_id": interface.device.id }
|
||||
termination_b = { "termination_name": destination.name, "termination_device_name": destination.device.name, "device_id": destination.device.id }
|
||||
edges.append(create_edge(edge_id=edge_ids, termination_a=termination_a, termination_b=termination_b, interface=True))
|
||||
nodes_devices[interface.device.id] = interface.device
|
||||
nodes_devices[destination.device.id] = destination.device
|
||||
|
||||
if show_cables:
|
||||
links: QuerySet[CableTermination] = CableTermination.objects.filter(
|
||||
Q(_device_id__in=device_ids)
|
||||
).select_related("termination_type")
|
||||
|
||||
for link in links:
|
||||
if link.termination_type.name in ignore_cable_type:
|
||||
continue
|
||||
|
||||
# Normal device cables
|
||||
if link.termination_type.name in supported_termination_types:
|
||||
complete_link = False
|
||||
if link.cable_end == "A":
|
||||
if link.cable_id not in cable_ids:
|
||||
cable_ids[link.cable_id] = {}
|
||||
else:
|
||||
if "B" in cable_ids[link.cable_id]:
|
||||
if cable_ids[link.cable_id]["B"] is not None:
|
||||
complete_link = True
|
||||
elif link.cable_end == "B":
|
||||
if link.cable_id not in cable_ids:
|
||||
cable_ids[link.cable_id] = {}
|
||||
else:
|
||||
if "A" in cable_ids[link.cable_id]:
|
||||
if cable_ids[link.cable_id]["A"] is not None:
|
||||
complete_link = True
|
||||
else:
|
||||
print("Unkown cable end")
|
||||
cable_ids[link.cable_id][link.cable_end] = link
|
||||
|
||||
if complete_link:
|
||||
edge_ids += 1
|
||||
if isinstance(cable_ids[link.cable_id]["B"], CableTermination):
|
||||
if cable_ids[link.cable_id]["B"]._device_id not in nodes_devices:
|
||||
nodes_devices[
|
||||
cable_ids[link.cable_id]["B"]._device_id
|
||||
] = cable_ids[link.cable_id]["B"].termination.device
|
||||
termination_b = {
|
||||
"termination_name": cable_ids[link.cable_id][
|
||||
"B"
|
||||
].termination.name,
|
||||
"termination_device_name": cable_ids[link.cable_id][
|
||||
"B"
|
||||
].termination.device.name,
|
||||
"device_id": cable_ids[link.cable_id][
|
||||
"B"
|
||||
].termination.device_id,
|
||||
}
|
||||
else:
|
||||
termination_b = cable_ids[link.cable_id]["B"]
|
||||
|
||||
if isinstance(cable_ids[link.cable_id]["A"], CableTermination):
|
||||
if cable_ids[link.cable_id]["A"]._device_id not in nodes_devices:
|
||||
nodes_devices[
|
||||
cable_ids[link.cable_id]["A"]._device_id
|
||||
] = cable_ids[link.cable_id]["A"].termination.device
|
||||
termination_a = {
|
||||
"termination_name": cable_ids[link.cable_id][
|
||||
"A"
|
||||
].termination.name,
|
||||
"termination_device_name": cable_ids[link.cable_id][
|
||||
"A"
|
||||
].termination.device.name,
|
||||
"device_id": cable_ids[link.cable_id][
|
||||
"A"
|
||||
].termination.device_id,
|
||||
}
|
||||
else:
|
||||
termination_a = cable_ids[link.cable_id]["A"]
|
||||
|
||||
edges.append(
|
||||
create_edge(
|
||||
edge_id=edge_ids,
|
||||
cable=link.cable,
|
||||
termination_a=termination_a,
|
||||
termination_b=termination_b,
|
||||
)
|
||||
)
|
||||
|
||||
if show_wireless:
|
||||
wlan_links: QuerySet[WirelessLink] = WirelessLink.objects.filter(
|
||||
Q(_interface_a_device_id__in=device_ids)
|
||||
& Q(_interface_b_device_id__in=device_ids)
|
||||
)
|
||||
|
||||
for wlan_link in wlan_links:
|
||||
if wlan_link.interface_a.device_id not in nodes_devices:
|
||||
nodes_devices[
|
||||
wlan_link.interface_a.device.pk
|
||||
] = wlan_link.interface_a.device
|
||||
if wlan_link.interface_b.device_id not in nodes_devices:
|
||||
nodes_devices[
|
||||
wlan_link.interface_b.device.pk
|
||||
] = wlan_link.interface_b.device
|
||||
|
||||
termination_a = {
|
||||
"termination_name": wlan_link.interface_a.name,
|
||||
"termination_device_name": wlan_link.interface_a.device.name,
|
||||
"device_id": wlan_link.interface_a.device_id,
|
||||
}
|
||||
termination_b = {
|
||||
"termination_name": wlan_link.interface_b.name,
|
||||
"termination_device_name": wlan_link.interface_b.device.name,
|
||||
"device_id": wlan_link.interface_b.device_id,
|
||||
}
|
||||
wireless = {"ssid": wlan_link.ssid}
|
||||
|
||||
edge_ids += 1
|
||||
edges.append(
|
||||
create_edge(
|
||||
edge_id=edge_ids,
|
||||
cable=wlan_link,
|
||||
termination_a=termination_a,
|
||||
termination_b=termination_b,
|
||||
wireless=wireless,
|
||||
)
|
||||
)
|
||||
|
||||
for qs_device in queryset:
|
||||
if qs_device.pk not in nodes_devices and not hide_unconnected:
|
||||
nodes_devices[qs_device.pk] = qs_device
|
||||
@@ -540,6 +594,7 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
||||
"device_type", "device_role"
|
||||
)
|
||||
self.queryset = self.filterset(request.GET, self.queryset).qs
|
||||
self.model = self.queryset.model
|
||||
topo_data = None
|
||||
|
||||
if request.GET:
|
||||
@@ -563,22 +618,43 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
||||
if request.GET["show_circuit"] == "on":
|
||||
show_circuit = True
|
||||
|
||||
show_logical_connections = False
|
||||
if "show_logical_connections" in request.GET:
|
||||
if request.GET["show_logical_connections"] == "on" :
|
||||
show_logical_connections = True
|
||||
|
||||
show_cables = False
|
||||
if "show_cables" in request.GET:
|
||||
if request.GET["show_cables"] == "on" :
|
||||
show_cables = True
|
||||
|
||||
show_wireless = False
|
||||
if "show_wireless" in request.GET:
|
||||
if request.GET["show_wireless"] == "on" :
|
||||
show_wireless = True
|
||||
|
||||
if "draw_init" in request.GET:
|
||||
if request.GET["draw_init"].lower() == "true":
|
||||
topo_data = get_topology_data(
|
||||
self.queryset,
|
||||
hide_unconnected,
|
||||
save_coords,
|
||||
show_cables,
|
||||
show_circuit,
|
||||
show_logical_connections,
|
||||
show_power,
|
||||
show_wireless,
|
||||
)
|
||||
else:
|
||||
topo_data = get_topology_data(
|
||||
self.queryset,
|
||||
hide_unconnected,
|
||||
save_coords,
|
||||
show_cables,
|
||||
show_circuit,
|
||||
show_logical_connections,
|
||||
show_power,
|
||||
show_wireless,
|
||||
)
|
||||
else:
|
||||
preselected_device_roles = settings.PLUGINS_CONFIG["netbox_topology_views"][
|
||||
@@ -630,6 +706,7 @@ class TopologyHomeView(PermissionRequiredMixin, View):
|
||||
"filter_form": DeviceFilterForm(request.GET, label_suffix=""),
|
||||
"topology_data": json.dumps(topo_data),
|
||||
"broken_image": find_image_url("role-unknown"),
|
||||
"model": self.model,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user