From e2f33af1c775430c18845c30ee2d171c8f5ca86f Mon Sep 17 00:00:00 2001 From: Lykin <137850705+tiny-craft@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:59:04 +0800 Subject: [PATCH] feat: the browser pane is now set to display only a single database feat: add search input in browser pane --- backend/services/browser_service.go | 16 +- frontend/src/components/common/IconButton.vue | 3 + .../components/common/RedisTypeSelector.vue | 83 +++++ .../src/components/common/RedisTypeTag.vue | 4 +- .../content_value/ContentSearchInput.vue | 36 +- .../components/dialogs/KeyFilterDialog.vue | 6 +- .../src/components/dialogs/NewKeyDialog.vue | 18 +- frontend/src/components/icons/LoadAll.vue | 4 +- frontend/src/components/icons/More.vue | 12 +- frontend/src/components/icons/Plus.vue | 27 ++ frontend/src/components/icons/Search.vue | 8 +- .../src/components/sidebar/BrowserPane.vue | 313 +++++++++++++----- .../src/components/sidebar/BrowserTree.vue | 291 +++------------- .../src/components/sidebar/ConnectionTree.vue | 22 +- frontend/src/langs/en-us.json | 2 +- frontend/src/langs/pt-br.json | 3 +- frontend/src/langs/zh-cn.json | 2 +- frontend/src/stores/browser.js | 143 ++++---- frontend/src/styles/style.scss | 20 +- frontend/src/utils/glob_pattern.js | 13 + frontend/src/utils/render.js | 20 ++ 21 files changed, 609 insertions(+), 437 deletions(-) create mode 100644 frontend/src/components/common/RedisTypeSelector.vue create mode 100644 frontend/src/components/icons/Plus.vue create mode 100644 frontend/src/utils/glob_pattern.js create mode 100644 frontend/src/utils/render.js diff --git a/backend/services/browser_service.go b/backend/services/browser_service.go index 8369bf9..e83f8e4 100644 --- a/backend/services/browser_service.go +++ b/backend/services/browser_service.go @@ -390,7 +390,20 @@ func (b *browserService) ServerInfo(name string) (resp types.JSResp) { // @param path contain connection name and db name func (b *browserService) OpenDatabase(connName string, db int, match string, keyType string) (resp types.JSResp) { b.setClientCursor(connName, db, 0) - return b.LoadNextKeys(connName, db, match, keyType) + + item, err := b.getRedisClient(connName, db) + if err != nil { + resp.Msg = err.Error() + return + } + client, ctx := item.client, item.ctx + maxKeys := b.loadDBSize(ctx, client) + + resp.Success = true + resp.Data = map[string]any{ + "maxKeys": maxKeys, + } + return } // scan keys @@ -433,6 +446,7 @@ func (b *browserService) scanKeys(ctx context.Context, client redis.UniversalCli // cluster mode var mutex sync.Mutex err = cluster.ForEachMaster(ctx, func(ctx context.Context, cli *redis.Client) error { + // FIXME: BUG? can not fully load in cluster mode? maybe remove the shared "cursor" return scan(ctx, cli, func(k []any) { mutex.Lock() keys = append(keys, k...) diff --git a/frontend/src/components/common/IconButton.vue b/frontend/src/components/common/IconButton.vue index e632d46..4692da5 100644 --- a/frontend/src/components/common/IconButton.vue +++ b/frontend/src/components/common/IconButton.vue @@ -26,6 +26,7 @@ const props = defineProps({ disabled: Boolean, buttonStyle: [String, Object], buttonClass: [String, Object], + small: Boolean, }) const hasTooltip = computed(() => { @@ -42,6 +43,7 @@ const hasTooltip = computed(() => { :disabled="disabled" :focusable="false" :loading="loading" + :size="small ? 'small' : ''" :style="props.buttonStyle" :text="!border" :type="type" @@ -64,6 +66,7 @@ const hasTooltip = computed(() => { :disabled="disabled" :focusable="false" :loading="loading" + :size="small ? 'small' : ''" :style="props.buttonStyle" :text="!border" :type="type" diff --git a/frontend/src/components/common/RedisTypeSelector.vue b/frontend/src/components/common/RedisTypeSelector.vue new file mode 100644 index 0000000..c6abe5d --- /dev/null +++ b/frontend/src/components/common/RedisTypeSelector.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/frontend/src/components/common/RedisTypeTag.vue b/frontend/src/components/common/RedisTypeTag.vue index 3bba2de..eb9573d 100644 --- a/frontend/src/components/common/RedisTypeTag.vue +++ b/frontend/src/components/common/RedisTypeTag.vue @@ -12,7 +12,6 @@ const props = defineProps({ default: 'STRING', }, binaryKey: Boolean, - bordered: Boolean, size: String, }) @@ -27,9 +26,8 @@ const backgroundColor = computed(() => {