mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 22:16:00 +00:00
open import/export tab function
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
14
packages/web/src/utility/importExportTools.ts
Normal file
14
packages/web/src/utility/importExportTools.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import openNewTab from './openNewTab';
|
||||
|
||||
export function openImportExportTab(editorProps) {
|
||||
openNewTab(
|
||||
{
|
||||
tabComponent: 'ImportExportTab',
|
||||
title: 'Import/Export',
|
||||
icon: 'img export',
|
||||
},
|
||||
{
|
||||
editor: editorProps,
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user