mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-23 15:06:01 +00:00
show redis keys icons
This commit is contained in:
@@ -8,8 +8,8 @@
|
|||||||
|
|
||||||
export let icon;
|
export let icon;
|
||||||
export let title;
|
export let title;
|
||||||
export let data;
|
export let data = null;
|
||||||
export let module;
|
export let module = null;
|
||||||
|
|
||||||
export let isBold = false;
|
export let isBold = false;
|
||||||
export let isBusy = false;
|
export let isBusy = false;
|
||||||
@@ -24,8 +24,10 @@
|
|||||||
export let onPin = null;
|
export let onPin = null;
|
||||||
export let onUnpin = null;
|
export let onUnpin = null;
|
||||||
export let showPinnedInsteadOfUnpin = false;
|
export let showPinnedInsteadOfUnpin = false;
|
||||||
|
export let indentLevel = 0;
|
||||||
|
|
||||||
$: isChecked = checkedObjectsStore && $checkedObjectsStore.find(x => module.extractKey(data) == module.extractKey(x));
|
$: isChecked =
|
||||||
|
checkedObjectsStore && $checkedObjectsStore.find(x => module?.extractKey(data) == module?.extractKey(x));
|
||||||
|
|
||||||
function handleExpand() {
|
function handleExpand() {
|
||||||
dispatch('expand');
|
dispatch('expand');
|
||||||
@@ -33,7 +35,7 @@
|
|||||||
function handleClick() {
|
function handleClick() {
|
||||||
if (checkedObjectsStore) {
|
if (checkedObjectsStore) {
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
checkedObjectsStore.update(x => x.filter(y => module.extractKey(data) != module.extractKey(y)));
|
checkedObjectsStore.update(x => x.filter(y => module?.extractKey(data) != module?.extractKey(y)));
|
||||||
} else {
|
} else {
|
||||||
checkedObjectsStore.update(x => [...x, data]);
|
checkedObjectsStore.update(x => [...x, data]);
|
||||||
}
|
}
|
||||||
@@ -52,12 +54,14 @@
|
|||||||
|
|
||||||
function setChecked(value) {
|
function setChecked(value) {
|
||||||
if (!value && isChecked) {
|
if (!value && isChecked) {
|
||||||
checkedObjectsStore.update(x => x.filter(y => module.extractKey(data) != module.extractKey(y)));
|
checkedObjectsStore.update(x => x.filter(y => module?.extractKey(data) != module?.extractKey(y)));
|
||||||
}
|
}
|
||||||
if (value && !isChecked) {
|
if (value && !isChecked) {
|
||||||
checkedObjectsStore.update(x => [...x, data]);
|
checkedObjectsStore.update(x => [...x, data]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: console.log(title, indentLevel);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
@@ -85,6 +89,9 @@
|
|||||||
<FontIcon icon={expandIcon} />
|
<FontIcon icon={expandIcon} />
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if indentLevel}
|
||||||
|
<span style:margin-right={`${indentLevel * 16}px`} />
|
||||||
|
{/if}
|
||||||
{#if isBusy}
|
{#if isBusy}
|
||||||
<FontIcon icon="icon loading" />
|
<FontIcon icon="icon loading" />
|
||||||
{:else}
|
{:else}
|
||||||
@@ -188,5 +195,4 @@
|
|||||||
float: right;
|
float: right;
|
||||||
color: var(--theme-font-2);
|
color: var(--theme-font-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -167,6 +167,16 @@
|
|||||||
'img link': 'mdi mdi-link',
|
'img link': 'mdi mdi-link',
|
||||||
'img filter': 'mdi mdi-filter',
|
'img filter': 'mdi mdi-filter',
|
||||||
'img group': 'mdi mdi-group',
|
'img group': 'mdi mdi-group',
|
||||||
|
|
||||||
|
'img folder': 'mdi mdi-folder color-icon-yellow',
|
||||||
|
'img type-string': 'mdi mdi-alphabetical color-icon-blue',
|
||||||
|
'img type-hash': 'mdi mdi-pound color-icon-blue',
|
||||||
|
'img type-set': 'mdi mdi-format-list-bulleted color-icon-blue',
|
||||||
|
'img type-list': 'mdi mdi-format-list-numbered color-icon-blue',
|
||||||
|
'img type-zset': 'mdi mdi-format-list-checks color-icon-blue',
|
||||||
|
'img type-stream': 'mdi mdi-view-stream color-icon-blue',
|
||||||
|
'img type-binary': 'mdi mdi-file color-icon-blue',
|
||||||
|
'img type-rejson': 'mdi mdi-color-json color-icon-blue',
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,11 @@
|
|||||||
export let database;
|
export let database;
|
||||||
|
|
||||||
export let root;
|
export let root;
|
||||||
|
export let indentLevel = 0;
|
||||||
|
|
||||||
$: items = useDatabaseKeys({ conid, database, root });
|
$: items = useDatabaseKeys({ conid, database, root });
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#each $items || [] as item}
|
{#each $items || [] as item}
|
||||||
<DbKeysTreeNode {conid} {database} {root} {item} />
|
<DbKeysTreeNode {conid} {database} {root} {item} {indentLevel} />
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -1,8 +1,29 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import CloseSearchButton from '../buttons/CloseSearchButton.svelte';
|
||||||
|
import InlineButton from '../buttons/InlineButton.svelte';
|
||||||
|
|
||||||
|
import SearchBoxWrapper from '../elements/SearchBoxWrapper.svelte';
|
||||||
|
import SearchInput from '../elements/SearchInput.svelte';
|
||||||
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
|
|
||||||
import DbKeysSubTree from './DbKeysSubTree.svelte';
|
import DbKeysSubTree from './DbKeysSubTree.svelte';
|
||||||
|
import WidgetsInnerContainer from './WidgetsInnerContainer.svelte';
|
||||||
|
|
||||||
export let conid;
|
export let conid;
|
||||||
export let database;
|
export let database;
|
||||||
|
|
||||||
|
let filter;
|
||||||
|
|
||||||
|
function handleRefreshDatabase() {}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<DbKeysSubTree {conid} {database} root="" />
|
<SearchBoxWrapper>
|
||||||
|
<SearchInput placeholder="Search keys" bind:value={filter} />
|
||||||
|
<CloseSearchButton bind:filter />
|
||||||
|
<InlineButton on:click={handleRefreshDatabase} title="Refresh key list">
|
||||||
|
<FontIcon icon="icon refresh" />
|
||||||
|
</InlineButton>
|
||||||
|
</SearchBoxWrapper>
|
||||||
|
<WidgetsInnerContainer>
|
||||||
|
<DbKeysSubTree {conid} {database} root="" />
|
||||||
|
</WidgetsInnerContainer>
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import AppObjectCore from '../appobj/AppObjectCore.svelte';
|
||||||
|
import { plusExpandIcon } from '../icons/expandIcons';
|
||||||
|
import FontIcon from '../icons/FontIcon.svelte';
|
||||||
|
|
||||||
import DbKeysSubTree from './DbKeysSubTree.svelte';
|
import DbKeysSubTree from './DbKeysSubTree.svelte';
|
||||||
|
|
||||||
export let conid;
|
export let conid;
|
||||||
@@ -7,14 +11,52 @@
|
|||||||
export let root;
|
export let root;
|
||||||
|
|
||||||
export let item;
|
export let item;
|
||||||
|
export let indentLevel = 0;
|
||||||
|
|
||||||
let isExpanded;
|
let isExpanded;
|
||||||
|
|
||||||
|
function getIconForType(type) {
|
||||||
|
switch (type) {
|
||||||
|
case 'dir':
|
||||||
|
return 'img folder';
|
||||||
|
case 'string':
|
||||||
|
return 'img type-string';
|
||||||
|
case 'hash':
|
||||||
|
return 'img type-hash';
|
||||||
|
case 'set':
|
||||||
|
return 'img type-set';
|
||||||
|
case 'list':
|
||||||
|
return 'img type-list';
|
||||||
|
case 'zset':
|
||||||
|
return 'img type-zset';
|
||||||
|
case 'stream':
|
||||||
|
return 'img type-stream';
|
||||||
|
case 'binary':
|
||||||
|
return 'img type-binary';
|
||||||
|
case 'ReJSON-RL':
|
||||||
|
return 'img type-rejson';
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// $: console.log(item.text, indentLevel);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div on:click={() => (isExpanded = !isExpanded)}>
|
<AppObjectCore
|
||||||
|
icon={getIconForType(item.type)}
|
||||||
|
title={item.text}
|
||||||
|
expandIcon={item.type == 'dir' ? plusExpandIcon(isExpanded) : 'icon invisible-box'}
|
||||||
|
on:expand={() => {
|
||||||
|
isExpanded = !isExpanded;
|
||||||
|
}}
|
||||||
|
{indentLevel}
|
||||||
|
/>
|
||||||
|
<!-- <div on:click={() => (isExpanded = !isExpanded)}>
|
||||||
|
<FontIcon icon={} />
|
||||||
{item.text}
|
{item.text}
|
||||||
</div>
|
</div> -->
|
||||||
|
|
||||||
{#if isExpanded}
|
{#if isExpanded}
|
||||||
<DbKeysSubTree {conid} {database} root={item.root} />
|
<DbKeysSubTree {conid} {database} root={item.root} indentLevel={indentLevel + 1} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user