mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
Merge branch 'master' into redis
This commit is contained in:
commit
98a9859216
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "4.7.2",
|
"version": "4.7.3-beta.1",
|
||||||
"name": "dbgate-all",
|
"name": "dbgate-all",
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*",
|
"packages/*",
|
||||||
|
@ -141,8 +141,8 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
generateUploadsFile_meta: true,
|
generateUploadsFile_meta: true,
|
||||||
async generateUploadsFile() {
|
async generateUploadsFile({ extension }) {
|
||||||
const fileName = `${uuidv1()}.html`;
|
const fileName = `${uuidv1()}.${extension || 'html'}`;
|
||||||
return {
|
return {
|
||||||
fileName,
|
fileName,
|
||||||
filePath: path.join(uploadsdir(), fileName),
|
filePath: path.join(uploadsdir(), fileName),
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
import { archiveFilesAsDataSheets, currentArchive, extensions, getCurrentDatabase } from '../stores';
|
import { archiveFilesAsDataSheets, currentArchive, extensions, getCurrentDatabase } from '../stores';
|
||||||
|
|
||||||
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
||||||
import { exportElectronFile } from '../utility/exportElectronFile';
|
import { exportQuickExportFile } from '../utility/exportFileTools';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
import AppObjectCore from './AppObjectCore.svelte';
|
import AppObjectCore from './AppObjectCore.svelte';
|
||||||
import getConnectionLabel from '../utility/getConnectionLabel';
|
import getConnectionLabel from '../utility/getConnectionLabel';
|
||||||
@ -169,31 +169,33 @@
|
|||||||
{ text: 'Delete', onClick: handleDelete },
|
{ text: 'Delete', onClick: handleDelete },
|
||||||
{ text: 'Rename', onClick: handleRename },
|
{ text: 'Rename', onClick: handleRename },
|
||||||
data.fileType == 'jsonl' &&
|
data.fileType == 'jsonl' &&
|
||||||
createQuickExportMenu($extensions, fmt => async () => {
|
createQuickExportMenu(
|
||||||
exportElectronFile(
|
fmt => async () => {
|
||||||
data.fileName,
|
exportQuickExportFile(
|
||||||
{
|
data.fileName,
|
||||||
functionName: 'archiveReader',
|
{
|
||||||
props: {
|
functionName: 'archiveReader',
|
||||||
fileName: data.fileName,
|
props: {
|
||||||
folderName: data.folderName,
|
fileName: data.fileName,
|
||||||
|
folderName: data.folderName,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
fmt
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Export',
|
||||||
|
onClick: () => {
|
||||||
|
showModal(ImportExportModal, {
|
||||||
|
initialValues: {
|
||||||
|
sourceStorageType: 'archive',
|
||||||
|
sourceArchiveFolder: data.folderName,
|
||||||
|
sourceList: [data.fileName],
|
||||||
|
},
|
||||||
|
});
|
||||||
},
|
},
|
||||||
fmt
|
}
|
||||||
);
|
),
|
||||||
}),
|
|
||||||
data.fileType == 'jsonl' && {
|
|
||||||
text: 'Export',
|
|
||||||
onClick: () => {
|
|
||||||
showModal(ImportExportModal, {
|
|
||||||
initialValues: {
|
|
||||||
sourceStorageType: 'archive',
|
|
||||||
sourceArchiveFolder: data.folderName,
|
|
||||||
sourceList: [data.fileName],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data.fileType.endsWith('.sql') && { text: 'Open SQL', onClick: handleOpenSqlFile },
|
data.fileType.endsWith('.sql') && { text: 'Open SQL', onClick: handleOpenSqlFile },
|
||||||
data.fileType.endsWith('.yaml') && { text: 'Open YAML', onClick: handleOpenYamlFile },
|
data.fileType.endsWith('.yaml') && { text: 'Open YAML', onClick: handleOpenYamlFile },
|
||||||
];
|
];
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" context="module">
|
||||||
export const extractKey = ({ schemaName, pureName }) => (schemaName ? `${schemaName}.${pureName}` : pureName);
|
export const extractKey = ({ schemaName, pureName }) => (schemaName ? `${schemaName}.${pureName}` : pureName);
|
||||||
export const createMatcher = ({ pureName }) => filter => filterName(filter, pureName);
|
export const createMatcher = ({ schemaName, pureName }) => filter => filterName(filter, pureName, schemaName);
|
||||||
const electron = getElectron();
|
const electron = getElectron();
|
||||||
|
|
||||||
export const databaseObjectIcons = {
|
export const databaseObjectIcons = {
|
||||||
@ -60,12 +60,9 @@
|
|||||||
{
|
{
|
||||||
divider: true,
|
divider: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
isQuickExport: true,
|
|
||||||
functionName: 'tableReader',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: 'Export',
|
label: 'Export',
|
||||||
|
functionName: 'tableReader',
|
||||||
isExport: true,
|
isExport: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -131,13 +128,10 @@
|
|||||||
{
|
{
|
||||||
divider: true,
|
divider: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
isQuickExport: true,
|
|
||||||
functionName: 'tableReader',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: 'Export',
|
label: 'Export',
|
||||||
isExport: true,
|
isExport: true,
|
||||||
|
functionName: 'tableReader',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Open as data sheet',
|
label: 'Open as data sheet',
|
||||||
@ -196,13 +190,10 @@
|
|||||||
{
|
{
|
||||||
divider: true,
|
divider: true,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
isQuickExport: true,
|
|
||||||
functionName: 'tableReader',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: 'Export',
|
label: 'Export',
|
||||||
isExport: true,
|
isExport: true,
|
||||||
|
functionName: 'tableReader',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Open as data sheet',
|
label: 'Open as data sheet',
|
||||||
@ -304,13 +295,10 @@
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
isQuickExport: true,
|
|
||||||
functionName: 'tableReader',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: 'Export',
|
label: 'Export',
|
||||||
isExport: true,
|
isExport: true,
|
||||||
|
functionName: 'tableReader',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Drop collection',
|
label: 'Drop collection',
|
||||||
@ -411,40 +399,45 @@
|
|||||||
.map(menu => {
|
.map(menu => {
|
||||||
if (menu.divider) return menu;
|
if (menu.divider) return menu;
|
||||||
|
|
||||||
if (menu.isQuickExport) {
|
if (menu.isExport) {
|
||||||
return createQuickExportMenu(getExtensions(), fmt => async () => {
|
return createQuickExportMenu(
|
||||||
const coninfo = await getConnectionInfo(data);
|
fmt => async () => {
|
||||||
exportElectronFile(
|
const coninfo = await getConnectionInfo(data);
|
||||||
data.pureName,
|
exportQuickExportFile(
|
||||||
{
|
data.pureName,
|
||||||
functionName: menu.functionName,
|
{
|
||||||
props: {
|
functionName: menu.functionName,
|
||||||
connection: {
|
props: {
|
||||||
..._.omit(coninfo, ['_id', 'displayName']),
|
connection: {
|
||||||
..._.pick(data, ['database']),
|
..._.omit(coninfo, ['_id', 'displayName']),
|
||||||
|
..._.pick(data, ['database']),
|
||||||
|
},
|
||||||
|
..._.pick(data, ['pureName', 'schemaName']),
|
||||||
},
|
},
|
||||||
..._.pick(data, ['pureName', 'schemaName']),
|
|
||||||
},
|
},
|
||||||
|
fmt
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
onClick: () => {
|
||||||
|
showModal(ImportExportModal, {
|
||||||
|
initialValues: {
|
||||||
|
sourceStorageType: 'database',
|
||||||
|
sourceConnectionId: data.conid,
|
||||||
|
sourceDatabaseName: data.database,
|
||||||
|
sourceSchemaName: data.schemaName,
|
||||||
|
sourceList: [data.pureName],
|
||||||
|
},
|
||||||
|
});
|
||||||
},
|
},
|
||||||
fmt
|
}
|
||||||
);
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
text: menu.label,
|
text: menu.label,
|
||||||
onClick: async () => {
|
onClick: async () => {
|
||||||
if (menu.isExport) {
|
if (menu.isOpenFreeTable) {
|
||||||
showModal(ImportExportModal, {
|
|
||||||
initialValues: {
|
|
||||||
sourceStorageType: 'database',
|
|
||||||
sourceConnectionId: data.conid,
|
|
||||||
sourceDatabaseName: data.database,
|
|
||||||
sourceSchemaName: data.schemaName,
|
|
||||||
sourceList: [data.pureName],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else if (menu.isOpenFreeTable) {
|
|
||||||
const coninfo = await getConnectionInfo(data);
|
const coninfo = await getConnectionInfo(data);
|
||||||
openNewTab({
|
openNewTab({
|
||||||
title: data.pureName,
|
title: data.pureName,
|
||||||
@ -620,7 +613,7 @@
|
|||||||
import SqlGeneratorModal from '../modals/SqlGeneratorModal.svelte';
|
import SqlGeneratorModal from '../modals/SqlGeneratorModal.svelte';
|
||||||
import getConnectionLabel from '../utility/getConnectionLabel';
|
import getConnectionLabel from '../utility/getConnectionLabel';
|
||||||
import getElectron from '../utility/getElectron';
|
import getElectron from '../utility/getElectron';
|
||||||
import { exportElectronFile } from '../utility/exportElectronFile';
|
import { exportQuickExportFile } from '../utility/exportFileTools';
|
||||||
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
||||||
import ConfirmSqlModal from '../modals/ConfirmSqlModal.svelte';
|
import ConfirmSqlModal from '../modals/ConfirmSqlModal.svelte';
|
||||||
import { alterDatabaseDialog, renameDatabaseObjectDialog } from '../utility/alterDatabaseTools';
|
import { alterDatabaseDialog, renameDatabaseObjectDialog } from '../utility/alterDatabaseTools';
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" context="module">
|
||||||
import { getContext, setContext } from 'svelte';
|
import { getContext, setContext } from 'svelte';
|
||||||
import { extensions } from '../stores';
|
|
||||||
import { createQuickExportMenuItems } from '../utility/createQuickExportMenu';
|
import { createQuickExportMenuItems } from '../utility/createQuickExportMenu';
|
||||||
|
|
||||||
import createRef from '../utility/createRef';
|
import createRef from '../utility/createRef';
|
||||||
@ -24,23 +23,21 @@
|
|||||||
import ToolStripCommandButton from './ToolStripCommandButton.svelte';
|
import ToolStripCommandButton from './ToolStripCommandButton.svelte';
|
||||||
import ToolStripDropDownButton from './ToolStripDropDownButton.svelte';
|
import ToolStripDropDownButton from './ToolStripDropDownButton.svelte';
|
||||||
|
|
||||||
const electron = getElectron();
|
|
||||||
|
|
||||||
export let quickExportHandlerRef = null;
|
export let quickExportHandlerRef = null;
|
||||||
export let command = 'sqlDataGrid.export';
|
export let command = 'sqlDataGrid.export';
|
||||||
export let label = 'Advanced settings';
|
export let label = 'Export';
|
||||||
|
|
||||||
function getExportMenu() {
|
function getExportMenu() {
|
||||||
return [
|
return [
|
||||||
quickExportHandlerRef?.value ? createQuickExportMenuItems($extensions, quickExportHandlerRef?.value) : null,
|
quickExportHandlerRef?.value
|
||||||
{ divider: true },
|
? createQuickExportMenuItems(quickExportHandlerRef?.value, { command })
|
||||||
{ command, text: label },
|
: { command },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if quickExportHandlerRef && electron}
|
{#if quickExportHandlerRef}
|
||||||
<ToolStripDropDownButton menu={getExportMenu} label="Export" icon="icon export" />
|
<ToolStripDropDownButton menu={getExportMenu} {label} icon="icon export" />
|
||||||
{:else}
|
{:else}
|
||||||
<ToolStripCommandButton {command} />
|
<ToolStripCommandButton {command} />
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
import contextMenu, { getContextMenu, registerMenu } from '../utility/contextMenu';
|
import contextMenu, { getContextMenu, registerMenu } from '../utility/contextMenu';
|
||||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||||
import { saveFileToDisk } from '../utility/exportElectronFile';
|
import { saveFileToDisk } from '../utility/exportFileTools';
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
export let title;
|
export let title;
|
||||||
|
@ -26,7 +26,7 @@ import { removeLocalStorage } from '../utility/storageCache';
|
|||||||
import { showSnackbarSuccess } from '../utility/snackbar';
|
import { showSnackbarSuccess } from '../utility/snackbar';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
import runCommand from './runCommand';
|
import runCommand from './runCommand';
|
||||||
import { openWebLink } from '../utility/exportElectronFile';
|
import { openWebLink } from '../utility/exportFileTools';
|
||||||
import { getSettings } from '../utility/metadataLoaders';
|
import { getSettings } from '../utility/metadataLoaders';
|
||||||
|
|
||||||
// function themeCommand(theme: ThemeDefinition) {
|
// function themeCommand(theme: ThemeDefinition) {
|
||||||
|
@ -109,6 +109,7 @@
|
|||||||
import { parseFilter } from 'dbgate-filterparser';
|
import { parseFilter } from 'dbgate-filterparser';
|
||||||
import { scriptToSql } from 'dbgate-sqltree';
|
import { scriptToSql } from 'dbgate-sqltree';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { registerQuickExportHandler } from '../buttons/ToolStripExportButton.svelte';
|
||||||
import registerCommand from '../commands/registerCommand';
|
import registerCommand from '../commands/registerCommand';
|
||||||
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
import ErrorInfo from '../elements/ErrorInfo.svelte';
|
||||||
import ConfirmNoSqlModal from '../modals/ConfirmNoSqlModal.svelte';
|
import ConfirmNoSqlModal from '../modals/ConfirmNoSqlModal.svelte';
|
||||||
@ -121,7 +122,7 @@
|
|||||||
import { registerMenu } from '../utility/contextMenu';
|
import { registerMenu } from '../utility/contextMenu';
|
||||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||||
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
||||||
import { exportElectronFile } from '../utility/exportElectronFile';
|
import { exportQuickExportFile } from '../utility/exportFileTools';
|
||||||
import { getConnectionInfo } from '../utility/metadataLoaders';
|
import { getConnectionInfo } from '../utility/metadataLoaders';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
import ChangeSetGrider from './ChangeSetGrider';
|
import ChangeSetGrider from './ChangeSetGrider';
|
||||||
@ -193,31 +194,30 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
registerMenu(
|
const quickExportHandler = fmt => async () => {
|
||||||
{ command: 'collectionDataGrid.openQuery', tag: 'export' },
|
const coninfo = await getConnectionInfo({ conid });
|
||||||
{
|
exportQuickExportFile(
|
||||||
...createQuickExportMenu($extensions, fmt => async () => {
|
pureName || 'Data',
|
||||||
const coninfo = await getConnectionInfo({ conid });
|
{
|
||||||
exportElectronFile(
|
functionName: 'queryReader',
|
||||||
pureName || 'Data',
|
props: {
|
||||||
{
|
connection: {
|
||||||
functionName: 'queryReader',
|
..._.omit(coninfo, ['_id', 'displayName']),
|
||||||
props: {
|
database,
|
||||||
connection: {
|
|
||||||
..._.omit(coninfo, ['_id', 'displayName']),
|
|
||||||
database,
|
|
||||||
},
|
|
||||||
sql: getExportQuery(),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
fmt
|
sql: getExportQuery(),
|
||||||
);
|
},
|
||||||
}),
|
},
|
||||||
tag: 'export',
|
fmt
|
||||||
},
|
);
|
||||||
|
};
|
||||||
|
|
||||||
{ command: 'collectionDataGrid.export', tag: 'export' }
|
registerQuickExportHandler(quickExportHandler);
|
||||||
);
|
|
||||||
|
registerMenu({ command: 'collectionDataGrid.openQuery', tag: 'export' }, () => ({
|
||||||
|
...createQuickExportMenu(quickExportHandler, { command: 'collectionDataGrid.export' }),
|
||||||
|
tag: 'export',
|
||||||
|
}));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<LoadingDataGridCore
|
<LoadingDataGridCore
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
import { registerMenu } from '../utility/contextMenu';
|
import { registerMenu } from '../utility/contextMenu';
|
||||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||||
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
||||||
import { exportElectronFile } from '../utility/exportElectronFile';
|
import { exportQuickExportFile } from '../utility/exportFileTools';
|
||||||
import useEffect from '../utility/useEffect';
|
import useEffect from '../utility/useEffect';
|
||||||
|
|
||||||
import LoadingDataGridCore from './LoadingDataGridCore.svelte';
|
import LoadingDataGridCore from './LoadingDataGridCore.svelte';
|
||||||
@ -104,7 +104,7 @@
|
|||||||
const quickExportHandler = fmt => async () => {
|
const quickExportHandler = fmt => async () => {
|
||||||
const archiveMatch = jslid.match(/^archive:\/\/([^/]+)\/(.*)$/);
|
const archiveMatch = jslid.match(/^archive:\/\/([^/]+)\/(.*)$/);
|
||||||
if (archiveMatch) {
|
if (archiveMatch) {
|
||||||
exportElectronFile(
|
exportQuickExportFile(
|
||||||
archiveMatch[2],
|
archiveMatch[2],
|
||||||
{
|
{
|
||||||
functionName: 'archiveReader',
|
functionName: 'archiveReader',
|
||||||
@ -116,7 +116,7 @@
|
|||||||
fmt
|
fmt
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
exportElectronFile(
|
exportQuickExportFile(
|
||||||
'Query',
|
'Query',
|
||||||
{
|
{
|
||||||
functionName: 'jslDataReader',
|
functionName: 'jslDataReader',
|
||||||
@ -130,13 +130,10 @@
|
|||||||
};
|
};
|
||||||
registerQuickExportHandler(quickExportHandler);
|
registerQuickExportHandler(quickExportHandler);
|
||||||
|
|
||||||
registerMenu(
|
registerMenu(() => ({
|
||||||
{
|
...createQuickExportMenu(quickExportHandler, { command: 'jslTableGrid.export' }),
|
||||||
...createQuickExportMenu($extensions, quickExportHandler),
|
tag: 'export',
|
||||||
tag: 'export',
|
}));
|
||||||
},
|
|
||||||
{ command: 'jslTableGrid.export', tag: 'export' }
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<LoadingDataGridCore
|
<LoadingDataGridCore
|
||||||
|
@ -66,18 +66,17 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { getContext } from 'svelte';
|
import { getContext } from 'svelte';
|
||||||
import { registerQuickExportHandler } from '../buttons/ToolStripExportButton.svelte';
|
import { registerQuickExportHandler } from '../buttons/ToolStripExportButton.svelte';
|
||||||
|
|
||||||
import registerCommand from '../commands/registerCommand';
|
import registerCommand from '../commands/registerCommand';
|
||||||
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
import { extensions } from '../stores';
|
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
|
|
||||||
import { registerMenu } from '../utility/contextMenu';
|
import { registerMenu } from '../utility/contextMenu';
|
||||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||||
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
||||||
import { exportElectronFile } from '../utility/exportElectronFile';
|
import { exportQuickExportFile } from '../utility/exportFileTools';
|
||||||
import { getConnectionInfo } from '../utility/metadataLoaders';
|
import { getConnectionInfo } from '../utility/metadataLoaders';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
import ChangeSetGrider from './ChangeSetGrider';
|
import ChangeSetGrider from './ChangeSetGrider';
|
||||||
@ -182,7 +181,7 @@ import { registerQuickExportHandler } from '../buttons/ToolStripExportButton.sve
|
|||||||
|
|
||||||
const quickExportHandler = fmt => async () => {
|
const quickExportHandler = fmt => async () => {
|
||||||
const coninfo = await getConnectionInfo({ conid });
|
const coninfo = await getConnectionInfo({ conid });
|
||||||
exportElectronFile(
|
exportQuickExportFile(
|
||||||
pureName || 'Data',
|
pureName || 'Data',
|
||||||
{
|
{
|
||||||
functionName: 'queryReader',
|
functionName: 'queryReader',
|
||||||
@ -202,11 +201,10 @@ import { registerQuickExportHandler } from '../buttons/ToolStripExportButton.sve
|
|||||||
registerMenu(
|
registerMenu(
|
||||||
{ command: 'sqlDataGrid.openActiveChart', tag: 'chart' },
|
{ command: 'sqlDataGrid.openActiveChart', tag: 'chart' },
|
||||||
{ command: 'sqlDataGrid.openQuery', tag: 'export' },
|
{ command: 'sqlDataGrid.openQuery', tag: 'export' },
|
||||||
{
|
() => ({
|
||||||
...createQuickExportMenu($extensions, quickExportHandler),
|
...createQuickExportMenu(quickExportHandler, { command: 'sqlDataGrid.export' }),
|
||||||
tag: 'export',
|
tag: 'export',
|
||||||
},
|
})
|
||||||
{ command: 'sqlDataGrid.export', tag: 'export' }
|
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
import registerCommand from '../commands/registerCommand';
|
import registerCommand from '../commands/registerCommand';
|
||||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||||
import { GraphDefinition, GraphLayout } from './GraphLayout';
|
import { GraphDefinition, GraphLayout } from './GraphLayout';
|
||||||
import { saveFileToDisk } from '../utility/exportElectronFile';
|
import { saveFileToDisk } from '../utility/exportFileTools';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
import moveDrag from '../utility/moveDrag';
|
import moveDrag from '../utility/moveDrag';
|
||||||
import { rectanglesHaveIntersection } from './designerMath';
|
import { rectanglesHaveIntersection } from './designerMath';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { openWebLink } from '../utility/exportElectronFile';
|
import { openWebLink } from '../utility/exportFileTools';
|
||||||
|
|
||||||
export let href = undefined;
|
export let href = undefined;
|
||||||
export let onClick = undefined;
|
export let onClick = undefined;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
import SelectField from '../forms/SelectField.svelte';
|
import SelectField from '../forms/SelectField.svelte';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { useDatabaseInfo, useTableInfo } from '../utility/metadataLoaders';
|
import { useDatabaseInfo, useTableInfo } from '../utility/metadataLoaders';
|
||||||
import { onMount } from 'svelte';
|
import { onMount, tick } from 'svelte';
|
||||||
import TargetApplicationSelect from '../forms/TargetApplicationSelect.svelte';
|
import TargetApplicationSelect from '../forms/TargetApplicationSelect.svelte';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
import { saveDbToApp } from '../utility/appTools';
|
import { saveDbToApp } from '../utility/appTools';
|
||||||
@ -34,6 +34,19 @@
|
|||||||
// ..._.sortBy($dbInfo?.views || [], ['schemaName', 'pureName']),
|
// ..._.sortBy($dbInfo?.views || [], ['schemaName', 'pureName']),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
let tableOptions = [];
|
||||||
|
|
||||||
|
$: (async () => {
|
||||||
|
// without this has svelte problem, doesn't invalidate SelectField options
|
||||||
|
await tick();
|
||||||
|
// to replicate try to invoke VFK editor after page refresh, when active widget without DB, eg. application layers
|
||||||
|
// and comment line above. Tables list in vFK editor will be empty
|
||||||
|
|
||||||
|
tableOptions = tableList.map(tbl => ({
|
||||||
|
label: fullNameToLabel(tbl),
|
||||||
|
value: fullNameToString(tbl),
|
||||||
|
}));
|
||||||
|
})();
|
||||||
$: refTableInfo = tableList.find(x => x.pureName == refTableName && x.schemaName == refSchemaName);
|
$: refTableInfo = tableList.find(x => x.pureName == refTableName && x.schemaName == refSchemaName);
|
||||||
// $dbInfo?.views?.find(x => x.pureName == refTableName && x.schemaName == refSchemaName);
|
// $dbInfo?.views?.find(x => x.pureName == refTableName && x.schemaName == refSchemaName);
|
||||||
|
|
||||||
@ -50,6 +63,8 @@
|
|||||||
|
|
||||||
// $: console.log('conid, database', conid, database);
|
// $: console.log('conid, database', conid, database);
|
||||||
// $: console.log('$dbInfo?.tables', $dbInfo?.tables);
|
// $: console.log('$dbInfo?.tables', $dbInfo?.tables);
|
||||||
|
// $: console.log('tableList', tableList);
|
||||||
|
// $: console.log('tableOptions', tableOptions);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<FormProvider>
|
<FormProvider>
|
||||||
@ -64,15 +79,23 @@
|
|||||||
value={fullNameToString({ pureName: refTableName, schemaName: refSchemaName })}
|
value={fullNameToString({ pureName: refTableName, schemaName: refSchemaName })}
|
||||||
isNative
|
isNative
|
||||||
notSelected
|
notSelected
|
||||||
options={tableList.map(tbl => ({
|
options={tableOptions}
|
||||||
label: fullNameToLabel(tbl),
|
|
||||||
value: fullNameToString(tbl),
|
|
||||||
}))}
|
|
||||||
on:change={e => {
|
on:change={e => {
|
||||||
if (e.detail) {
|
if (e.detail) {
|
||||||
const name = fullNameFromString(e.detail);
|
const name = fullNameFromString(e.detail);
|
||||||
refTableName = name.pureName;
|
refTableName = name.pureName;
|
||||||
refSchemaName = name.schemaName;
|
refSchemaName = name.schemaName;
|
||||||
|
if (columns?.length == 1) {
|
||||||
|
const table = $dbInfo?.tables?.find(x => x.pureName == refTableName && x.schemaName == refSchemaName);
|
||||||
|
if (table?.primaryKey?.columns?.length == 1) {
|
||||||
|
columns = [
|
||||||
|
{
|
||||||
|
...columns[0],
|
||||||
|
refColumnName: table.primaryKey.columns[0].columnName,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -158,7 +158,7 @@
|
|||||||
import { changeTab } from '../utility/common';
|
import { changeTab } from '../utility/common';
|
||||||
import contextMenu, { getContextMenu, registerMenu } from '../utility/contextMenu';
|
import contextMenu, { getContextMenu, registerMenu } from '../utility/contextMenu';
|
||||||
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
import createActivator, { getActiveComponent } from '../utility/createActivator';
|
||||||
import { saveFileToDisk } from '../utility/exportElectronFile';
|
import { saveFileToDisk } from '../utility/exportFileTools';
|
||||||
import { useArchiveFolders, useConnectionInfo, useDatabaseInfo } from '../utility/metadataLoaders';
|
import { useArchiveFolders, useConnectionInfo, useDatabaseInfo } from '../utility/metadataLoaders';
|
||||||
import resolveApi from '../utility/resolveApi';
|
import resolveApi from '../utility/resolveApi';
|
||||||
import { showSnackbarSuccess } from '../utility/snackbar';
|
import { showSnackbarSuccess } from '../utility/snackbar';
|
||||||
|
@ -50,14 +50,11 @@
|
|||||||
import { showSnackbarSuccess } from '../utility/snackbar';
|
import { showSnackbarSuccess } from '../utility/snackbar';
|
||||||
import StatusBarTabItem from '../widgets/StatusBarTabItem.svelte';
|
import StatusBarTabItem from '../widgets/StatusBarTabItem.svelte';
|
||||||
import openNewTab from '../utility/openNewTab';
|
import openNewTab from '../utility/openNewTab';
|
||||||
import { getBoolSettingsValue } from '../settings/settingsTools';
|
|
||||||
import { setContext } from 'svelte';
|
import { setContext } from 'svelte';
|
||||||
import { apiCall } from '../utility/api';
|
import { apiCall } from '../utility/api';
|
||||||
import { getLocalStorage, setLocalStorage } from '../utility/storageCache';
|
import { getLocalStorage, setLocalStorage } from '../utility/storageCache';
|
||||||
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
||||||
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
|
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
|
||||||
import ToolStripDropDownButton from '../buttons/ToolStripDropDownButton.svelte';
|
|
||||||
import { createQuickExportMenuItems } from '../utility/createQuickExportMenu';
|
|
||||||
import ToolStripExportButton, { createQuickExportHandlerRef } from '../buttons/ToolStripExportButton.svelte';
|
import ToolStripExportButton, { createQuickExportHandlerRef } from '../buttons/ToolStripExportButton.svelte';
|
||||||
|
|
||||||
export let tabid;
|
export let tabid;
|
||||||
|
@ -1,30 +1,27 @@
|
|||||||
import { ExtensionsDirectory, QuickExportDefinition } from 'dbgate-types';
|
import { QuickExportDefinition } from 'dbgate-types';
|
||||||
import getElectron from './getElectron';
|
import { getExtensions } from '../stores';
|
||||||
|
|
||||||
export function createQuickExportMenuItems(
|
export function createQuickExportMenuItems(handler: (fmt: QuickExportDefinition) => Function, advancedExportMenuItem) {
|
||||||
extensions: ExtensionsDirectory,
|
const extensions = getExtensions();
|
||||||
handler: (fmt: QuickExportDefinition) => Function
|
return [
|
||||||
) {
|
...extensions.quickExports.map(fmt => ({
|
||||||
const electron = getElectron();
|
text: fmt.label,
|
||||||
if (!electron) {
|
onClick: handler(fmt),
|
||||||
return null;
|
})),
|
||||||
}
|
{ divider: true },
|
||||||
return extensions.quickExports.map(fmt => ({
|
{
|
||||||
text: fmt.label,
|
text: 'More...',
|
||||||
onClick: handler(fmt),
|
...advancedExportMenuItem,
|
||||||
}));
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function createQuickExportMenu(
|
export default function createQuickExportMenu(
|
||||||
extensions: ExtensionsDirectory,
|
handler: (fmt: QuickExportDefinition) => Function,
|
||||||
handler: (fmt: QuickExportDefinition) => Function
|
advancedExportMenuItem
|
||||||
) {
|
) {
|
||||||
const electron = getElectron();
|
|
||||||
if (!electron) {
|
|
||||||
return { _skip: true };
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
text: 'Quick export',
|
text: 'Export',
|
||||||
submenu: createQuickExportMenuItems(extensions, handler),
|
submenu: createQuickExportMenuItems(handler, advancedExportMenuItem),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,23 @@ import { showSnackbar, showSnackbarInfo, showSnackbarError, closeSnackbar } from
|
|||||||
import resolveApi from './resolveApi';
|
import resolveApi from './resolveApi';
|
||||||
import { apiCall, apiOff, apiOn } from './api';
|
import { apiCall, apiOff, apiOn } from './api';
|
||||||
|
|
||||||
export async function exportElectronFile(dataName, reader, format) {
|
export async function exportQuickExportFile(dataName, reader, format) {
|
||||||
const electron = getElectron();
|
const electron = getElectron();
|
||||||
const filters = [{ name: format.label, extensions: [format.extension] }];
|
|
||||||
|
|
||||||
const filePath = await electron.showSaveDialog({
|
let filePath;
|
||||||
filters,
|
let pureFileName;
|
||||||
defaultPath: `${dataName}.${format.extension}`,
|
if (electron) {
|
||||||
properties: ['showOverwriteConfirmation'],
|
const filters = [{ name: format.label, extensions: [format.extension] }];
|
||||||
});
|
filePath = electron.showSaveDialog({
|
||||||
if (!filePath) return;
|
filters,
|
||||||
|
defaultPath: `${dataName}.${format.extension}`,
|
||||||
|
properties: ['showOverwriteConfirmation'],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const resp = await apiCall('files/generate-uploads-file', { extension: format.extension });
|
||||||
|
filePath = resp.filePath;
|
||||||
|
pureFileName = resp.fileName;
|
||||||
|
}
|
||||||
|
|
||||||
const script = new ScriptWriter();
|
const script = new ScriptWriter();
|
||||||
|
|
||||||
@ -50,6 +57,10 @@ export async function exportElectronFile(dataName, reader, format) {
|
|||||||
apiOff(`runner-done-${runid}`, handleRunnerDone);
|
apiOff(`runner-done-${runid}`, handleRunnerDone);
|
||||||
if (isCanceled) showSnackbarError(`Export ${dataName} canceled`);
|
if (isCanceled) showSnackbarError(`Export ${dataName} canceled`);
|
||||||
else showSnackbarInfo(`Export ${dataName} finished`);
|
else showSnackbarInfo(`Export ${dataName} finished`);
|
||||||
|
|
||||||
|
if (!electron) {
|
||||||
|
window.open(`${resolveApi()}/uploads/get?file=${pureFileName}`, '_blank');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apiOn(`runner-done-${runid}`, handleRunnerDone);
|
apiOn(`runner-done-${runid}`, handleRunnerDone);
|
@ -387,7 +387,7 @@
|
|||||||
draggingDbGroupTarget = null;
|
draggingDbGroupTarget = null;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<FontIcon icon={getDbIcon(tabGroup.tabDbKey)} />
|
<FontIcon icon={getDbIcon(tabGroup.tabDbKey)} padRight />
|
||||||
{tabGroup.tabDbName}
|
{tabGroup.tabDbName}
|
||||||
|
|
||||||
<span
|
<span
|
||||||
@ -493,6 +493,7 @@
|
|||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
}
|
}
|
||||||
.db-name {
|
.db-name {
|
||||||
|
display: flex;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 8pt;
|
font-size: 8pt;
|
||||||
border-bottom: 1px solid var(--theme-border);
|
border-bottom: 1px solid var(--theme-border);
|
||||||
@ -501,10 +502,10 @@
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
padding: 1px;
|
padding: 1px;
|
||||||
position: relative;
|
position: relative;
|
||||||
white-space: nowrap;
|
|
||||||
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
/* .db-name:hover {
|
/* .db-name:hover {
|
||||||
background-color: var(--theme-bg-3);
|
background-color: var(--theme-bg-3);
|
||||||
|
@ -47,6 +47,10 @@ class StringifyStream extends stream.Transform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_transform(chunk, encoding, done) {
|
_transform(chunk, encoding, done) {
|
||||||
|
if (chunk.__isStreamHeader) {
|
||||||
|
done();
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.startElement(this.itemElementName);
|
this.startElement(this.itemElementName);
|
||||||
this.push('\n');
|
this.push('\n');
|
||||||
for (const key of Object.keys(chunk)) {
|
for (const key of Object.keys(chunk)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user