Skip to content

Commit

Permalink
feat: add the page reference in the export file name, closes #772
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Mar 25, 2024
1 parent 62e3115 commit 2064294
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/renderer/components/WorkspaceTabQueryTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ const props = defineProps({
results: Array as Prop<QueryResult[]>,
connUid: String,
mode: String as Prop<'table' | 'query'>,
page: {
type: Number,
required: false
},
isSelected: Boolean,
elementType: { type: String, default: 'table' }
});
Expand Down Expand Up @@ -868,6 +872,7 @@ const downloadTable = (format: 'csv' | 'json' | 'sql' | 'php', table: string, po
},
client: workspaceClient.value,
table,
page: props.page,
sqlOptions: popup ? { ...sqlExportOptions.value } : null,
csvOptions: popup ? { ...csvExportOptions.value } : null
});
Expand Down
1 change: 1 addition & 0 deletions src/renderer/components/WorkspaceTabTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
v-if="results"
ref="queryTable"
:results="results"
:page="page"
:tab-uid="tabUid"
:conn-uid="connection.uid"
:is-selected="isSelected"
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/libs/exportRows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const exportRows = (args: {
type: 'csv' | 'json'| 'sql' | 'php';
content: object[];
table: string;
page?: number;
client?: ClientCode;
fields?: {
[key: string]: {type: string; datePrecision: number};
Expand Down Expand Up @@ -83,7 +84,7 @@ export const exportRows = (args: {

const file = new Blob([content], { type: mime });
const downloadLink = document.createElement('a');
downloadLink.download = `${args.sqlOptions?.targetTable || args.table}.${args.type}`;
downloadLink.download = `${args.sqlOptions?.targetTable || args.table}${args.page ? `-${args.page}` : ''}.${args.type}`;
downloadLink.href = window.URL.createObjectURL(file);
downloadLink.style.display = 'none';
document.body.appendChild(downloadLink);
Expand Down

0 comments on commit 2064294

Please sign in to comment.