mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 19:16:01 +00:00
key count limit
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import _omit from 'lodash/omit';
|
import _omit from 'lodash/omit';
|
||||||
import _sortBy from 'lodash/sortBy';
|
import _sortBy from 'lodash/sortBy';
|
||||||
|
|
||||||
const SHOW_INCREMENT = 100;
|
export const DB_KEYS_SHOW_INCREMENT = 100;
|
||||||
|
|
||||||
export interface DbKeysNodeModelBase {
|
export interface DbKeysNodeModelBase {
|
||||||
text?: string;
|
text?: string;
|
||||||
@@ -247,6 +247,20 @@ export function dbKeys_markNodeExpanded(tree: DbKeysTreeModel, root: string, isE
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function dbKeys_showNextItems(tree: DbKeysTreeModel, root: string): DbKeysTreeModel {
|
||||||
|
const node = tree.dirStateByKey[root];
|
||||||
|
return {
|
||||||
|
...tree,
|
||||||
|
dirStateByKey: {
|
||||||
|
...tree.dirStateByKey,
|
||||||
|
[root]: {
|
||||||
|
...node,
|
||||||
|
visibleCount: (node?.visibleCount ?? DB_KEYS_SHOW_INCREMENT) + DB_KEYS_SHOW_INCREMENT,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function dbKeys_createNewModel(treeKeySeparator: string): DbKeysTreeModel {
|
export function dbKeys_createNewModel(treeKeySeparator: string): DbKeysTreeModel {
|
||||||
const root: DbKeysFolderNodeModel = {
|
const root: DbKeysFolderNodeModel = {
|
||||||
level: 0,
|
level: 0,
|
||||||
@@ -265,7 +279,7 @@ export function dbKeys_createNewModel(treeKeySeparator: string): DbKeysTreeModel
|
|||||||
dirStateByKey: {
|
dirStateByKey: {
|
||||||
'': {
|
'': {
|
||||||
key: '',
|
key: '',
|
||||||
visibleCount: SHOW_INCREMENT,
|
visibleCount: DB_KEYS_SHOW_INCREMENT,
|
||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,7 +4,12 @@
|
|||||||
import AppObjectCore from '../appobj/AppObjectCore.svelte';
|
import AppObjectCore from '../appobj/AppObjectCore.svelte';
|
||||||
|
|
||||||
import DbKeysTreeNode from './DbKeysTreeNode.svelte';
|
import DbKeysTreeNode from './DbKeysTreeNode.svelte';
|
||||||
import { dbKeys_markNodeExpanded, DbKeysChangeModelFunction, DbKeysTreeModel } from 'dbgate-tools';
|
import {
|
||||||
|
DB_KEYS_SHOW_INCREMENT,
|
||||||
|
dbKeys_showNextItems,
|
||||||
|
DbKeysChangeModelFunction,
|
||||||
|
DbKeysTreeModel,
|
||||||
|
} from 'dbgate-tools';
|
||||||
|
|
||||||
export let key;
|
export let key;
|
||||||
export let connection;
|
export let connection;
|
||||||
@@ -20,9 +25,10 @@
|
|||||||
export let parentRoots = [];
|
export let parentRoots = [];
|
||||||
|
|
||||||
$: items = model.childrenByKey[key] ?? [];
|
$: items = model.childrenByKey[key] ?? [];
|
||||||
|
$: visibleCount = model.dirStateByKey[key]?.visibleCount ?? DB_KEYS_SHOW_INCREMENT;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#each items as item}
|
{#each items.slice(0, visibleCount) as item}
|
||||||
<DbKeysTreeNode
|
<DbKeysTreeNode
|
||||||
{conid}
|
{conid}
|
||||||
{database}
|
{database}
|
||||||
@@ -37,16 +43,14 @@
|
|||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
{#if model.dirsByKey[key]?.shouldLoadNext}
|
{#if model.childrenByKey[key]?.length > visibleCount}
|
||||||
<AppObjectCore {indentLevel} title="Loading keys..." icon="icon loading" expandIcon="icon invisible-box" />
|
|
||||||
{:else if model.dirsByKey[key]?.hasNext}
|
|
||||||
<AppObjectCore
|
<AppObjectCore
|
||||||
{indentLevel}
|
{indentLevel}
|
||||||
title="Show more..."
|
title="Show more..."
|
||||||
icon="icon dots-horizontal"
|
icon="icon dots-horizontal"
|
||||||
expandIcon="icon invisible-box"
|
expandIcon="icon invisible-box"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
changeModel(model => dbKeys_markNodeExpanded(model, key, true), false);
|
changeModel(model => dbKeys_showNextItems(model, key), false);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user