redis: reload keys

This commit is contained in:
Jan Prochazka 2022-03-24 18:32:17 +01:00
parent 613ac3f0e5
commit 735c48902f
4 changed files with 47 additions and 29 deletions

View File

@ -78,11 +78,11 @@ const databaseListLoader = ({ conid }) => ({
},
});
const databaseKeysLoader = ({ conid, database, root }) => ({
url: 'database-connections/load-keys',
params: { conid, database, root },
reloadTrigger: `database-keys-changed-${conid}-${database}`,
});
// const databaseKeysLoader = ({ conid, database, root }) => ({
// url: 'database-connections/load-keys',
// params: { conid, database, root },
// reloadTrigger: `database-keys-changed-${conid}-${database}`,
// });
const serverVersionLoader = ({ conid }) => ({
url: 'server-connections/version',
@ -436,9 +436,9 @@ export function useAuthTypes(args) {
return useCore(authTypesLoader, args);
}
export function getDatabaseKeys(args) {
return getCore(databaseKeysLoader, args);
}
export function useDatabaseKeys(args) {
return useCore(databaseKeysLoader, args);
}
// export function getDatabaseKeys(args) {
// return getCore(databaseKeysLoader, args);
// }
// export function useDatabaseKeys(args) {
// return useCore(databaseKeysLoader, args);
// }

View File

@ -1,5 +1,7 @@
<script lang="ts">
import AppObjectCore from '../appobj/AppObjectCore.svelte';
import LoadingInfo from '../elements/LoadingInfo.svelte';
import { apiCall } from '../utility/api';
const SHOW_INCREMENT = 500;
@ -12,23 +14,29 @@
export let root;
export let indentLevel = 0;
export let reloadToken = 0;
let maxShowCount = SHOW_INCREMENT;
$: items = useDatabaseKeys({ conid, database, root });
// $: items = useDatabaseKeys({ conid, database, root, reloadToken });
</script>
{#each ($items || []).slice(0, maxShowCount) as item}
<DbKeysTreeNode {conid} {database} {root} {item} {indentLevel} />
{/each}
{#await apiCall('database-connections/load-keys', { conid, database, root, reloadToken })}
<LoadingInfo message="Loading key list" wrapper />
{:then items}
{#each (items || []).slice(0, maxShowCount) as item}
<DbKeysTreeNode {conid} {database} {root} {item} {indentLevel} />
{/each}
{#if ($items || []).length > maxShowCount}
<AppObjectCore
{indentLevel}
title="Show more..."
icon="icon dots-horizontal"
expandIcon="icon invisible-box"
on:click={() => {
maxShowCount += SHOW_INCREMENT;
}}
/>
{/if}
{#if (items || []).length > maxShowCount}
<AppObjectCore
{indentLevel}
title="Show more..."
icon="icon dots-horizontal"
expandIcon="icon invisible-box"
on:click={() => {
maxShowCount += SHOW_INCREMENT;
}}
/>
{/if}
{/await}

View File

@ -14,8 +14,11 @@
export let database;
let filter;
let reloadToken = 0;
function handleRefreshDatabase() {}
function handleRefreshDatabase() {
reloadToken += 1;
}
</script>
<SearchBoxWrapper>
@ -29,5 +32,5 @@
</InlineButton>
</SearchBoxWrapper>
<WidgetsInnerContainer>
<DbKeysSubTree {conid} {database} root="" />
<DbKeysSubTree {conid} {database} root="" {reloadToken} />
</WidgetsInnerContainer>

View File

@ -21,6 +21,7 @@
export let indentLevel = 0;
let isExpanded;
let reloadToken = 0;
// $: console.log(item.text, indentLevel);
function createMenu() {
@ -41,6 +42,12 @@
});
},
},
item.type == 'dir' && {
label: 'Reload',
onClick: () => {
reloadToken += 1;
},
},
];
}
</script>
@ -83,5 +90,5 @@
</div> -->
{#if isExpanded}
<DbKeysSubTree {conid} {database} root={item.root} indentLevel={indentLevel + 1} />
<DbKeysSubTree {conid} {database} root={item.root} indentLevel={indentLevel + 1} {reloadToken} />
{/if}