refresh perspective command

This commit is contained in:
Jan Prochazka 2022-07-24 15:56:29 +02:00
parent 088ca231f3
commit 96106e6aac
3 changed files with 63 additions and 12 deletions

View File

@ -109,4 +109,8 @@ export class PerspectiveCache {
// cache could be used
return res;
}
clear() {
this.tables = {};
}
}

View File

@ -13,6 +13,7 @@
import resizeObserver from '../utility/resizeObserver';
import PerspectiveIntersectionObserver from './PerspectiveIntersectionObserver.svelte';
import debug from 'debug';
import contextMenu from '../utility/contextMenu';
const dbg = debug('dbgate:PerspectivaTable');
@ -133,13 +134,27 @@
domHeaderWrap;
createHeaderClone();
}
function buildMenu() {
return [
{
command: 'perspective.refresh',
},
];
}
</script>
<div class="headerWrap">
<table bind:this={domHeaderWrap} />
</div>
<div class="wrapper" bind:this={domWrapper} use:resizeObserver={true} on:resize={createHeaderClone}>
<div
class="wrapper"
bind:this={domWrapper}
use:resizeObserver={true}
on:resize={createHeaderClone}
use:contextMenu={buildMenu}
>
{#if display}
<table>
<thead bind:this={domTableHead}>

View File

@ -1,10 +1,29 @@
<script lang="ts" context="module">
const getCurrentEditor = () => getActiveComponent('PerspectiveTab');
registerCommand({
id: 'perspective.refresh',
category: 'Perspective',
name: 'Refresh',
keyText: 'F5 | CtrlOrCommand+R',
toolbar: true,
isRelatedToTab: true,
icon: 'icon reload',
testEnabled: () => getCurrentEditor() != null,
onClick: () => getCurrentEditor().refresh(),
});
</script>
<script lang="ts">
import { PerspectiveCache } from 'dbgate-datalib';
import PerspectiveView from '../perspectives/PerspectiveView.svelte';
import usePerspectiveConfig from '../utility/usePerspectiveConfig';
import stableStringify from 'json-stable-stringify';
import { writable } from 'svelte/store';
import registerCommand from '../commands/registerCommand';
import createActivator, { getActiveComponent } from '../utility/createActivator';
import ToolStripContainer from '../buttons/ToolStripContainer.svelte';
import ToolStripCommandButton from '../buttons/ToolStripCommandButton.svelte';
export let tabid;
export let conid;
@ -12,12 +31,20 @@
export let schemaName;
export let pureName;
export const activator = createActivator('PerspectiveTab', true);
const config = usePerspectiveConfig(tabid);
const cache = new PerspectiveCache();
const loadedCounts = writable({});
export function refresh() {
cache.clear();
loadedCounts.set({});
}
</script>
<PerspectiveView
<ToolStripContainer>
<PerspectiveView
{conid}
{database}
{schemaName}
@ -26,4 +53,9 @@
setConfig={config.update}
{cache}
{loadedCounts}
/>
/>
<svelte:fragment slot="toolstrip">
<ToolStripCommandButton command="perspective.refresh" />
</svelte:fragment>
</ToolStripContainer>