mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
query toolstip
This commit is contained in:
parent
74cf073bfa
commit
488b200fcb
@ -26,18 +26,20 @@
|
||||
|
||||
const electron = getElectron();
|
||||
|
||||
export let quickExportHandlerRef;
|
||||
export let quickExportHandlerRef = null;
|
||||
export let command = 'sqlDataGrid.export';
|
||||
export let label = 'Advanced settings';
|
||||
|
||||
function getExportMenu() {
|
||||
return [
|
||||
quickExportHandlerRef?.value ? createQuickExportMenuItems($extensions, quickExportHandlerRef?.value) : null,
|
||||
{ divider: true },
|
||||
{ command: 'sqlDataGrid.export', text: 'Advanced settings' },
|
||||
{ command, text: label },
|
||||
];
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if electron}
|
||||
{#if quickExportHandlerRef && electron}
|
||||
<ToolStripDropDownButton menu={getExportMenu} label="Export" icon="icon export" />
|
||||
{:else}
|
||||
<ToolStripCommandButton command="sqlDataGrid.export" />
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import _ from 'lodash';
|
||||
import { registerQuickExportHandler } from '../buttons/ToolStripExportButton.svelte';
|
||||
import registerCommand from '../commands/registerCommand';
|
||||
import ImportExportModal from '../modals/ImportExportModal.svelte';
|
||||
import { showModal } from '../modals/modalTools';
|
||||
@ -99,35 +100,38 @@
|
||||
showModal(ImportExportModal, { initialValues });
|
||||
}
|
||||
|
||||
const quickExportHandler = fmt => async () => {
|
||||
const archiveMatch = jslid.match(/^archive:\/\/([^/]+)\/(.*)$/);
|
||||
if (archiveMatch) {
|
||||
exportElectronFile(
|
||||
archiveMatch[2],
|
||||
{
|
||||
functionName: 'archiveReader',
|
||||
props: {
|
||||
folderName: archiveMatch[1],
|
||||
fileName: archiveMatch[2],
|
||||
},
|
||||
},
|
||||
fmt
|
||||
);
|
||||
} else {
|
||||
exportElectronFile(
|
||||
'Query',
|
||||
{
|
||||
functionName: 'jslDataReader',
|
||||
props: {
|
||||
jslid,
|
||||
},
|
||||
},
|
||||
fmt
|
||||
);
|
||||
}
|
||||
};
|
||||
registerQuickExportHandler(quickExportHandler);
|
||||
|
||||
registerMenu(
|
||||
{
|
||||
...createQuickExportMenu($extensions, fmt => async () => {
|
||||
const archiveMatch = jslid.match(/^archive:\/\/([^/]+)\/(.*)$/);
|
||||
if (archiveMatch) {
|
||||
exportElectronFile(
|
||||
archiveMatch[2],
|
||||
{
|
||||
functionName: 'archiveReader',
|
||||
props: {
|
||||
folderName: archiveMatch[1],
|
||||
fileName: archiveMatch[2],
|
||||
},
|
||||
},
|
||||
fmt
|
||||
);
|
||||
} else {
|
||||
exportElectronFile(
|
||||
'Query',
|
||||
{
|
||||
functionName: 'jslDataReader',
|
||||
props: {
|
||||
jslid,
|
||||
},
|
||||
},
|
||||
fmt
|
||||
);
|
||||
}
|
||||
}),
|
||||
...createQuickExportMenu($extensions, quickExportHandler),
|
||||
tag: 'export',
|
||||
},
|
||||
{ command: 'jslTableGrid.export', tag: 'export' }
|
||||
|
@ -14,6 +14,8 @@
|
||||
export let sessionId;
|
||||
export let executeNumber;
|
||||
|
||||
export let resultCount;
|
||||
|
||||
onMount(() => {
|
||||
allResultsInOneTab = $allResultsInOneTabDefault;
|
||||
});
|
||||
@ -22,6 +24,8 @@
|
||||
let resultInfos = [];
|
||||
let domTabs;
|
||||
|
||||
$: resultCount = resultInfos.length;
|
||||
|
||||
const handleResultSet = async props => {
|
||||
const { jslid, resultIndex } = props;
|
||||
resultInfos = [...resultInfos, { jslid, resultIndex }];
|
||||
|
@ -50,6 +50,9 @@
|
||||
import { apiCall, apiOff, apiOn } from '../utility/api';
|
||||
import registerCommand from '../commands/registerCommand';
|
||||
import newQuery from '../query/newQuery';
|
||||
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
||||
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
|
||||
import ToolStripExportButton, { createQuickExportHandlerRef } from '../buttons/ToolStripExportButton.svelte';
|
||||
|
||||
export let tabid;
|
||||
export let conid;
|
||||
@ -233,53 +236,64 @@
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const quickExportHandlerRef = createQuickExportHandlerRef();
|
||||
</script>
|
||||
|
||||
<VerticalSplitter initialValue="70%">
|
||||
<svelte:fragment slot="1">
|
||||
<QueryDesigner
|
||||
value={$modelState.value || {}}
|
||||
{conid}
|
||||
{database}
|
||||
engine={$connection && $connection.engine}
|
||||
onChange={handleChange}
|
||||
menu={createMenu}
|
||||
/>
|
||||
</svelte:fragment>
|
||||
<ToolStripContainer>
|
||||
<VerticalSplitter initialValue="70%">
|
||||
<svelte:fragment slot="1">
|
||||
<QueryDesigner
|
||||
value={$modelState.value || {}}
|
||||
{conid}
|
||||
{database}
|
||||
engine={$connection && $connection.engine}
|
||||
onChange={handleChange}
|
||||
menu={createMenu}
|
||||
/>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="2">
|
||||
<ResultTabs
|
||||
tabs={[
|
||||
{
|
||||
label: 'Columns',
|
||||
component: QueryDesignColumns,
|
||||
props: {
|
||||
value: $modelState.value || {},
|
||||
onChange: handleChange,
|
||||
<svelte:fragment slot="2">
|
||||
<ResultTabs
|
||||
tabs={[
|
||||
{
|
||||
label: 'Columns',
|
||||
component: QueryDesignColumns,
|
||||
props: {
|
||||
value: $modelState.value || {},
|
||||
onChange: handleChange,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'SQL',
|
||||
component: SqlEditor,
|
||||
props: {
|
||||
engine: $connection && $connection.engine,
|
||||
readOnly: true,
|
||||
value: sqlPreview,
|
||||
{
|
||||
label: 'SQL',
|
||||
component: SqlEditor,
|
||||
props: {
|
||||
engine: $connection && $connection.engine,
|
||||
readOnly: true,
|
||||
value: sqlPreview,
|
||||
},
|
||||
},
|
||||
},
|
||||
visibleResultTabs && { label: 'Messages', slot: 0 },
|
||||
]}
|
||||
{sessionId}
|
||||
{executeNumber}
|
||||
>
|
||||
<svelte:fragment slot="0">
|
||||
<SocketMessageView
|
||||
eventName={sessionId ? `session-info-${sessionId}` : null}
|
||||
{executeNumber}
|
||||
showProcedure
|
||||
showLine
|
||||
/>
|
||||
</svelte:fragment>
|
||||
</ResultTabs>
|
||||
visibleResultTabs && { label: 'Messages', slot: 0 },
|
||||
]}
|
||||
{sessionId}
|
||||
{executeNumber}
|
||||
>
|
||||
<svelte:fragment slot="0">
|
||||
<SocketMessageView
|
||||
eventName={sessionId ? `session-info-${sessionId}` : null}
|
||||
{executeNumber}
|
||||
showProcedure
|
||||
showLine
|
||||
/>
|
||||
</svelte:fragment>
|
||||
</ResultTabs>
|
||||
</svelte:fragment>
|
||||
</VerticalSplitter>
|
||||
<svelte:fragment slot="toolstrip">
|
||||
<ToolStripCommandButton command="designer.execute" />
|
||||
<ToolStripCommandButton command="designer.kill" />
|
||||
<ToolStripCommandButton command="designer.openSql" />
|
||||
<ToolStripCommandButton command="designer.save" />
|
||||
<ToolStripExportButton command="jslTableGrid.export" {quickExportHandlerRef} label="Export result" />
|
||||
</svelte:fragment>
|
||||
</VerticalSplitter>
|
||||
</ToolStripContainer>
|
||||
|
@ -68,8 +68,9 @@
|
||||
import StatusBarTabItem from '../widgets/StatusBarTabItem.svelte';
|
||||
import { showSnackbarError } from '../utility/snackbar';
|
||||
import { apiCall, apiOff, apiOn } from '../utility/api';
|
||||
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
|
||||
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
||||
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
|
||||
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
||||
import ToolStripExportButton, { createQuickExportHandlerRef } from '../buttons/ToolStripExportButton.svelte';
|
||||
|
||||
export let tabid;
|
||||
export let conid;
|
||||
@ -85,6 +86,7 @@ import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
||||
let executeNumber = 0;
|
||||
let visibleResultTabs = false;
|
||||
let sessionId = null;
|
||||
let resultCount;
|
||||
|
||||
let domEditor;
|
||||
|
||||
@ -270,6 +272,8 @@ import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
||||
{ command: 'query.replace' },
|
||||
];
|
||||
}
|
||||
|
||||
const quickExportHandlerRef = createQuickExportHandlerRef();
|
||||
</script>
|
||||
|
||||
<ToolStripContainer>
|
||||
@ -306,7 +310,7 @@ import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="2">
|
||||
<ResultTabs tabs={[{ label: 'Messages', slot: 0 }]} {sessionId} {executeNumber}>
|
||||
<ResultTabs tabs={[{ label: 'Messages', slot: 0 }]} {sessionId} {executeNumber} bind:resultCount>
|
||||
<svelte:fragment slot="0">
|
||||
<SocketMessageView
|
||||
eventName={sessionId ? `session-info-${sessionId}` : null}
|
||||
@ -324,6 +328,9 @@ import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
|
||||
<ToolStripCommandButton command="query.kill" />
|
||||
<ToolStripCommandButton command="query.save" />
|
||||
<ToolStripCommandButton command="query.formatCode" />
|
||||
{#if resultCount == 1}
|
||||
<ToolStripExportButton command="jslTableGrid.export" {quickExportHandlerRef} label="Export result" />
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</ToolStripContainer>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user