query toolstip

This commit is contained in:
Jan Prochazka 2022-02-12 20:53:55 +01:00
parent 74cf073bfa
commit 488b200fcb
5 changed files with 108 additions and 77 deletions

View File

@ -26,18 +26,20 @@
const electron = getElectron(); const electron = getElectron();
export let quickExportHandlerRef; export let quickExportHandlerRef = null;
export let command = 'sqlDataGrid.export';
export let label = 'Advanced settings';
function getExportMenu() { function getExportMenu() {
return [ return [
quickExportHandlerRef?.value ? createQuickExportMenuItems($extensions, quickExportHandlerRef?.value) : null, quickExportHandlerRef?.value ? createQuickExportMenuItems($extensions, quickExportHandlerRef?.value) : null,
{ divider: true }, { divider: true },
{ command: 'sqlDataGrid.export', text: 'Advanced settings' }, { command, text: label },
]; ];
} }
</script> </script>
{#if electron} {#if quickExportHandlerRef && electron}
<ToolStripDropDownButton menu={getExportMenu} label="Export" icon="icon export" /> <ToolStripDropDownButton menu={getExportMenu} label="Export" icon="icon export" />
{:else} {:else}
<ToolStripCommandButton command="sqlDataGrid.export" /> <ToolStripCommandButton command="sqlDataGrid.export" />

View File

@ -37,6 +37,7 @@
<script lang="ts"> <script lang="ts">
import _ from 'lodash'; import _ from 'lodash';
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';
@ -99,9 +100,7 @@
showModal(ImportExportModal, { initialValues }); showModal(ImportExportModal, { initialValues });
} }
registerMenu( const quickExportHandler = fmt => async () => {
{
...createQuickExportMenu($extensions, fmt => async () => {
const archiveMatch = jslid.match(/^archive:\/\/([^/]+)\/(.*)$/); const archiveMatch = jslid.match(/^archive:\/\/([^/]+)\/(.*)$/);
if (archiveMatch) { if (archiveMatch) {
exportElectronFile( exportElectronFile(
@ -127,7 +126,12 @@
fmt fmt
); );
} }
}), };
registerQuickExportHandler(quickExportHandler);
registerMenu(
{
...createQuickExportMenu($extensions, quickExportHandler),
tag: 'export', tag: 'export',
}, },
{ command: 'jslTableGrid.export', tag: 'export' } { command: 'jslTableGrid.export', tag: 'export' }

View File

@ -14,6 +14,8 @@
export let sessionId; export let sessionId;
export let executeNumber; export let executeNumber;
export let resultCount;
onMount(() => { onMount(() => {
allResultsInOneTab = $allResultsInOneTabDefault; allResultsInOneTab = $allResultsInOneTabDefault;
}); });
@ -22,6 +24,8 @@
let resultInfos = []; let resultInfos = [];
let domTabs; let domTabs;
$: resultCount = resultInfos.length;
const handleResultSet = async props => { const handleResultSet = async props => {
const { jslid, resultIndex } = props; const { jslid, resultIndex } = props;
resultInfos = [...resultInfos, { jslid, resultIndex }]; resultInfos = [...resultInfos, { jslid, resultIndex }];

View File

@ -50,6 +50,9 @@
import { apiCall, apiOff, apiOn } from '../utility/api'; import { apiCall, apiOff, apiOn } from '../utility/api';
import registerCommand from '../commands/registerCommand'; import registerCommand from '../commands/registerCommand';
import newQuery from '../query/newQuery'; 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 tabid;
export let conid; export let conid;
@ -233,8 +236,11 @@
}, },
]; ];
} }
const quickExportHandlerRef = createQuickExportHandlerRef();
</script> </script>
<ToolStripContainer>
<VerticalSplitter initialValue="70%"> <VerticalSplitter initialValue="70%">
<svelte:fragment slot="1"> <svelte:fragment slot="1">
<QueryDesigner <QueryDesigner
@ -283,3 +289,11 @@
</ResultTabs> </ResultTabs>
</svelte:fragment> </svelte:fragment>
</VerticalSplitter> </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>
</ToolStripContainer>

View File

@ -70,6 +70,7 @@
import { apiCall, apiOff, apiOn } from '../utility/api'; import { apiCall, apiOff, apiOn } from '../utility/api';
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte'; import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
import ToolStripContainer from '../buttons/ToolStripContainer.svelte'; import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
import ToolStripExportButton, { createQuickExportHandlerRef } from '../buttons/ToolStripExportButton.svelte';
export let tabid; export let tabid;
export let conid; export let conid;
@ -85,6 +86,7 @@ import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
let executeNumber = 0; let executeNumber = 0;
let visibleResultTabs = false; let visibleResultTabs = false;
let sessionId = null; let sessionId = null;
let resultCount;
let domEditor; let domEditor;
@ -270,6 +272,8 @@ import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
{ command: 'query.replace' }, { command: 'query.replace' },
]; ];
} }
const quickExportHandlerRef = createQuickExportHandlerRef();
</script> </script>
<ToolStripContainer> <ToolStripContainer>
@ -306,7 +310,7 @@ import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
{/if} {/if}
</svelte:fragment> </svelte:fragment>
<svelte:fragment slot="2"> <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"> <svelte:fragment slot="0">
<SocketMessageView <SocketMessageView
eventName={sessionId ? `session-info-${sessionId}` : null} eventName={sessionId ? `session-info-${sessionId}` : null}
@ -324,6 +328,9 @@ import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
<ToolStripCommandButton command="query.kill" /> <ToolStripCommandButton command="query.kill" />
<ToolStripCommandButton command="query.save" /> <ToolStripCommandButton command="query.save" />
<ToolStripCommandButton command="query.formatCode" /> <ToolStripCommandButton command="query.formatCode" />
{#if resultCount == 1}
<ToolStripExportButton command="jslTableGrid.export" {quickExportHandlerRef} label="Export result" />
{/if}
</svelte:fragment> </svelte:fragment>
</ToolStripContainer> </ToolStripContainer>