mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 08:43:57 +00:00
import db from local files
This commit is contained in:
@@ -10,9 +10,15 @@
|
|||||||
function handleClick() {
|
function handleClick() {
|
||||||
if (!disabled) dispatch('click');
|
if (!disabled) dispatch('click');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let domButton;
|
||||||
|
|
||||||
|
export function getBoundingClientRect() {
|
||||||
|
return domButton.getBoundingClientRect();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<input {type} {value} class:disabled {...$$restProps} on:click={handleClick} />
|
<input {type} {value} class:disabled {...$$restProps} on:click={handleClick} bind:this={domButton} />
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
input {
|
input {
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
import FormProvider from '../forms/FormProvider.svelte';
|
import FormProvider from '../forms/FormProvider.svelte';
|
||||||
import FormSubmit from '../forms/FormSubmit.svelte';
|
import FormSubmit from '../forms/FormSubmit.svelte';
|
||||||
|
import { currentDropDownMenu } from '../stores';
|
||||||
|
import { apiCall } from '../utility/api';
|
||||||
import { importSqlDump } from '../utility/exportFileTools';
|
import { importSqlDump } from '../utility/exportFileTools';
|
||||||
import getElectron from '../utility/getElectron';
|
import getElectron from '../utility/getElectron';
|
||||||
import { setUploadListener } from '../utility/uploadFiles';
|
import { setUploadListener } from '../utility/uploadFiles';
|
||||||
@@ -17,6 +19,7 @@
|
|||||||
|
|
||||||
let inputLabel = '(not selected)';
|
let inputLabel = '(not selected)';
|
||||||
let inputFile = null;
|
let inputFile = null;
|
||||||
|
let domButton;
|
||||||
|
|
||||||
const handleSubmit = async values => {
|
const handleSubmit = async values => {
|
||||||
const { value } = values;
|
const { value } = values;
|
||||||
@@ -64,6 +67,23 @@
|
|||||||
inputLabel = path.parse(inputFile).name;
|
inputLabel = path.parse(inputFile).name;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function handleFilesClick() {
|
||||||
|
const rect = domButton.getBoundingClientRect();
|
||||||
|
const left = rect.left;
|
||||||
|
const top = rect.bottom;
|
||||||
|
const files = await apiCall('files/list', { folder: 'sql' });
|
||||||
|
const menu = files.map(({ file }) => ({
|
||||||
|
label: file,
|
||||||
|
onClick: async () => {
|
||||||
|
inputFile = await apiCall('files/get-file-real-path', { folder: 'sql', file });
|
||||||
|
if (inputFile) {
|
||||||
|
inputLabel = file;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
currentDropDownMenu.set({ left, top, items: menu });
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<FormProvider>
|
<FormProvider>
|
||||||
@@ -79,7 +99,8 @@
|
|||||||
<UploadButton />
|
<UploadButton />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<FormStyledButton value="Import from web URL" on:click={handleAddUrl} />
|
<FormStyledButton value="Web URL" on:click={handleAddUrl} />
|
||||||
|
<FormStyledButton value="From files" on:click={handleFilesClick} bind:this={domButton} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<svelte:fragment slot="footer">
|
<svelte:fragment slot="footer">
|
||||||
|
|||||||
Reference in New Issue
Block a user