mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 17:16:01 +00:00
deep refresh on datagrid
This commit is contained in:
@@ -13,6 +13,18 @@
|
|||||||
onClick: () => getCurrentDataGrid().refresh(),
|
onClick: () => getCurrentDataGrid().refresh(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
registerCommand({
|
||||||
|
id: 'dataGrid.deepRefresh',
|
||||||
|
category: 'Data grid',
|
||||||
|
name: 'Refresh with structure',
|
||||||
|
keyText: 'Ctrl+F5',
|
||||||
|
toolbar: true,
|
||||||
|
isRelatedToTab: true,
|
||||||
|
icon: 'icon reload',
|
||||||
|
testEnabled: () => getCurrentDataGrid()?.canDeepRefresh(),
|
||||||
|
onClick: () => getCurrentDataGrid().deepRefresh(),
|
||||||
|
});
|
||||||
|
|
||||||
registerCommand({
|
registerCommand({
|
||||||
id: 'dataGrid.revertRowChanges',
|
id: 'dataGrid.revertRowChanges',
|
||||||
category: 'Data grid',
|
category: 'Data grid',
|
||||||
@@ -282,7 +294,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { GridDisplay } from 'dbgate-datalib';
|
import { GridDisplay } from 'dbgate-datalib';
|
||||||
import { driverBase, parseCellValue } from 'dbgate-tools';
|
import { driverBase, parseCellValue } from 'dbgate-tools';
|
||||||
import { getContext } from 'svelte';
|
import { getContext, onDestroy } from 'svelte';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import registerCommand from '../commands/registerCommand';
|
import registerCommand from '../commands/registerCommand';
|
||||||
import ColumnHeaderControl from './ColumnHeaderControl.svelte';
|
import ColumnHeaderControl from './ColumnHeaderControl.svelte';
|
||||||
@@ -336,6 +348,7 @@
|
|||||||
import { selectionCouldBeShownOnMap } from '../elements/SelectionMapView.svelte';
|
import { selectionCouldBeShownOnMap } from '../elements/SelectionMapView.svelte';
|
||||||
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
import ErrorMessageModal from '../modals/ErrorMessageModal.svelte';
|
||||||
import EditCellDataModal, { shouldOpenMultilineDialog } from '../modals/EditCellDataModal.svelte';
|
import EditCellDataModal, { shouldOpenMultilineDialog } from '../modals/EditCellDataModal.svelte';
|
||||||
|
import { getDatabaseInfo, useDatabaseStatus } from '../utility/metadataLoaders';
|
||||||
|
|
||||||
export let onLoadNextData = undefined;
|
export let onLoadNextData = undefined;
|
||||||
export let grider = undefined;
|
export let grider = undefined;
|
||||||
@@ -396,6 +409,26 @@
|
|||||||
|
|
||||||
const tabid = getContext('tabid');
|
const tabid = getContext('tabid');
|
||||||
|
|
||||||
|
let unsubscribeDbRefresh;
|
||||||
|
|
||||||
|
onDestroy(callUnsubscribeDbRefresh);
|
||||||
|
|
||||||
|
function callUnsubscribeDbRefresh() {
|
||||||
|
if (unsubscribeDbRefresh) {
|
||||||
|
unsubscribeDbRefresh();
|
||||||
|
unsubscribeDbRefresh = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refreshAndUnsubscribe(status) {
|
||||||
|
if (status?.name != 'pending' && status?.name != 'checkStructure' && status?.name != 'loadStructure') {
|
||||||
|
callUnsubscribeDbRefresh();
|
||||||
|
// ensure new structure is loaded
|
||||||
|
await getDatabaseInfo({ conid, database });
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function refresh() {
|
export function refresh() {
|
||||||
if (onCustomGridRefresh) onCustomGridRefresh();
|
if (onCustomGridRefresh) onCustomGridRefresh();
|
||||||
else display.reload();
|
else display.reload();
|
||||||
@@ -406,6 +439,16 @@
|
|||||||
return getDisplay()?.supportsReload;
|
return getDisplay()?.supportsReload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function canDeepRefresh() {
|
||||||
|
return canRefresh() && !!conid && !!database;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function deepRefresh() {
|
||||||
|
callUnsubscribeDbRefresh();
|
||||||
|
await apiCall('database-connections/sync-model', { conid, database });
|
||||||
|
unsubscribeDbRefresh = useDatabaseStatus({ conid, database }).subscribe(refreshAndUnsubscribe);
|
||||||
|
}
|
||||||
|
|
||||||
export function getGrider() {
|
export function getGrider() {
|
||||||
return grider;
|
return grider;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,6 +211,7 @@
|
|||||||
function createAutoRefreshMenu() {
|
function createAutoRefreshMenu() {
|
||||||
return [
|
return [
|
||||||
{ divider: true },
|
{ divider: true },
|
||||||
|
{ command: 'dataGrid.deepRefresh', hideDisabled: true },
|
||||||
{ command: 'tableData.stopAutoRefresh', hideDisabled: true },
|
{ command: 'tableData.stopAutoRefresh', hideDisabled: true },
|
||||||
{ command: 'tableData.startAutoRefresh', hideDisabled: true },
|
{ command: 'tableData.startAutoRefresh', hideDisabled: true },
|
||||||
'tableData.setAutoRefresh.1',
|
'tableData.setAutoRefresh.1',
|
||||||
|
|||||||
Reference in New Issue
Block a user