mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-17 04:00:48 +01:00
feat: option to choose the target table of an SQL INSERT exportation, closes #556
This commit is contained in:
parent
96e1ceb1d2
commit
c48266c336
@ -120,11 +120,21 @@
|
||||
<template #header>
|
||||
<div class="d-flex">
|
||||
<i class="mdi mdi-24px mdi-file-export mr-1" />
|
||||
<span class="cut-text">{{ t('message.newInserStmtEvery') }}:</span>
|
||||
<span class="cut-text">{{ t('message.sqlExportOptions') }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #body>
|
||||
<div class="columns">
|
||||
<label class="column col-12 h6 mb-2 cut-text">{{ t('message.targetTable') }}</label>
|
||||
<div class="column col-12">
|
||||
<input
|
||||
v-model.number="sqlExportOptions.targetTable"
|
||||
type="text"
|
||||
class="form-input"
|
||||
:placeholder="chunkModalRequest"
|
||||
>
|
||||
</div>
|
||||
<label class="column col-12 h6 mb-2 mt-4 cut-text">{{ t('message.newInserStmtEvery') }}:</label>
|
||||
<div class="column col-6">
|
||||
<input
|
||||
v-model.number="sqlExportOptions.sqlInsertAfter"
|
||||
@ -214,7 +224,8 @@ const isEditingRow = ref(false);
|
||||
const chunkModalRequest: Ref<false | string> = ref(false);
|
||||
const sqlExportOptions = ref({
|
||||
sqlInsertAfter: 250,
|
||||
sqlInsertDivider: 'bytes' as 'bytes' | 'rows'
|
||||
sqlInsertDivider: 'bytes' as 'bytes' | 'rows',
|
||||
targetTable: ''
|
||||
});
|
||||
|
||||
const workspaceSchema = computed(() => getWorkspace(props.connUid).breadcrumbs.schema);
|
||||
@ -704,6 +715,11 @@ const downloadTable = (format: 'csv' | 'json' | 'sql', table: string, chunks = f
|
||||
if (!sortedResults.value) return;
|
||||
|
||||
if (format === 'sql' && !chunks && customizations.value.exportByChunks) {
|
||||
sqlExportOptions.value = {
|
||||
sqlInsertAfter: 250,
|
||||
sqlInsertDivider: 'bytes' as 'bytes' | 'rows',
|
||||
targetTable: ''
|
||||
};
|
||||
chunkModalRequest.value = table;
|
||||
return;
|
||||
}
|
||||
|
@ -340,7 +340,9 @@ export const enUS = {
|
||||
showTableSizeDescription: 'MySQL/MariaDB only. Enable this option may affects performance on schema with many tables.',
|
||||
searchForSchemas: 'Search for schemas',
|
||||
switchSearchMethod: 'Switch search method',
|
||||
noResultsPresent: 'No results present'
|
||||
noResultsPresent: 'No results present',
|
||||
sqlExportOptions: 'SQL export options',
|
||||
targetTable: 'Target table'
|
||||
},
|
||||
faker: {
|
||||
address: 'Address',
|
||||
|
@ -9,7 +9,7 @@ export const exportRows = (args: {
|
||||
fields?: {
|
||||
[key: string]: {type: string; datePrecision: number};
|
||||
};
|
||||
sqlOptions?: {sqlInsertAfter: number; sqlInsertDivider: 'bytes' | 'rows'};
|
||||
sqlOptions?: {sqlInsertAfter: number; sqlInsertDivider: 'bytes' | 'rows'; targetTable: string};
|
||||
}) => {
|
||||
let mime;
|
||||
let content;
|
||||
@ -41,7 +41,7 @@ export const exportRows = (args: {
|
||||
client:
|
||||
args.client,
|
||||
fields: args.fields,
|
||||
table: args.table,
|
||||
table: args.sqlOptions.targetTable || args.table,
|
||||
options: args.sqlOptions
|
||||
});
|
||||
|
||||
@ -58,7 +58,7 @@ export const exportRows = (args: {
|
||||
|
||||
const file = new Blob([content], { type: mime });
|
||||
const downloadLink = document.createElement('a');
|
||||
downloadLink.download = `${args.table}.${args.type}`;
|
||||
downloadLink.download = `${args.sqlOptions?.targetTable || args.table}.${args.type}`;
|
||||
downloadLink.href = window.URL.createObjectURL(file);
|
||||
downloadLink.style.display = 'none';
|
||||
document.body.appendChild(downloadLink);
|
||||
|
Loading…
x
Reference in New Issue
Block a user