mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 18:56:00 +00:00
quick export from web
This commit is contained in:
@@ -6,14 +6,21 @@ import { apiCall, apiOff, apiOn } from './api';
|
||||
|
||||
export async function exportElectronFile(dataName, reader, format) {
|
||||
const electron = getElectron();
|
||||
const filters = [{ name: format.label, extensions: [format.extension] }];
|
||||
|
||||
const filePath = await electron.showSaveDialog({
|
||||
filters,
|
||||
defaultPath: `${dataName}.${format.extension}`,
|
||||
properties: ['showOverwriteConfirmation'],
|
||||
});
|
||||
if (!filePath) return;
|
||||
let filePath;
|
||||
let pureFileName;
|
||||
if (electron) {
|
||||
const filters = [{ name: format.label, extensions: [format.extension] }];
|
||||
filePath = electron.showSaveDialog({
|
||||
filters,
|
||||
defaultPath: `${dataName}.${format.extension}`,
|
||||
properties: ['showOverwriteConfirmation'],
|
||||
});
|
||||
} else {
|
||||
const resp = await apiCall('files/generate-uploads-file');
|
||||
filePath = resp.filePath;
|
||||
pureFileName = resp.fileName;
|
||||
}
|
||||
|
||||
const script = new ScriptWriter();
|
||||
|
||||
@@ -50,6 +57,10 @@ export async function exportElectronFile(dataName, reader, format) {
|
||||
apiOff(`runner-done-${runid}`, handleRunnerDone);
|
||||
if (isCanceled) showSnackbarError(`Export ${dataName} canceled`);
|
||||
else showSnackbarInfo(`Export ${dataName} finished`);
|
||||
|
||||
if (!electron) {
|
||||
window.open(`${resolveApi()}/uploads/get?file=${pureFileName}`, '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
apiOn(`runner-done-${runid}`, handleRunnerDone);
|
||||
|
||||
Reference in New Issue
Block a user