Closes #189, Closes #158: Add draw.io XML export (#277)

* Added export to draw.io XML

* Corrected missing newline at end of file

* init

* moved to api call

---------

Co-authored-by: mattieserver <3049868+mattieserver@users.noreply.github.com>
This commit is contained in:
Mario
2023-04-30 15:22:38 +02:00
committed by GitHub
co-authored by mattieserver
parent 7d23cfc7eb
commit 5e9aaecf9c
11 changed files with 1372 additions and 253 deletions
@@ -133,6 +133,29 @@ function performGraphDownload() {
document.body.removeChild(tempDownloadLink)
}
// Download XML
const downloadXmlButton = document.querySelector('#btnDownloadXml')
downloadXmlButton.addEventListener('click', (e) => {
performXmlDownload()
})
function performXmlDownload() {
const tempDownloadLink = document.createElement('a');
fetch('/api/plugins/netbox_topology_views/xml-export/?' + new URLSearchParams(window.location.search)).then(response => response.text())
.then(data => {
var blob = new Blob([data ], { type: "text/plain" });
tempDownloadLink.setAttribute("href", window.URL.createObjectURL(blob));
tempDownloadLink.setAttribute("download", 'topology.xml');
tempDownloadLink.dataset.downloadurl = ["text/plain", tempDownloadLink.download, tempDownloadLink.href].join(":");
tempDownloadLink.click();
});
}
// Theme switching
const observer = new MutationObserver((mutations) =>
mutations.forEach((mutation) => {