import-export advanced config

This commit is contained in:
Jan Prochazka 2020-12-08 17:34:40 +01:00
parent cc11e63cd7
commit e0c91214fd
3 changed files with 17 additions and 20 deletions

View File

@ -2,11 +2,11 @@ import _ from 'lodash';
import { extractShellApiFunctionName, extractShellApiPlugins } from 'dbgate-tools';
export default class ScriptWriter {
constructor() {
constructor(varCount) {
this.s = '';
this.packageNames = [];
// this.engines = [];
this.varCount = 0;
this.varCount = parseInt(varCount) || 0;
}
allocVariable(prefix = 'var') {
@ -32,22 +32,14 @@ export default class ScriptWriter {
this.put(`// ${s}`);
}
getScript(extensions) {
// if (this.packageNames.length > 0) {
// this.comment('@packages');
// this.comment(JSON.stringify(this.packageNames));
// }
// if (this.engines.length > 0) {
// this.comment('@engines');
// this.comment(JSON.stringify(this.engines));
// }
getScript(extensions, schedule) {
const packageNames = this.packageNames;
return (
_.uniq(packageNames)
.map((packageName) => `// @require ${packageName}\n`)
.join('') +
'\n' +
this.s
);
let prefix = _.uniq(packageNames)
.map((packageName) => `// @require ${packageName}\n`)
.join('');
if (schedule) prefix += `// @schedule ${schedule}`;
if (prefix) prefix += '\n';
return prefix + this.s;
}
}

View File

@ -150,7 +150,7 @@ function getTargetExpr(extensions, sourceName, values, targetConnection, targetD
}
export default async function createImpExpScript(extensions, values, addEditorInfo = true) {
const script = new ScriptWriter();
const script = new ScriptWriter(values.startVariableIndex || 0);
const [sourceConnection, sourceDriver] = await getConnection(
extensions,
@ -182,7 +182,7 @@ export default async function createImpExpScript(extensions, values, addEditorIn
script.comment('@ImportExportConfigurator');
script.comment(JSON.stringify(values));
}
return script.getScript(extensions);
return script.getScript(extensions, values.schedule);
}
export function getActionOptions(extensions, source, values, targetDbinfo) {

View File

@ -24,6 +24,7 @@ import LargeButton, { LargeFormButton } from '../widgets/LargeButton';
import { getDefaultFileFormat } from '../utility/fileformats';
import useExtensions from '../utility/useExtensions';
import { FormProvider, useForm } from '../utility/FormProvider';
import { FormTextField } from '../utility/forms';
const headerHeight = '60px';
const footerHeight = '100px';
@ -213,6 +214,10 @@ export default function ImportExportModal({
<PreviewDataGrid reader={previewReader} />
</WidgetColumnBarItem>
)}
<WidgetColumnBarItem title="Advanced configuration" name="config" collapsed>
<FormTextField label="Schedule" name="schedule" />
<FormTextField label="Start variable index" name="startVariableIndex" />
</WidgetColumnBarItem>
</WidgetColumnBar>
</WidgetColumnWrapper>
</Wrapper>