mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-11-26 09:56:20 -05:00
refactor downloading file
This commit is contained in:
parent
372e61ed7c
commit
82c67bb71c
2 changed files with 36 additions and 8 deletions
|
|
@ -84,6 +84,7 @@ import ElectronUtils from "../../js/ElectronUtils";
|
|||
import Interface from "./Interface.vue";
|
||||
import Utils from "../../js/Utils";
|
||||
import ImportInterfacesModal from "./ImportInterfacesModal.vue";
|
||||
import DownloadUtils from "../../js/DownloadUtils";
|
||||
|
||||
export default {
|
||||
name: 'InterfacesPage',
|
||||
|
|
@ -250,17 +251,16 @@ export default {
|
|||
},
|
||||
async exportInterfaces() {
|
||||
try {
|
||||
|
||||
// fetch exported interfaces
|
||||
const response = await window.axios.get('/api/v1/reticulum/interfaces/export', {
|
||||
responseType: 'blob'
|
||||
});
|
||||
|
||||
const url = window.URL.createObjectURL(new Blob([response.data]));
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', 'reticulum_interfaces');
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
|
||||
// download file to browser
|
||||
const blob = new Blob([response.data]);
|
||||
DownloadUtils.downloadFile("meshchat_interfaces", blob);
|
||||
|
||||
} catch(e) {
|
||||
DialogUtils.alert("Failed to export interfaces");
|
||||
console.error(e);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue