mirror of
https://github.com/dbgate/dbgate
synced 2024-11-12 22:55:31 +00:00
try to guess desired import target+preselect it
This commit is contained in:
parent
a96851b38f
commit
5cc78c4e50
@ -272,7 +272,7 @@ registerCommand({
|
|||||||
icon: 'icon import',
|
icon: 'icon import',
|
||||||
onClick: () =>
|
onClick: () =>
|
||||||
showModal(ImportExportModal, {
|
showModal(ImportExportModal, {
|
||||||
importToArchive: true,
|
importToCurrentTarget: true,
|
||||||
initialValues: { sourceStorageType: getDefaultFileFormat(get(extensions)).storageType },
|
initialValues: { sourceStorageType: getDefaultFileFormat(get(extensions)).storageType },
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
import { getDefaultFileFormat } from '../plugins/fileformats';
|
import { getDefaultFileFormat } from '../plugins/fileformats';
|
||||||
import RunnerOutputFiles from '../query/RunnerOutputFiles.svelte';
|
import RunnerOutputFiles from '../query/RunnerOutputFiles.svelte';
|
||||||
import SocketMessageView from '../query/SocketMessageView.svelte';
|
import SocketMessageView from '../query/SocketMessageView.svelte';
|
||||||
import { currentArchive, extensions, selectedWidget } from '../stores';
|
import { currentArchive, currentDatabase, extensions, selectedWidget } from '../stores';
|
||||||
import axiosInstance from '../utility/axiosInstance';
|
import axiosInstance from '../utility/axiosInstance';
|
||||||
import createRef from '../utility/createRef';
|
import createRef from '../utility/createRef';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
@ -35,11 +35,35 @@
|
|||||||
export let initialValues;
|
export let initialValues;
|
||||||
export let uploadedFile = undefined;
|
export let uploadedFile = undefined;
|
||||||
export let openedFile = undefined;
|
export let openedFile = undefined;
|
||||||
export let importToArchive = false;
|
export let importToCurrentTarget = false;
|
||||||
|
|
||||||
const refreshArchiveFolderRef = createRef(null);
|
const refreshArchiveFolderRef = createRef(null);
|
||||||
|
|
||||||
$: targetArchiveFolder = importToArchive ? `import-${moment().format('YYYY-MM-DD-hh-mm-ss')}` : $currentArchive;
|
function detectCurrentTarget() {
|
||||||
|
if (!importToCurrentTarget) return {};
|
||||||
|
|
||||||
|
if ($currentDatabase && $selectedWidget != 'archive') {
|
||||||
|
return {
|
||||||
|
targetStorageType: 'database',
|
||||||
|
targetConnectionId: $currentDatabase?.connection?._id,
|
||||||
|
targetDatabaseName: $currentDatabase?.name,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($currentArchive == 'default') {
|
||||||
|
return {
|
||||||
|
targetStorageType: 'archive',
|
||||||
|
targetArchiveFolder: `import-${moment().format('YYYY-MM-DD-hh-mm-ss')}`,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
targetStorageType: 'archive',
|
||||||
|
targetArchiveFolder: $currentArchive,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// $: targetArchiveFolder = importToArchive ? `import-${moment().format('YYYY-MM-DD-hh-mm-ss')}` : $currentArchive;
|
||||||
|
|
||||||
$: effect = useEffect(() => registerRunnerDone(runnerId));
|
$: effect = useEffect(() => registerRunnerDone(runnerId));
|
||||||
|
|
||||||
@ -107,9 +131,10 @@
|
|||||||
<FormProvider
|
<FormProvider
|
||||||
initialValues={{
|
initialValues={{
|
||||||
sourceStorageType: 'database',
|
sourceStorageType: 'database',
|
||||||
targetStorageType: importToArchive ? 'archive' : getDefaultFileFormat($extensions).storageType,
|
targetStorageType: getDefaultFileFormat($extensions).storageType,
|
||||||
|
targetArchiveFolder: $currentArchive,
|
||||||
sourceArchiveFolder: $currentArchive,
|
sourceArchiveFolder: $currentArchive,
|
||||||
targetArchiveFolder,
|
...detectCurrentTarget(),
|
||||||
...initialValues,
|
...initialValues,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -89,7 +89,7 @@ export function openElectronFileCore(filePath, extensions) {
|
|||||||
storageType: format.storageType,
|
storageType: format.storageType,
|
||||||
shortName: parsed.name,
|
shortName: parsed.name,
|
||||||
},
|
},
|
||||||
importToArchive: true,
|
importToCurrentTarget: true,
|
||||||
initialValues: {
|
initialValues: {
|
||||||
sourceStorageType: format.storageType,
|
sourceStorageType: format.storageType,
|
||||||
},
|
},
|
||||||
|
@ -66,7 +66,7 @@ export default function uploadFiles(files) {
|
|||||||
if (findFileFormat(ext, fileData.storageType)) {
|
if (findFileFormat(ext, fileData.storageType)) {
|
||||||
showModal(ImportExportModal, {
|
showModal(ImportExportModal, {
|
||||||
uploadedFile: fileData,
|
uploadedFile: fileData,
|
||||||
importToArchive: true,
|
importToCurrentTarget: true,
|
||||||
initialValues: {
|
initialValues: {
|
||||||
sourceStorageType: fileData.storageType,
|
sourceStorageType: fileData.storageType,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user