diff --git a/src/renderer/components/ModalProcessesList.vue b/src/renderer/components/ModalProcessesList.vue index 4074470f..2b9b3559 100644 --- a/src/renderer/components/ModalProcessesList.vue +++ b/src/renderer/components/ModalProcessesList.vue @@ -315,7 +315,7 @@ const downloadTable = (format: 'csv' | 'json') => { exportRows({ type: format, content: sortedResults.value, - filename: 'processes' + table: 'processes' }); }; diff --git a/src/renderer/components/WorkspaceTabQueryTable.vue b/src/renderer/components/WorkspaceTabQueryTable.vue index a5c00532..b8d4c71b 100644 --- a/src/renderer/components/WorkspaceTabQueryTable.vue +++ b/src/renderer/components/WorkspaceTabQueryTable.vue @@ -131,6 +131,7 @@ import * as moment from 'moment'; import { useI18n } from 'vue-i18n'; import { TableField, QueryResult } from 'common/interfaces/antares'; import { TableUpdateParams } from 'common/interfaces/tableApis'; +import { jsonToSqlInsert } from 'common/libs/sqlUtils'; const { t } = useI18n(); @@ -413,11 +414,22 @@ const copyCell = () => { navigator.clipboard.writeText(valueToCopy); }; -const copyRow = () => { +const copyRow = (format: string) => { const row = localResults.value.find((row: any) => selectedRows.value.includes(row._antares_id)); const rowToCopy = JSON.parse(JSON.stringify(row)); delete rowToCopy._antares_id; - navigator.clipboard.writeText(JSON.stringify(rowToCopy)); + if (format === 'json') + navigator.clipboard.writeText(JSON.stringify(rowToCopy)); + else if (format === 'sql') { + navigator.clipboard.writeText(jsonToSqlInsert({ + json: rowToCopy, + client: workspaceClient.value, + fields: fieldsObj.value as { + [key: string]: {type: string; datePrecision: number}; + }, + table: getTable(resultsetIndex.value) + })); + } }; const duplicateRow = () => { diff --git a/src/renderer/components/WorkspaceTabQueryTableContext.vue b/src/renderer/components/WorkspaceTabQueryTableContext.vue index 9f2b19c1..daf705a5 100644 --- a/src/renderer/components/WorkspaceTabQueryTableContext.vue +++ b/src/renderer/components/WorkspaceTabQueryTableContext.vue @@ -19,10 +19,19 @@
- {{ t('word.row', 1) }} + {{ t('word.row', 1) }} (JSON) + +
+
+ + {{ t('word.row', 1) }} (SQL INSERT)
@@ -98,8 +107,8 @@ const copyCell = () => { closeContext(); }; -const copyRow = () => { - emit('copy-row'); +const copyRow = (format: string) => { + emit('copy-row', format); closeContext(); };