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