mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
refresh perspective command
This commit is contained in:
parent
088ca231f3
commit
96106e6aac
@ -109,4 +109,8 @@ export class PerspectiveCache {
|
||||
// cache could be used
|
||||
return res;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.tables = {};
|
||||
}
|
||||
}
|
||||
|
@ -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}>
|
||||
|
@ -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,18 +31,31 @@
|
||||
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
|
||||
{conid}
|
||||
{database}
|
||||
{schemaName}
|
||||
{pureName}
|
||||
config={$config}
|
||||
setConfig={config.update}
|
||||
{cache}
|
||||
{loadedCounts}
|
||||
/>
|
||||
<ToolStripContainer>
|
||||
<PerspectiveView
|
||||
{conid}
|
||||
{database}
|
||||
{schemaName}
|
||||
{pureName}
|
||||
config={$config}
|
||||
setConfig={config.update}
|
||||
{cache}
|
||||
{loadedCounts}
|
||||
/>
|
||||
|
||||
<svelte:fragment slot="toolstrip">
|
||||
<ToolStripCommandButton command="perspective.refresh" />
|
||||
</svelte:fragment>
|
||||
</ToolStripContainer>
|
||||
|
Loading…
Reference in New Issue
Block a user