mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
quick export - sql data grid
This commit is contained in:
parent
7467dd2f10
commit
af7c450f56
@ -48,7 +48,6 @@
|
||||
divider: true,
|
||||
},
|
||||
electron && {
|
||||
label: 'Quick export',
|
||||
isQuickExport: true,
|
||||
functionName: 'tableReader',
|
||||
},
|
||||
@ -116,7 +115,7 @@
|
||||
},
|
||||
electron && {
|
||||
label: 'Quick export',
|
||||
isQuickExport: true,
|
||||
functionName: 'tableReader',
|
||||
},
|
||||
{
|
||||
label: 'Export',
|
||||
@ -177,7 +176,7 @@
|
||||
},
|
||||
electron && {
|
||||
label: 'Quick export',
|
||||
isQuickExport: true,
|
||||
functionName: 'tableReader',
|
||||
},
|
||||
{
|
||||
label: 'Export',
|
||||
@ -277,7 +276,7 @@
|
||||
},
|
||||
electron && {
|
||||
label: 'Quick export',
|
||||
isQuickExport: true,
|
||||
functionName: 'tableReader',
|
||||
},
|
||||
{
|
||||
label: 'Export',
|
||||
@ -348,6 +347,7 @@
|
||||
import getConnectionLabel from '../utility/getConnectionLabel';
|
||||
import getElectron from '../utility/getElectron';
|
||||
import { exportElectronFile } from '../utility/exportElectronFile';
|
||||
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
||||
|
||||
export let data;
|
||||
|
||||
@ -397,11 +397,7 @@
|
||||
if (menu.divider) return menu;
|
||||
|
||||
if (menu.isQuickExport) {
|
||||
return {
|
||||
text: menu.label,
|
||||
submenu: $extensions.quickExports.map(fmt => ({
|
||||
text: fmt.label,
|
||||
onClick: async () => {
|
||||
return createQuickExportMenu($extensions, fmt => async () => {
|
||||
const coninfo = await getConnectionInfo(data);
|
||||
exportElectronFile(
|
||||
data.pureName,
|
||||
@ -417,9 +413,7 @@
|
||||
},
|
||||
fmt
|
||||
);
|
||||
},
|
||||
})),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -68,16 +68,23 @@
|
||||
|
||||
return parseInt(response.data.rows[0].count);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import _ from 'lodash';
|
||||
|
||||
import registerCommand from '../commands/registerCommand';
|
||||
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
||||
import { showModal } from '../modals/modalTools';
|
||||
import { extensions } from '../stores';
|
||||
|
||||
import axiosInstance from '../utility/axiosInstance';
|
||||
import { registerMenu } from '../utility/contextMenu';
|
||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
||||
import { exportElectronFile } from '../utility/exportElectronFile';
|
||||
import { getConnectionInfo } from '../utility/metadataLoaders';
|
||||
import openNewTab from '../utility/openNewTab';
|
||||
import ChangeSetGrider from './ChangeSetGrider';
|
||||
|
||||
@ -169,8 +176,29 @@
|
||||
registerMenu(
|
||||
{ command: 'sqlDataGrid.openActiveChart', tag: 'chart' },
|
||||
{ command: 'sqlDataGrid.openQuery', tag: 'export' },
|
||||
{
|
||||
...createQuickExportMenu($extensions, fmt => async () => {
|
||||
const coninfo = await getConnectionInfo({ conid });
|
||||
exportElectronFile(
|
||||
pureName || 'Data',
|
||||
{
|
||||
functionName: 'queryReader',
|
||||
props: {
|
||||
connection: {
|
||||
..._.omit(coninfo, ['_id', 'displayName']),
|
||||
database,
|
||||
},
|
||||
sql: display.getExportQuery(),
|
||||
},
|
||||
},
|
||||
fmt
|
||||
);
|
||||
}),
|
||||
tag: 'export',
|
||||
},
|
||||
{ command: 'sqlDataGrid.export', tag: 'export' }
|
||||
);
|
||||
|
||||
</script>
|
||||
|
||||
<LoadingDataGridCore
|
||||
|
14
packages/web/src/utility/createQuickExportMenu.ts
Normal file
14
packages/web/src/utility/createQuickExportMenu.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { ExtensionsDirectory, QuickExportDefinition } from 'dbgate-types';
|
||||
|
||||
export default function createQuickExportMenu(
|
||||
extensions: ExtensionsDirectory,
|
||||
handler: (fmt: QuickExportDefinition) => Function
|
||||
) {
|
||||
return {
|
||||
text: 'Quick export',
|
||||
submenu: extensions.quickExports.map(fmt => ({
|
||||
text: fmt.label,
|
||||
onClick: handler(fmt),
|
||||
})),
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user