mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 03:36:01 +00:00
export/import column map support
This commit is contained in:
@@ -42,11 +42,14 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
import Link from '../elements/Link.svelte';
|
||||
import TableControl from '../elements/TableControl.svelte';
|
||||
import CheckboxField from '../forms/CheckboxField.svelte';
|
||||
import { getFormContext } from '../forms/FormProviderCore.svelte';
|
||||
import TextField from '../forms/TextField.svelte';
|
||||
import FontIcon from '../icons/FontIcon.svelte';
|
||||
import ColumnMapModal from '../modals/ColumnMapModal.svelte';
|
||||
import { showModal } from '../modals/modalTools';
|
||||
import { findFileFormat } from '../plugins/fileformats';
|
||||
import { extensions } from '../stores';
|
||||
import getAsArray from '../utility/getAsArray';
|
||||
@@ -189,6 +192,11 @@
|
||||
header: 'Preview',
|
||||
slot: 0,
|
||||
},
|
||||
{
|
||||
fieldName: 'columns',
|
||||
header: 'Columns',
|
||||
slot: 2,
|
||||
},
|
||||
]}
|
||||
>
|
||||
<svelte:fragment slot="0" let:row>
|
||||
@@ -214,6 +222,18 @@
|
||||
)}
|
||||
/>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="2" let:row>
|
||||
{@const columnCount = ($values[`columns_${row}`] || []).filter(x => !x.skip).length}
|
||||
<Link
|
||||
onClick={() => {
|
||||
showModal(ColumnMapModal, {
|
||||
value: $values[`columns_${row}`],
|
||||
onConfirm: value => setFieldValue(`columns_${row}`, value),
|
||||
});
|
||||
}}
|
||||
>{columnCount > 0 ? `(${columnCount} columns)` : '(copy from source)'}
|
||||
</Link>
|
||||
</svelte:fragment>
|
||||
</TableControl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -25,12 +25,20 @@ export default class ScriptWriter {
|
||||
this.packageNames.push(...extractShellApiPlugins(functionName, props));
|
||||
}
|
||||
|
||||
assignValue(variableName, jsonValue) {
|
||||
this.put(`const ${variableName} = ${JSON.stringify(jsonValue)};`);
|
||||
}
|
||||
|
||||
requirePackage(packageName) {
|
||||
this.packageNames.push(packageName);
|
||||
}
|
||||
|
||||
copyStream(sourceVar, targetVar) {
|
||||
this.put(`await dbgateApi.copyStream(${sourceVar}, ${targetVar});`);
|
||||
copyStream(sourceVar, targetVar, colmapVar) {
|
||||
if (colmapVar) {
|
||||
this.put(`await dbgateApi.copyStream(${sourceVar}, ${targetVar}, {columns: ${colmapVar}});`);
|
||||
} else {
|
||||
this.put(`await dbgateApi.copyStream(${sourceVar}, ${targetVar});`);
|
||||
}
|
||||
}
|
||||
|
||||
comment(s) {
|
||||
|
||||
@@ -186,7 +186,14 @@ export default async function createImpExpScript(extensions, values, addEditorIn
|
||||
// @ts-ignore
|
||||
script.assign(targetVar, ...getTargetExpr(extensions, sourceName, values, targetConnection, targetDriver));
|
||||
|
||||
script.copyStream(sourceVar, targetVar);
|
||||
const colmap = (values[`columns_${sourceName}`] || []).filter(x => !x.skip);
|
||||
let colmapVar = null;
|
||||
if (colmap.length > 0) {
|
||||
colmapVar = script.allocVariable();
|
||||
script.assignValue(colmapVar, colmap);
|
||||
}
|
||||
|
||||
script.copyStream(sourceVar, targetVar, colmapVar);
|
||||
script.put();
|
||||
}
|
||||
if (addEditorInfo) {
|
||||
|
||||
Reference in New Issue
Block a user