fix: minor bugs about keys view
This commit is contained in:
parent
8d7c8cb3ed
commit
c2bf4128f7
|
@ -2293,7 +2293,7 @@ func (b *browserService) ImportCSV(server string, db int, path string, conflict
|
|||
continue
|
||||
}
|
||||
// get ttl
|
||||
if ttl < 0 {
|
||||
if ttl < 0 && len(line) > 2 {
|
||||
// use previous
|
||||
if expire, ttlErr := strconv.ParseInt(line[2], 10, 64); ttlErr == nil && expire > 0 {
|
||||
ttlValue = time.UnixMilli(expire).Sub(time.Now())
|
||||
|
|
|
@ -16,6 +16,7 @@ import Pub from '@/components/icons/Pub.vue'
|
|||
import ContentSlog from '@/components/content_value/ContentSlog.vue'
|
||||
import { decodeTypes, formatTypes } from '@/consts/value_view_type.js'
|
||||
import ContentMonitor from '@/components/content_value/ContentMonitor.vue'
|
||||
import { decodeRedisKey } from '@/utils/key_convert.js'
|
||||
|
||||
const themeVars = useThemeVars()
|
||||
|
||||
|
@ -50,7 +51,7 @@ const tabContent = computed(() => {
|
|||
subTab: tab.subTab,
|
||||
type: toUpper(tab.type),
|
||||
db: tab.db,
|
||||
keyPath: tab.key,
|
||||
keyPath: tab.keyCode != null ? decodeRedisKey(tab.keyCode) : tab.key,
|
||||
keyCode: tab.keyCode,
|
||||
ttl: tab.ttl,
|
||||
value: tab.value,
|
||||
|
|
|
@ -111,7 +111,13 @@ const onTTL = () => {
|
|||
</template>
|
||||
TTL{{ `${ttl > 0 ? ': ' + ttl + $t('common.second') : ''}` }}
|
||||
</n-tooltip>
|
||||
<icon-button :icon="Edit" border size="18" t-tooltip="interface.rename_key" @click="emit('rename')" />
|
||||
<icon-button
|
||||
:disabled="binaryKey"
|
||||
:icon="Edit"
|
||||
:t-tooltip="binaryKey ? 'dialogue.rename_binary_key_fail' : 'interface.rename_key'"
|
||||
border
|
||||
size="18"
|
||||
@click="emit('rename')" />
|
||||
</n-button-group>
|
||||
<n-tooltip :show-arrow="false">
|
||||
<template #trigger>
|
||||
|
|
|
@ -359,8 +359,7 @@ const renderPrefix = ({ option }) => {
|
|||
browserStore.loadKeyType({
|
||||
server: props.server,
|
||||
db: option.db,
|
||||
key: option.redisKey,
|
||||
keyCode: option.redisKeyCode,
|
||||
key: option.redisKeyCode || option.redisKey,
|
||||
})
|
||||
}
|
||||
switch (prefStore.keyIconType) {
|
||||
|
|
|
@ -246,12 +246,12 @@ const getServerMenu = (connected) => {
|
|||
const getGroupMenu = () => {
|
||||
return [
|
||||
h(IconButton, {
|
||||
tTooltip: 'interface.edit_conn',
|
||||
tTooltip: 'interface.rename_conn_group',
|
||||
icon: Config,
|
||||
onClick: () => handleSelectContextMenu('group_rename'),
|
||||
}),
|
||||
h(IconButton, {
|
||||
tTooltip: 'interface.remove_conn',
|
||||
tTooltip: 'interface.remove_conn_group',
|
||||
icon: Delete,
|
||||
onClick: () => handleSelectContextMenu('group_delete'),
|
||||
}),
|
||||
|
|
|
@ -70,9 +70,9 @@
|
|||
"dup_conn": "Duplicate Connection",
|
||||
"remove_conn": "Delete Connection",
|
||||
"edit_conn": "Edit Connection Config",
|
||||
"edit_conn_group": "Edit Connection Group",
|
||||
"rename_conn_group": "Rename Connection Group",
|
||||
"remove_conn_group": "Delete Connection Group",
|
||||
"edit_conn_group": "Edit Group",
|
||||
"rename_conn_group": "Rename Group",
|
||||
"remove_conn_group": "Delete Group",
|
||||
"ttl": "TTL",
|
||||
"forever": "Forever",
|
||||
"rename_key": "Rename Key",
|
||||
|
|
|
@ -70,9 +70,9 @@
|
|||
"dup_conn": "复制连接",
|
||||
"remove_conn": "删除连接",
|
||||
"edit_conn": "编辑连接配置",
|
||||
"edit_conn_group": "编辑连接分组",
|
||||
"rename_conn_group": "重命名连接分组",
|
||||
"remove_conn_group": "删除连接分组",
|
||||
"edit_conn_group": "编辑分组",
|
||||
"rename_conn_group": "重命名分组",
|
||||
"remove_conn_group": "删除分组",
|
||||
"ttl": "TTL",
|
||||
"forever": "永久",
|
||||
"rename_key": "重命名键",
|
||||
|
|
|
@ -52,7 +52,7 @@ export class RedisServerState {
|
|||
this.getRoot()
|
||||
|
||||
const connStore = useConnectionStore()
|
||||
const { keySeparator } = connStore.getDefaultSeparator(name)
|
||||
const keySeparator = connStore.getDefaultSeparator(name)
|
||||
this.separator = isEmpty(keySeparator) ? ':' : keySeparator
|
||||
}
|
||||
|
||||
|
@ -246,8 +246,8 @@ export class RedisServerState {
|
|||
|
||||
/**
|
||||
* rename key to a new name
|
||||
* @param key
|
||||
* @param newKey
|
||||
* @param {string} key
|
||||
* @param {string} newKey
|
||||
*/
|
||||
renameKey(key, newKey) {
|
||||
const oldLayer = initial(key.split(this.separator)).join(this.separator)
|
||||
|
@ -265,7 +265,11 @@ export class RedisServerState {
|
|||
const newNodeKeyName = `${ConnectionType.RedisValue}/${newKey}`
|
||||
const keyNode = this.nodeMap.get(oldNodeKeyName)
|
||||
keyNode.key = `${this.name}/db${this.db}#${newNodeKeyName}`
|
||||
keyNode.label = last(split(newKey, this.separator))
|
||||
if (this.viewType === KeyViewType.Tree) {
|
||||
keyNode.label = last(split(newKey, this.separator))
|
||||
} else {
|
||||
keyNode.label = newKey
|
||||
}
|
||||
keyNode.redisKey = newKey
|
||||
// not support rename binary key name yet
|
||||
// keyNode.redisKeyCode = []
|
||||
|
|
|
@ -245,6 +245,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
name,
|
||||
separator: this.getSeparator(name),
|
||||
db: -1,
|
||||
viewType: view,
|
||||
})
|
||||
/** @type {Object.<number,RedisDatabaseItem>} **/
|
||||
const databases = {}
|
||||
|
@ -379,7 +380,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
})
|
||||
if (success) {
|
||||
const { type, ttl, size, length } = data
|
||||
const k = decodeRedisKey(key)
|
||||
const k = nativeRedisKey(key)
|
||||
const binaryKey = k !== key
|
||||
tab.upsertTab({
|
||||
subTab: BrowserTabType.KeyDetail,
|
||||
|
@ -426,23 +427,23 @@ const useBrowserStore = defineStore('browser', {
|
|||
* load key type
|
||||
* @param {string} server
|
||||
* @param {number} db
|
||||
* @param {string} key
|
||||
* @param {string|number[]} key
|
||||
* @param {number[]} keyCode
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async loadKeyType({ server, db, key, keyCode }) {
|
||||
async loadKeyType({ server, db, key }) {
|
||||
/** @type {RedisServerState} **/
|
||||
const serverInst = this.servers[server]
|
||||
if (serverInst == null) {
|
||||
return
|
||||
}
|
||||
const node = serverInst.getNode(ConnectionType.RedisValue, key)
|
||||
const node = serverInst.getNode(ConnectionType.RedisValue, nativeRedisKey(key))
|
||||
if (node == null || !isEmpty(node.redisType)) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
node.redisType = 'loading'
|
||||
const { data, success } = await GetKeyType({ server, db, key: keyCode || key })
|
||||
const { data, success, msg } = await GetKeyType({ server, db, key })
|
||||
if (success) {
|
||||
const { type } = data || {}
|
||||
node.redisType = type
|
||||
|
@ -508,7 +509,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
tab.updateValue({
|
||||
server,
|
||||
db,
|
||||
key: decodeRedisKey(key),
|
||||
key: nativeRedisKey(key),
|
||||
value,
|
||||
decode: retDecode,
|
||||
format: retFormat,
|
||||
|
@ -1497,7 +1498,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
tabStore.updateTTL({
|
||||
server,
|
||||
db,
|
||||
key,
|
||||
key: nativeRedisKey(key),
|
||||
ttl,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -364,8 +364,8 @@ const useConnectionStore = defineStore('connections', {
|
|||
* @return {string}
|
||||
*/
|
||||
getDefaultSeparator(name) {
|
||||
const { defaultSeparator = ':' } = this.serverProfile[name] || {}
|
||||
return defaultSeparator
|
||||
const { keySeparator = ':' } = this.serverProfile[name] || {}
|
||||
return keySeparator
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { assign, find, findIndex, get, indexOf, isEmpty, pullAt, remove, set, size } from 'lodash'
|
||||
import { defineStore } from 'pinia'
|
||||
import { TabItem } from '@/objects/tabItem.js'
|
||||
import { decodeRedisKey } from '@/utils/key_convert.js'
|
||||
|
||||
const useTabStore = defineStore('tab', {
|
||||
/**
|
||||
|
@ -543,11 +542,11 @@ const useTabStore = defineStore('tab', {
|
|||
* update ttl in tab
|
||||
* @param {string} server
|
||||
* @param {number} db
|
||||
* @param {string|number[]} key
|
||||
* @param {string} key
|
||||
* @param {number} ttl
|
||||
*/
|
||||
updateTTL({ server, db, key, ttl }) {
|
||||
let tab = find(this.tabList, { name: server, db, key: decodeRedisKey(key) })
|
||||
let tab = find(this.tabList, { name: server, db, key })
|
||||
if (tab == null) {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue