mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 00:36:01 +00:00
csv delimiter configuration
This commit is contained in:
@@ -26,6 +26,7 @@ import { useUploadsProvider } from '../utility/UploadsProvider';
|
||||
import { FontIcon } from '../icons';
|
||||
import useTheme from '../theme/useTheme';
|
||||
import { fileformats, findFileFormat, getFileFormatDirections } from '../fileformats';
|
||||
import FormArgumentList from '../utility/FormArgumentList';
|
||||
|
||||
const Container = styled.div`
|
||||
// max-height: 50vh;
|
||||
@@ -192,6 +193,7 @@ function SourceTargetConfig({
|
||||
const storageType = values[storageTypeField];
|
||||
const dbinfo = useDatabaseInfo({ conid: values[connectionIdField], database: values[databaseNameField] });
|
||||
const archiveFiles = useArchiveFiles({ folder: values[archiveFolderField] });
|
||||
const format = findFileFormat(storageType);
|
||||
return (
|
||||
<Column>
|
||||
{direction == 'source' && (
|
||||
@@ -297,7 +299,14 @@ function SourceTargetConfig({
|
||||
</>
|
||||
)}
|
||||
|
||||
{isFileStorage(storageType) && direction == 'source' && <FilesInput />}
|
||||
{!!format && direction == 'source' && <FilesInput />}
|
||||
|
||||
{format && format.args && (
|
||||
<FormArgumentList
|
||||
args={format.args.filter((arg) => !arg.direction || arg.direction == direction)}
|
||||
namePrefix={`${direction}_${format.storageType}_`}
|
||||
/>
|
||||
)}
|
||||
</Column>
|
||||
);
|
||||
}
|
||||
@@ -379,6 +388,18 @@ export default function ImportExportConfigurator({ uploadedFile = undefined, onC
|
||||
handleChangePreviewSource();
|
||||
}, [previewSource, supportsPreview]);
|
||||
|
||||
const oldValues = React.useRef({});
|
||||
React.useEffect(() => {
|
||||
const changed = _.pickBy(
|
||||
values,
|
||||
(v, k) => k.startsWith(`source_${values.sourceStorageType}_`) && oldValues.current[k] != v
|
||||
);
|
||||
if (!_.isEmpty(changed)) {
|
||||
handleChangePreviewSource();
|
||||
}
|
||||
oldValues.current = values;
|
||||
}, [values]);
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Wrapper>
|
||||
|
||||
@@ -21,6 +21,7 @@ export default function PreviewDataGrid({ reader, ...other }) {
|
||||
setGrider(null);
|
||||
return;
|
||||
}
|
||||
setErrorMessage(null);
|
||||
setIsLoading(true);
|
||||
const resp = await axios.post('runners/load-reader', reader);
|
||||
// @ts-ignore
|
||||
|
||||
@@ -18,6 +18,14 @@ export function isFileStorage(storageType) {
|
||||
return !!findFileFormat(storageType);
|
||||
}
|
||||
|
||||
function extractApiParameters(values, direction, format) {
|
||||
const pairs = (format.args || [])
|
||||
.filter((arg) => arg.apiName)
|
||||
.map((arg) => [arg.apiName, values[`${direction}_${format.storageType}_${arg.name}`]])
|
||||
.filter((x) => x[1]);
|
||||
return _.fromPairs(pairs);
|
||||
}
|
||||
|
||||
async function getConnection(storageType, conid, database) {
|
||||
if (storageType == 'database' || storageType == 'query') {
|
||||
const conn = await getConnectionInfo({ conid });
|
||||
@@ -58,7 +66,13 @@ function getSourceExpr(sourceName, values, sourceConnection, sourceDriver) {
|
||||
const sourceFile = values[`sourceFile_${sourceName}`];
|
||||
const format = findFileFormat(sourceStorageType);
|
||||
if (format && format.readerFunc) {
|
||||
return [format.readerFunc, sourceFile];
|
||||
return [
|
||||
format.readerFunc,
|
||||
{
|
||||
...sourceFile,
|
||||
...extractApiParameters(values, 'source', format),
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
if (sourceStorageType == 'jsldata') {
|
||||
@@ -103,9 +117,9 @@ function getTargetExpr(sourceName, values, targetConnection, targetDriver) {
|
||||
format.writerFunc,
|
||||
{
|
||||
fileName: getTargetName(sourceName, values),
|
||||
...extractApiParameters(values, 'target', format),
|
||||
},
|
||||
];
|
||||
|
||||
}
|
||||
if (targetStorageType == 'database') {
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user