fixed xml-export path construction
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -81,7 +81,7 @@ const coordSaveCheckbox = document.querySelector('#id_save_coords')
|
|||||||
async ([nodeId, nodePosition]) => {
|
async ([nodeId, nodePosition]) => {
|
||||||
window.nodes.update({id: parseInt(nodeId), physics: false, x: nodePosition.x, y: nodePosition.y});
|
window.nodes.update({id: parseInt(nodeId), physics: false, x: nodePosition.x, y: nodePosition.y});
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
'/api/plugins/netbox_topology_views/save-coords/save_coords/',
|
'/' + basePath + 'api/plugins/netbox_topology_views/save-coords/save_coords/',
|
||||||
{
|
{
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -171,7 +171,7 @@ function performXmlDownload() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
fetch('/api/plugins/netbox_topology_views/xml-export/?' + xml_search_options).then(response => response.text())
|
fetch('/' + basePath + 'api/plugins/netbox_topology_views/xml-export/?' + xml_search_options).then(response => response.text())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
var blob = new Blob([data ], { type: "text/plain" });
|
var blob = new Blob([data ], { type: "text/plain" });
|
||||||
|
|
||||||
|
|||||||
@@ -35,12 +35,11 @@ def image_static_url(path: Path) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def get_image_from_url(url: str) -> str:
|
def get_image_from_url(url: str) -> str:
|
||||||
url_path = settings.BASE_PATH + settings.STATIC_URL
|
|
||||||
if sys.version_info >= (3,9,0):
|
if sys.version_info >= (3,9,0):
|
||||||
return url.removeprefix(url_path)
|
return url.removeprefix(settings.STATIC_URL)
|
||||||
else:
|
else:
|
||||||
if url.startswith(url_path):
|
if url.startswith(settings.STATIC_URL):
|
||||||
url_new = url[len(url_path):]
|
url_new = url[len(settings.STATIC_URL):]
|
||||||
return url_new
|
return url_new
|
||||||
else:
|
else:
|
||||||
return url
|
return url
|
||||||
@@ -250,7 +249,7 @@ def export_data_to_xml(data: dict):
|
|||||||
noPositionX = 0
|
noPositionX = 0
|
||||||
noPositionY = 1000
|
noPositionY = 1000
|
||||||
for node in data['nodes']:
|
for node in data['nodes']:
|
||||||
with open(str(Path(settings.BASE_DIR)) + node['image'], "rb") as img:
|
with open(settings.STATIC_ROOT + '/' + get_image_from_url(node['image']), "rb") as img:
|
||||||
svg = base64.b64encode(img.read()).decode('utf-8')
|
svg = base64.b64encode(img.read()).decode('utf-8')
|
||||||
mxcell = doc.createElement('mxCell')
|
mxcell = doc.createElement('mxCell')
|
||||||
mxcell.setAttribute('id', 'node_' + str(node['id']))
|
mxcell.setAttribute('id', 'node_' + str(node['id']))
|
||||||
|
|||||||
Reference in New Issue
Block a user