mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 12:26:01 +00:00
redis key loading refactor
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { findEngineDriver } from 'dbgate-tools';
|
||||
import { dbKeys_loadMissing, dbKeys_refreshAll, findEngineDriver } from 'dbgate-tools';
|
||||
|
||||
import CloseSearchButton from '../buttons/CloseSearchButton.svelte';
|
||||
import InlineButton from '../buttons/InlineButton.svelte';
|
||||
import runCommand from '../commands/runCommand';
|
||||
|
||||
import SearchBoxWrapper from '../elements/SearchBoxWrapper.svelte';
|
||||
import SearchInput from '../elements/SearchInput.svelte';
|
||||
@@ -17,15 +16,16 @@
|
||||
import DbKeysSubTree from './DbKeysSubTree.svelte';
|
||||
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
|
||||
import FocusedConnectionInfoWidget from './FocusedConnectionInfoWidget.svelte';
|
||||
|
||||
|
||||
export let conid;
|
||||
export let database;
|
||||
|
||||
let filter;
|
||||
let reloadToken = 0;
|
||||
|
||||
let model = dbKeys_refreshAll();
|
||||
|
||||
function handleRefreshDatabase() {
|
||||
reloadToken += 1;
|
||||
changeModel(model => dbKeys_refreshAll(model));
|
||||
}
|
||||
|
||||
function handleAddKey() {
|
||||
@@ -58,6 +58,31 @@
|
||||
($focusedConnectionOrDatabase?.database && $focusedConnectionOrDatabase?.database != database));
|
||||
|
||||
$: connection = useConnectionInfo({ conid });
|
||||
|
||||
async function changeModel(modelUpdate) {
|
||||
model = modelUpdate(model);
|
||||
model = await dbKeys_loadMissing(model, async (root, limit) => {
|
||||
const result = await apiCall('database-connections/load-keys', {
|
||||
conid,
|
||||
database,
|
||||
root,
|
||||
filter,
|
||||
limit,
|
||||
});
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
function reloadModel() {
|
||||
changeModel(model => dbKeys_refreshAll(model));
|
||||
}
|
||||
|
||||
$: {
|
||||
conid;
|
||||
database;
|
||||
filter;
|
||||
reloadModel();
|
||||
}
|
||||
</script>
|
||||
|
||||
<SearchBoxWrapper>
|
||||
@@ -74,5 +99,5 @@
|
||||
<FocusedConnectionInfoWidget {conid} {database} connection={$connection} />
|
||||
{/if}
|
||||
<WidgetsInnerContainer hideContent={differentFocusedDb}>
|
||||
<DbKeysSubTree {conid} {database} root="" {reloadToken} connection={$currentDatabase?.connection} {filter} />
|
||||
<DbKeysSubTree root="" {filter} {model} {changeModel} {conid} {database} {connection} />
|
||||
</WidgetsInnerContainer>
|
||||
|
||||
Reference in New Issue
Block a user