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