mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 08:43:57 +00:00
next csv params
This commit is contained in:
@@ -37,12 +37,11 @@ class CsvPrepareStream extends stream.Transform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function csvReader({ fileName, encoding = 'utf-8', header = true, delimiter, quoted, limitRows = undefined }) {
|
async function csvReader({ fileName, encoding = 'utf-8', header = true, delimiter, limitRows = undefined }) {
|
||||||
console.log(`Reading file ${fileName}`);
|
console.log(`Reading file ${fileName}`);
|
||||||
const csvStream = csv.parse({
|
const csvStream = csv.parse({
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
delimiter,
|
delimiter,
|
||||||
quoted,
|
|
||||||
skip_lines_with_error: true,
|
skip_lines_with_error: true,
|
||||||
to_line: limitRows ? limitRows + 1 : -1,
|
to_line: limitRows ? limitRows + 1 : -1,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,6 +21,20 @@ const csvFormat: FileFormatDefinition = {
|
|||||||
],
|
],
|
||||||
apiName: 'delimiter',
|
apiName: 'delimiter',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'checkbox',
|
||||||
|
name: 'quoted',
|
||||||
|
label: 'Quoted',
|
||||||
|
apiName: 'quoted',
|
||||||
|
direction: 'target',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'checkbox',
|
||||||
|
name: 'header',
|
||||||
|
label: 'Has header row',
|
||||||
|
apiName: 'header',
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function extractApiParameters(values, direction, format) {
|
|||||||
const pairs = (format.args || [])
|
const pairs = (format.args || [])
|
||||||
.filter((arg) => arg.apiName)
|
.filter((arg) => arg.apiName)
|
||||||
.map((arg) => [arg.apiName, values[`${direction}_${format.storageType}_${arg.name}`]])
|
.map((arg) => [arg.apiName, values[`${direction}_${format.storageType}_${arg.name}`]])
|
||||||
.filter((x) => x[1]);
|
.filter((x) => x[1] != null);
|
||||||
return _.fromPairs(pairs);
|
return _.fromPairs(pairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function FormArgument({ arg, namePrefix }) {
|
|||||||
return <FormTextField label={arg.label} name={name} />;
|
return <FormTextField label={arg.label} name={name} />;
|
||||||
}
|
}
|
||||||
if (arg.type == 'checkbox') {
|
if (arg.type == 'checkbox') {
|
||||||
return <FormCheckboxField label={arg.label} name={name} />;
|
return <FormCheckboxField label={arg.label} name={name} defaultValue={arg.default} />;
|
||||||
}
|
}
|
||||||
if (arg.type == 'select') {
|
if (arg.type == 'select') {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -50,12 +50,14 @@ export function FormTextField({ label, ...other }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FormCheckboxFieldRaw({ name = undefined, ...other }) {
|
export function FormCheckboxFieldRaw({ name = undefined, defaultValue = undefined, ...other }) {
|
||||||
const { values, setFieldValue } = useFormikContext();
|
const { values, setFieldValue } = useFormikContext();
|
||||||
const handleChange = (event) => {
|
const handleChange = (event) => {
|
||||||
setFieldValue(name, event.target.checked);
|
setFieldValue(name, event.target.checked);
|
||||||
};
|
};
|
||||||
return <CheckboxField name={name} checked={!!values[name]} onChange={handleChange} {...other} />;
|
let isChecked = values[name];
|
||||||
|
if (isChecked == null) isChecked = defaultValue;
|
||||||
|
return <CheckboxField name={name} checked={!!isChecked} onChange={handleChange} {...other} />;
|
||||||
// return <Field {...other} as={CheckboxField} />;
|
// return <Field {...other} as={CheckboxField} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user