open import/export tab function

This commit is contained in:
SPRINX0\prochazka
2024-09-16 12:47:13 +02:00
parent a7846b4adf
commit d255273368
5 changed files with 74 additions and 46 deletions

View File

@@ -42,8 +42,8 @@ export async function exportSqlDump(outputFile, connection, databaseName, pureFi
onOpenResult:
pureFileName && !getElectron()
? () => {
downloadFromApi(`uploads/get?file=${pureFileName}`, 'file.sql');
}
downloadFromApi(`uploads/get?file=${pureFileName}`, 'file.sql');
}
: null,
openResultLabel: 'Download SQL file',
});
@@ -226,17 +226,18 @@ export async function downloadFromApi(route: string, donloadName: string) {
method: 'GET',
headers: resolveApiHeaders(),
})
.then((res) => res.blob())
.then((blob) => {
.then(res => res.blob())
.then(blob => {
const objUrl = URL.createObjectURL(blob);
const a = document.createElement("a");
const a = document.createElement('a');
document.body.appendChild(a);
a.download = donloadName;
a.href = objUrl;
a.click();
a.remove();
setTimeout(() => {
URL.revokeObjectURL(objUrl)
})
})
URL.revokeObjectURL(objUrl);
});
});
}

View File

@@ -0,0 +1,14 @@
import openNewTab from './openNewTab';
export function openImportExportTab(editorProps) {
openNewTab(
{
tabComponent: 'ImportExportTab',
title: 'Import/Export',
icon: 'img export',
},
{
editor: editorProps,
}
);
}