Compare commits
5 Commits
c7a365e8e9
...
c5abaa6573
Author | SHA1 | Date |
---|---|---|
Lykin | c5abaa6573 | |
Lykin | 8f15656f37 | |
Lykin | 860e1eaac3 | |
Lykin | d31da4a055 | |
Lykin | 566a7e212f |
|
@ -562,47 +562,59 @@ func (b *browserService) GetKeySummary(param types.KeySummaryParam) (resp types.
|
|||
|
||||
client, ctx := item.client, item.ctx
|
||||
key := strutil.DecodeRedisKey(param.Key)
|
||||
var keyType string
|
||||
var dur time.Duration
|
||||
keyType, err = client.Type(ctx, key).Result()
|
||||
|
||||
pipe := client.Pipeline()
|
||||
typeVal := pipe.Type(ctx, key)
|
||||
ttlVal := pipe.TTL(ctx, key)
|
||||
sizeVal := pipe.MemoryUsage(ctx, key, 0)
|
||||
_, err = pipe.Exec(ctx)
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
if keyType == "none" {
|
||||
if typeVal.Err() != nil {
|
||||
resp.Msg = typeVal.Err().Error()
|
||||
return
|
||||
}
|
||||
data := types.KeySummary{
|
||||
Type: strings.ToLower(typeVal.Val()),
|
||||
Size: sizeVal.Val(),
|
||||
}
|
||||
if data.Type == "none" {
|
||||
resp.Msg = "key not exists"
|
||||
return
|
||||
}
|
||||
|
||||
var data types.KeySummary
|
||||
data.Type = strings.ToLower(keyType)
|
||||
if dur, err = client.TTL(ctx, key).Result(); err != nil {
|
||||
if ttlVal.Err() != nil {
|
||||
data.TTL = -1
|
||||
} else {
|
||||
if dur < 0 {
|
||||
if ttlVal.Val() < 0 {
|
||||
data.TTL = -1
|
||||
} else {
|
||||
data.TTL = int64(dur.Seconds())
|
||||
data.TTL = int64(ttlVal.Val().Seconds())
|
||||
}
|
||||
}
|
||||
|
||||
data.Size, _ = client.MemoryUsage(ctx, key, 0).Result()
|
||||
switch data.Type {
|
||||
case "string":
|
||||
data.Length, _ = client.StrLen(ctx, key).Result()
|
||||
data.Length, err = client.StrLen(ctx, key).Result()
|
||||
case "list":
|
||||
data.Length, _ = client.LLen(ctx, key).Result()
|
||||
data.Length, err = client.LLen(ctx, key).Result()
|
||||
case "hash":
|
||||
data.Length, _ = client.HLen(ctx, key).Result()
|
||||
data.Length, err = client.HLen(ctx, key).Result()
|
||||
case "set":
|
||||
data.Length, _ = client.SCard(ctx, key).Result()
|
||||
data.Length, err = client.SCard(ctx, key).Result()
|
||||
case "zset":
|
||||
data.Length, _ = client.ZCard(ctx, key).Result()
|
||||
data.Length, err = client.ZCard(ctx, key).Result()
|
||||
case "stream":
|
||||
data.Length, _ = client.XLen(ctx, key).Result()
|
||||
data.Length, err = client.XLen(ctx, key).Result()
|
||||
default:
|
||||
resp.Msg = "unknown key type"
|
||||
err = errors.New("unknown key type")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ func (s *systemService) SelectFile(title string) (resp types.JSResp) {
|
|||
|
||||
func (s *systemService) loopWindowEvent() {
|
||||
var fullscreen, maximised, minimised, normal bool
|
||||
var width, height, posx, posy int
|
||||
var width, height int
|
||||
var dirty bool
|
||||
for {
|
||||
time.Sleep(300 * time.Millisecond)
|
||||
|
@ -84,12 +84,6 @@ func (s *systemService) loopWindowEvent() {
|
|||
dirty = true
|
||||
}
|
||||
|
||||
if x, y := runtime.WindowGetPosition(s.ctx); x != posx || y != posy {
|
||||
// window position changed
|
||||
posx, posy = x, y
|
||||
dirty = true
|
||||
}
|
||||
|
||||
if m := runtime.WindowIsMaximised(s.ctx); m != maximised {
|
||||
maximised = m
|
||||
dirty = true
|
||||
|
@ -118,7 +112,6 @@ func (s *systemService) loopWindowEvent() {
|
|||
if !fullscreen && !minimised {
|
||||
// save window size and position
|
||||
Preferences().SaveWindowSize(width, height, maximised)
|
||||
Preferences().SaveWindowPosition(posx, posy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,10 +132,11 @@ func autoDecode(str string) (value, resultDecode string) {
|
|||
return
|
||||
}
|
||||
|
||||
if value, ok = decodeBrotli(str); ok {
|
||||
resultDecode = types.DECODE_BROTLI
|
||||
return
|
||||
}
|
||||
// FIXME: skip decompress with brotli due to incorrect format checking
|
||||
//if value, ok = decodeBrotli(str); ok {
|
||||
// resultDecode = types.DECODE_BROTLI
|
||||
// return
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<title>Tiny RDM</title>
|
||||
<!-- <link href="./src/styles/style.scss" rel="stylesheet">-->
|
||||
</head>
|
||||
<body>
|
||||
<body spellcheck="false">
|
||||
<div id='app'></div>
|
||||
<script src='./src/main.js' type='module'></script>
|
||||
</body>
|
||||
|
|
|
@ -17,7 +17,7 @@ const handleUpdateValue = (val) => {
|
|||
<template>
|
||||
<div style="min-height: 22px">
|
||||
<template v-if="props.isEdit">
|
||||
<n-input :input-props="{ spellcheck: 'false' }" :value="props.value" @update:value="handleUpdateValue" />
|
||||
<n-input :value="props.value" @update:value="handleUpdateValue" />
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ props.value }}
|
||||
|
|
|
@ -23,12 +23,7 @@ const handleSelectFile = async () => {
|
|||
|
||||
<template>
|
||||
<n-input-group>
|
||||
<n-input
|
||||
v-model:value="props.value"
|
||||
:disabled="props.disabled"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="placeholder"
|
||||
clearable />
|
||||
<n-input v-model:value="props.value" :disabled="props.disabled" :placeholder="placeholder" clearable />
|
||||
<n-button :disabled="props.disabled" :focusable="false" @click="handleSelectFile">...</n-button>
|
||||
</n-input-group>
|
||||
</template>
|
||||
|
|
|
@ -76,10 +76,10 @@ const columns = computed(() => [
|
|||
return h(
|
||||
'div',
|
||||
null,
|
||||
map(cmdList, (c) => h('div', null, c)),
|
||||
map(cmdList, (c) => h('div', { class: 'cmd-line' }, c)),
|
||||
)
|
||||
}
|
||||
return cmd
|
||||
return h('div', { class: 'cmd-line' }, cmd)
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -148,7 +148,7 @@ defineExpose({
|
|||
style="min-width: 100px" />
|
||||
</n-form-item>
|
||||
<n-form-item :label="$t('log.filter_keyword')">
|
||||
<n-input v-model:value="data.keyword" :input-props="{ spellcheck: 'false' }" clearable placeholder="" />
|
||||
<n-input v-model:value="data.keyword" clearable placeholder="" />
|
||||
</n-form-item>
|
||||
<n-form-item label=" ">
|
||||
<icon-button :icon="Refresh" border t-tooltip="log.refresh" @click="loadHistory" />
|
||||
|
|
|
@ -164,7 +164,6 @@ const onSave = () => {
|
|||
<div class="editor-content-item-label">{{ props.fieldLabel }}</div>
|
||||
<n-input
|
||||
v-model:value="viewAs.field"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="props.field + ''"
|
||||
:readonly="props.fieldReadonly"
|
||||
class="editor-content-item-input"
|
||||
|
|
|
@ -88,7 +88,6 @@ defineExpose({
|
|||
<slot name="prepend" />
|
||||
<n-input
|
||||
v-model:value="inputData.filter"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('interface.filter')"
|
||||
:size="props.small ? 'small' : ''"
|
||||
clearable
|
||||
|
|
|
@ -186,7 +186,7 @@ const infoFilter = ref('')
|
|||
</n-card>
|
||||
<n-card :title="$t('status.all_info')" embedded>
|
||||
<template #header-extra>
|
||||
<n-input v-model:value="infoFilter" :input-props="{ spellcheck: 'false' }" clearable placeholder="">
|
||||
<n-input v-model:value="infoFilter" clearable placeholder="">
|
||||
<template #prefix>
|
||||
<icon-button :icon="Filter" size="18" />
|
||||
</template>
|
||||
|
|
|
@ -89,10 +89,10 @@ const columns = computed(() => [
|
|||
return h(
|
||||
'div',
|
||||
null,
|
||||
map(cmdList, (c) => h('div', null, c)),
|
||||
map(cmdList, (c) => h('div', { class: 'cmd-line' }, c)),
|
||||
)
|
||||
}
|
||||
return cmd
|
||||
return h('div', { class: 'cmd-line' }, cmd)
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -176,7 +176,7 @@ const onListLimitChanged = (limit) => {
|
|||
</n-tooltip>
|
||||
</n-form-item>
|
||||
<n-form-item :label="$t('slog.filter')">
|
||||
<n-input v-model:value="data.keyword" :input-props="{ spellcheck: 'false' }" clearable placeholder="" />
|
||||
<n-input v-model:value="data.keyword" clearable placeholder="" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
<div class="content-value fill-height flex-box-h">
|
||||
|
|
|
@ -78,7 +78,7 @@ const onCopyKey = () => {
|
|||
<div class="content-toolbar flex-box-h">
|
||||
<n-input-group>
|
||||
<redis-type-tag :binary-key="binaryKey" :type="props.keyType" size="large" />
|
||||
<n-input v-model:value="props.keyPath" :input-props="{ spellcheck: 'false' }" readonly>
|
||||
<n-input v-model:value="props.keyPath" :title="props.keyPath" readonly>
|
||||
<template #suffix>
|
||||
<icon-button
|
||||
:icon="Refresh"
|
||||
|
|
|
@ -205,12 +205,13 @@ const actionColumn = {
|
|||
onEdit: () => startEdit(index + 1, row.k, row.v),
|
||||
onDelete: async () => {
|
||||
try {
|
||||
const { removed, success, msg } = await browserStore.removeHashField(
|
||||
props.name,
|
||||
props.db,
|
||||
keyName.value,
|
||||
row.k,
|
||||
)
|
||||
const { removed, success, msg } = await browserStore.removeHashField({
|
||||
server: props.name,
|
||||
db: props.db,
|
||||
key: keyName.value,
|
||||
field: row.k,
|
||||
reload: false,
|
||||
})
|
||||
if (success) {
|
||||
props.value.splice(index, 1)
|
||||
$message.success(i18n.t('dialogue.delete_key_succ', { key: row.k }))
|
||||
|
|
|
@ -183,14 +183,13 @@ const actionColumn = {
|
|||
},
|
||||
onDelete: async () => {
|
||||
try {
|
||||
const { success, msg } = await browserStore.removeListItem(
|
||||
props.name,
|
||||
props.db,
|
||||
keyName.value,
|
||||
const { success, msg } = await browserStore.removeListItem({
|
||||
server: props.name,
|
||||
db: props.db,
|
||||
key: keyName.value,
|
||||
index,
|
||||
)
|
||||
})
|
||||
if (success) {
|
||||
props.value.splice(index, 1)
|
||||
$message.success(i18n.t('dialogue.delete_key_succ', { key: `#${index + 1}` }))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
|
|
|
@ -180,14 +180,13 @@ const actionColumn = {
|
|||
},
|
||||
onDelete: async () => {
|
||||
try {
|
||||
const { success, msg } = await browserStore.removeSetItem(
|
||||
props.name,
|
||||
props.db,
|
||||
keyName.value,
|
||||
row.v,
|
||||
)
|
||||
const { success, msg } = await browserStore.removeSetItem({
|
||||
server: props.name,
|
||||
db: props.db,
|
||||
key: keyName.value,
|
||||
value: row.v,
|
||||
})
|
||||
if (success) {
|
||||
// props.value.splice(index, 1)
|
||||
$message.success(i18n.t('dialogue.delete_key_succ', { key: row.v }))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
|
|
|
@ -120,12 +120,12 @@ const actionColumn = {
|
|||
},
|
||||
onDelete: async () => {
|
||||
try {
|
||||
const { success, msg } = await browserStore.removeStreamValues(
|
||||
props.name,
|
||||
props.db,
|
||||
keyName.value,
|
||||
row.id,
|
||||
)
|
||||
const { success, msg } = await browserStore.removeStreamValues({
|
||||
server: props.name,
|
||||
db: props.db,
|
||||
key: keyName.value,
|
||||
ids: row.id,
|
||||
})
|
||||
if (success) {
|
||||
$message.success(i18n.t('dialogue.delete_key_succ', { key: row.id }))
|
||||
} else {
|
||||
|
|
|
@ -145,7 +145,6 @@ const onSave = async () => {
|
|||
decode: viewAs.decode,
|
||||
})
|
||||
if (success) {
|
||||
// await browserStore.loadKeyDetail({ server: props.name, db: props.db, key: keyName.value })
|
||||
$message.success(i18n.t('interface.save_value_succ'))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
|
|
|
@ -227,14 +227,13 @@ const actionColumn = {
|
|||
onEdit: () => startEdit(index + 1, row.s, row.v),
|
||||
onDelete: async () => {
|
||||
try {
|
||||
const { success, msg } = await browserStore.removeZSetItem(
|
||||
props.name,
|
||||
props.db,
|
||||
keyName.value,
|
||||
row.v,
|
||||
)
|
||||
const { success, msg } = await browserStore.removeZSetItem({
|
||||
server: props.name,
|
||||
db: props.db,
|
||||
key: keyName.value,
|
||||
value: row.v,
|
||||
})
|
||||
if (success) {
|
||||
// props.value.splice(index, 1)
|
||||
$message.success(i18n.t('dialogue.delete_key_succ', { key: row.v }))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
|
|
|
@ -9,7 +9,7 @@ import AddListValue from '@/components/new_value/AddListValue.vue'
|
|||
import AddHashValue from '@/components/new_value/AddHashValue.vue'
|
||||
import AddZSetValue from '@/components/new_value/AddZSetValue.vue'
|
||||
import NewStreamValue from '@/components/new_value/NewStreamValue.vue'
|
||||
import { isEmpty, size, slice } from 'lodash'
|
||||
import { get, isEmpty, size, slice } from 'lodash'
|
||||
import useBrowserStore from 'stores/browser.js'
|
||||
import useTabStore from 'stores/tab.js'
|
||||
|
||||
|
@ -22,7 +22,7 @@ const newForm = reactive({
|
|||
type: '',
|
||||
opType: 0,
|
||||
value: null,
|
||||
reload: true,
|
||||
reload: false,
|
||||
})
|
||||
|
||||
const addValueComponent = {
|
||||
|
@ -89,88 +89,102 @@ const onAdd = async () => {
|
|||
value = defaultValue[type]
|
||||
}
|
||||
const keyName = isEmpty(keyCode) ? key : keyCode
|
||||
let updated = false
|
||||
let success = false
|
||||
let msg = ''
|
||||
switch (type) {
|
||||
case types.LIST:
|
||||
{
|
||||
let data
|
||||
if (newForm.opType === 1) {
|
||||
data = await browserStore.prependListItem({ server, db, key: keyName, values: value })
|
||||
data = await browserStore.prependListItem({
|
||||
server,
|
||||
db,
|
||||
key: keyName,
|
||||
values: value,
|
||||
reload: newForm.reload,
|
||||
})
|
||||
} else {
|
||||
data = await browserStore.appendListItem({ server, db, key: keyName, values: value })
|
||||
}
|
||||
const { success, msg } = data
|
||||
if (success) {
|
||||
updated = true
|
||||
$message.success(i18n.t('dialogue.handle_succ'))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
data = await browserStore.appendListItem({
|
||||
server,
|
||||
db,
|
||||
key: keyName,
|
||||
values: value,
|
||||
reload: newForm.reload,
|
||||
})
|
||||
}
|
||||
success = get(data, 'success')
|
||||
msg = get(data, 'msg')
|
||||
}
|
||||
break
|
||||
|
||||
case types.HASH:
|
||||
{
|
||||
const { success, msg } = await browserStore.addHashField(server, db, keyName, newForm.opType, value)
|
||||
if (success) {
|
||||
updated = true
|
||||
$message.success(i18n.t('dialogue.handle_succ'))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
const data = await browserStore.addHashField({
|
||||
server,
|
||||
db,
|
||||
key: keyName,
|
||||
action: newForm.opType,
|
||||
fieldItems: value,
|
||||
reload: newForm.reload,
|
||||
})
|
||||
success = get(data, 'success')
|
||||
msg = get(data, 'msg')
|
||||
}
|
||||
break
|
||||
|
||||
case types.SET:
|
||||
{
|
||||
const { success, msg } = await browserStore.addSetItem(server, db, keyName, value)
|
||||
if (success) {
|
||||
updated = true
|
||||
$message.success(i18n.t('dialogue.handle_succ'))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
const data = await browserStore.addSetItem({
|
||||
server,
|
||||
db,
|
||||
key: keyName,
|
||||
value,
|
||||
reload: newForm.reload,
|
||||
})
|
||||
success = get(data, 'success')
|
||||
msg = get(data, 'msg')
|
||||
}
|
||||
break
|
||||
|
||||
case types.ZSET:
|
||||
{
|
||||
const { success, msg } = await browserStore.addZSetItem(server, db, keyName, newForm.opType, value)
|
||||
if (success) {
|
||||
updated = true
|
||||
$message.success(i18n.t('dialogue.handle_succ'))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
const data = await browserStore.addZSetItem({
|
||||
server,
|
||||
db,
|
||||
key: keyName,
|
||||
action: newForm.opType,
|
||||
vs: value,
|
||||
reload: newForm.reload,
|
||||
})
|
||||
success = get(data, 'success')
|
||||
msg = get(data, 'msg')
|
||||
}
|
||||
break
|
||||
|
||||
case types.STREAM:
|
||||
{
|
||||
if (size(value) > 2) {
|
||||
const { success, msg } = await browserStore.addStreamValue(
|
||||
const data = await browserStore.addStreamValue({
|
||||
server,
|
||||
db,
|
||||
keyName,
|
||||
value[0],
|
||||
slice(value, 1),
|
||||
)
|
||||
if (success) {
|
||||
updated = true
|
||||
$message.success(i18n.t('dialogue.handle_succ'))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
key: keyName,
|
||||
id: value[0],
|
||||
values: slice(value, 1),
|
||||
reload: newForm.reload,
|
||||
})
|
||||
success = get(data, 'success')
|
||||
msg = get(data, 'msg')
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
if (updated) {
|
||||
if (newForm.reload) {
|
||||
browserStore.reloadKey({ server, db, key: keyName })
|
||||
}
|
||||
if (success) {
|
||||
$message.success(i18n.t('dialogue.handle_succ'))
|
||||
} else if (!isEmpty(msg)) {
|
||||
$message.error(msg)
|
||||
}
|
||||
|
||||
dialogStore.closeAddFieldsDialog()
|
||||
} catch (e) {
|
||||
$message.error(e.message)
|
||||
|
@ -202,11 +216,7 @@ const onClose = () => {
|
|||
<n-scrollbar style="max-height: 500px">
|
||||
<n-form :model="newForm" :show-require-mark="false" label-placement="top" style="padding-right: 15px">
|
||||
<n-form-item :label="$t('common.key')" path="key" required>
|
||||
<n-input
|
||||
v-model:value="newForm.key"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
placeholder=""
|
||||
readonly />
|
||||
<n-input v-model:value="newForm.key" placeholder="" readonly />
|
||||
</n-form-item>
|
||||
<component
|
||||
:is="addValueComponent[newForm.type]"
|
||||
|
|
|
@ -271,7 +271,6 @@ const onClose = () => {
|
|||
required>
|
||||
<n-input
|
||||
v-model:value="generalForm.name"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.connection.name_tip')" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi
|
||||
|
@ -284,7 +283,6 @@ const onClose = () => {
|
|||
<n-form-item-gi :label="$t('dialogue.connection.addr')" :span="24" path="addr" required>
|
||||
<n-input
|
||||
v-model:value="generalForm.addr"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.connection.addr_tip')" />
|
||||
<n-text style="width: 40px; text-align: center">:</n-text>
|
||||
<n-input-number
|
||||
|
@ -296,7 +294,6 @@ const onClose = () => {
|
|||
<n-form-item-gi :label="$t('dialogue.connection.pwd')" :span="12" path="password">
|
||||
<n-input
|
||||
v-model:value="generalForm.password"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.connection.pwd_tip')"
|
||||
show-password-on="click"
|
||||
type="password" />
|
||||
|
@ -304,7 +301,6 @@ const onClose = () => {
|
|||
<n-form-item-gi :label="$t('dialogue.connection.usr')" :span="12" path="username">
|
||||
<n-input
|
||||
v-model:value="generalForm.username"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.connection.usr_tip')" />
|
||||
</n-form-item-gi>
|
||||
</n-grid>
|
||||
|
@ -326,7 +322,6 @@ const onClose = () => {
|
|||
path="defaultFilter">
|
||||
<n-input
|
||||
v-model:value="generalForm.defaultFilter"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.connection.advn.filter_tip')" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi
|
||||
|
@ -335,7 +330,6 @@ const onClose = () => {
|
|||
path="keySeparator">
|
||||
<n-input
|
||||
v-model:value="generalForm.keySeparator"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.connection.advn.separator_tip')" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi
|
||||
|
@ -392,7 +386,6 @@ const onClose = () => {
|
|||
v-model:value="dbFilterList"
|
||||
:clearable="true"
|
||||
:disabled="generalForm.dbFilterType === 'none'"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.connection.advn.dbfilter_input_tip')"
|
||||
:show="false"
|
||||
:show-arrow="false"
|
||||
|
@ -471,7 +464,6 @@ const onClose = () => {
|
|||
<n-form-item :label="$t('dialogue.connection.addr')" required>
|
||||
<n-input
|
||||
v-model:value="generalForm.ssh.addr"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.connection.ssh.addr_tip')" />
|
||||
<n-text style="width: 40px; text-align: center">:</n-text>
|
||||
<n-input-number
|
||||
|
@ -491,13 +483,11 @@ const onClose = () => {
|
|||
:label="$t('dialogue.connection.usr')">
|
||||
<n-input
|
||||
v-model:value="generalForm.ssh.username"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.connection.ssh.usr_tip')" />
|
||||
</n-form-item>
|
||||
<n-form-item v-if="sshLoginType === 'pwd'" :label="$t('dialogue.connection.pwd')">
|
||||
<n-input
|
||||
v-model:value="generalForm.ssh.password"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.connection.ssh.pwd_tip')"
|
||||
show-password-on="click"
|
||||
type="password" />
|
||||
|
@ -511,7 +501,6 @@ const onClose = () => {
|
|||
<n-form-item v-if="sshLoginType === 'pkfile'" :label="$t('dialogue.connection.ssh.passphrase')">
|
||||
<n-input
|
||||
v-model:value="generalForm.ssh.passphrase"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.connection.ssh.passphrase_tip')"
|
||||
show-password-on="click"
|
||||
type="password" />
|
||||
|
@ -535,7 +524,6 @@ const onClose = () => {
|
|||
<n-input-group>
|
||||
<n-select
|
||||
v-model:value="generalForm.sentinel.master"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:options="masterNameOptions"
|
||||
filterable
|
||||
tag />
|
||||
|
@ -547,7 +535,6 @@ const onClose = () => {
|
|||
<n-form-item :label="$t('dialogue.connection.sentinel.password')">
|
||||
<n-input
|
||||
v-model:value="generalForm.sentinel.password"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.connection.sentinel.pwd_tip')"
|
||||
show-password-on="click"
|
||||
type="password" />
|
||||
|
@ -555,7 +542,6 @@ const onClose = () => {
|
|||
<n-form-item :label="$t('dialogue.connection.sentinel.username')">
|
||||
<n-input
|
||||
v-model:value="generalForm.sentinel.username"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.connection.sentinel.usr_tip')" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
|
|
|
@ -109,11 +109,7 @@ const onClose = () => {
|
|||
v-if="!(deleteForm.key instanceof Array)"
|
||||
:label="$t('dialogue.key.key_expression')"
|
||||
required>
|
||||
<n-input
|
||||
v-model:value="deleteForm.key"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
placeholder=""
|
||||
@input="resetAffected" />
|
||||
<n-input v-model:value="deleteForm.key" placeholder="" @input="resetAffected" />
|
||||
</n-form-item>
|
||||
<!-- <n-form-item :label="$t('dialogue.key.async_delete')" required>-->
|
||||
<!-- <n-checkbox v-model:checked="deleteForm.async">-->
|
||||
|
|
|
@ -112,7 +112,7 @@ const onClose = () => {
|
|||
:show-require-mark="false"
|
||||
label-placement="top">
|
||||
<n-form-item :label="$t('dialogue.group.name')" path="name" required>
|
||||
<n-input v-model:value="groupForm.name" :input-props="{ spellcheck: 'false' }" placeholder="" />
|
||||
<n-input v-model:value="groupForm.name" placeholder="" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</n-modal>
|
||||
|
|
|
@ -85,7 +85,6 @@ const onClose = () => {
|
|||
<template #trigger>
|
||||
<n-input
|
||||
v-model:value="filterForm.pattern"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.filter.filter_pattern')"
|
||||
clearable />
|
||||
</template>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import { computed, h, reactive, ref, watch } from 'vue'
|
||||
import { types, typesColor } from '@/consts/support_redis_type.js'
|
||||
import useDialog from 'stores/dialog'
|
||||
import { get, isEmpty, keys, map } from 'lodash'
|
||||
import { get, isEmpty, keys, map, trim } from 'lodash'
|
||||
import NewStringValue from '@/components/new_value/NewStringValue.vue'
|
||||
import NewHashValue from '@/components/new_value/NewHashValue.vue'
|
||||
import NewListValue from '@/components/new_value/NewListValue.vue'
|
||||
|
@ -46,7 +46,7 @@ const options = computed(() => {
|
|||
label: t,
|
||||
}))
|
||||
})
|
||||
const addValueComponent = {
|
||||
const newValueComponent = {
|
||||
[types.STRING]: NewStringValue,
|
||||
[types.HASH]: NewHashValue,
|
||||
[types.LIST]: NewListValue,
|
||||
|
@ -100,6 +100,10 @@ const renderTypeLabel = (option) => {
|
|||
)
|
||||
}
|
||||
|
||||
const onChangeType = () => {
|
||||
newForm.value = null
|
||||
}
|
||||
|
||||
const browserStore = useBrowserStore()
|
||||
const tabStore = useTabStore()
|
||||
const onAdd = async () => {
|
||||
|
@ -128,7 +132,7 @@ const onAdd = async () => {
|
|||
const { success, msg, nodeKey } = await browserStore.setKey({
|
||||
server,
|
||||
db,
|
||||
key,
|
||||
key: trim(key),
|
||||
keyType: type,
|
||||
value,
|
||||
ttl,
|
||||
|
@ -136,7 +140,7 @@ const onAdd = async () => {
|
|||
if (success) {
|
||||
// select current key
|
||||
tabStore.setSelectedKeys(server, nodeKey)
|
||||
browserStore.loadKeySummary({ server, db, key })
|
||||
browserStore.loadKeySummary({ server, db, key, clearValue: true })
|
||||
} else if (!isEmpty(msg)) {
|
||||
$message.error(msg)
|
||||
}
|
||||
|
@ -178,17 +182,17 @@ const onClose = () => {
|
|||
label-placement="top"
|
||||
style="padding-right: 15px">
|
||||
<n-form-item :label="$t('common.key')" path="key" required>
|
||||
<n-input v-model:value="newForm.key" :input-props="{ spellcheck: 'false' }" placeholder="" />
|
||||
<n-input v-model:value="newForm.key" placeholder="" />
|
||||
</n-form-item>
|
||||
<n-form-item :label="$t('dialogue.key.db_index')" path="db" required>
|
||||
<n-select
|
||||
v-model:value="newForm.db"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:options="dbOptions"
|
||||
filterable />
|
||||
<n-select v-model:value="newForm.db" :options="dbOptions" filterable />
|
||||
</n-form-item>
|
||||
<n-form-item :label="$t('interface.type')" path="type" required>
|
||||
<n-select v-model:value="newForm.type" :options="options" :render-label="renderTypeLabel" />
|
||||
<n-select
|
||||
v-model:value="newForm.type"
|
||||
:options="options"
|
||||
:render-label="renderTypeLabel"
|
||||
@update:value="onChangeType" />
|
||||
</n-form-item>
|
||||
<n-form-item :label="$t('interface.ttl')" required>
|
||||
<n-input-group>
|
||||
|
@ -206,7 +210,7 @@ const onClose = () => {
|
|||
</n-button>
|
||||
</n-input-group>
|
||||
</n-form-item>
|
||||
<component :is="addValueComponent[newForm.type]" ref="subFormRef" v-model:value="newForm.value" />
|
||||
<component :is="newValueComponent[newForm.type]" ref="subFormRef" v-model:value="newForm.value" />
|
||||
<!-- TODO: Add import from txt file option -->
|
||||
</n-form>
|
||||
</n-scrollbar>
|
||||
|
|
|
@ -88,14 +88,12 @@ const onClose = () => {
|
|||
<n-form-item-gi :label="$t('preferences.general.language')" :span="24" required>
|
||||
<n-select
|
||||
v-model:value="prefStore.general.language"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:options="prefStore.langOption"
|
||||
filterable />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="$t('preferences.general.font')" :span="12" required>
|
||||
<n-select
|
||||
v-model:value="prefStore.general.font"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:options="prefStore.fontOption"
|
||||
filterable />
|
||||
</n-form-item-gi>
|
||||
|
@ -106,10 +104,7 @@ const onClose = () => {
|
|||
<n-input-number v-model:value="prefStore.general.scanSize" :min="1" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="$t('preferences.general.key_icon_style')" :span="12">
|
||||
<n-select
|
||||
v-model:value="prefStore.general.keyIconStyle"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:options="keyOptions" />
|
||||
<n-select v-model:value="prefStore.general.keyIconStyle" :options="keyOptions" />
|
||||
</n-form-item-gi>
|
||||
<n-form-item-gi :label="$t('preferences.general.proxy')" :span="24">
|
||||
<n-space>
|
||||
|
@ -136,7 +131,6 @@ const onClose = () => {
|
|||
<n-form-item-gi :label="$t('preferences.general.font')" :span="24" required>
|
||||
<n-select
|
||||
v-model:value="prefStore.editor.font"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:options="prefStore.fontOption"
|
||||
filterable />
|
||||
</n-form-item-gi>
|
||||
|
|
|
@ -74,7 +74,7 @@ const onClose = () => {
|
|||
label-align="left"
|
||||
label-placement="top">
|
||||
<n-form-item :label="$t('dialogue.key.new_name')" required>
|
||||
<n-input v-model:value="renameForm.newKey" :input-props="{ spellcheck: 'false' }" />
|
||||
<n-input v-model:value="renameForm.newKey" />
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</n-modal>
|
||||
|
|
|
@ -80,7 +80,7 @@ const onConfirm = async () => {
|
|||
transform-origin="center">
|
||||
<n-form :model="ttlForm" :show-require-mark="false" label-placement="top">
|
||||
<n-form-item :label="$t('common.key')">
|
||||
<n-input :input-props="{ spellcheck: 'false' }" :value="ttlForm.key" readonly>
|
||||
<n-input :value="ttlForm.key" readonly>
|
||||
<template #prefix>
|
||||
<n-icon v-if="!!ttlForm.keyCode" :component="Binary" size="20" />
|
||||
</template>
|
||||
|
|
|
@ -65,7 +65,6 @@ const onUpdate = () => {
|
|||
<template #default="{ value }">
|
||||
<n-input
|
||||
v-model:value="value.value"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.field.enter_value')"
|
||||
type="text"
|
||||
@update:value="onUpdate" />
|
||||
|
|
|
@ -41,7 +41,7 @@ defineExpose({
|
|||
|
||||
<template>
|
||||
<n-form-item label="ID">
|
||||
<n-input v-model:value="id" :input-props="{ spellcheck: 'false' }" />
|
||||
<n-input v-model:value="id" />
|
||||
</n-form-item>
|
||||
<n-form-item :label="$t('common.field') + ':' + $t('common.value')" required>
|
||||
<n-dynamic-input
|
||||
|
|
|
@ -9,7 +9,6 @@ const emit = defineEmits(['update:value'])
|
|||
<template>
|
||||
<n-form-item :label="$t('common.value')">
|
||||
<n-input
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:rows="6"
|
||||
:value="props.value"
|
||||
placeholder=""
|
||||
|
|
|
@ -46,7 +46,6 @@ defineExpose({
|
|||
<template #default="{ value }">
|
||||
<n-input
|
||||
v-model:value="value.value"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('dialogue.field.enter_member')"
|
||||
type="text"
|
||||
@update:value="onUpdate" />
|
||||
|
|
|
@ -166,7 +166,7 @@ const handleSelectDB = async (db) => {
|
|||
await browserStore.openDatabase(props.server, db)
|
||||
await nextTick()
|
||||
await connectionStore.saveLastDB(props.server, db)
|
||||
tabStore.upsertTab({ server: props.server, db })
|
||||
tabStore.upsertTab({ server: props.server, db, clearValue: true })
|
||||
// browserTreeRef.value?.resetExpandKey(props.server, db)
|
||||
fullyLoaded.value = await browserStore.loadMoreKeys(props.server, db)
|
||||
browserTreeRef.value?.refreshTree()
|
||||
|
@ -290,7 +290,6 @@ onMounted(() => onReload())
|
|||
<n-select
|
||||
:consistent-menu-width="false"
|
||||
:filter="(pattern, option) => option.value.toString() === pattern"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:options="dbSelectOptions"
|
||||
:value="props.db"
|
||||
filterable
|
||||
|
|
|
@ -288,6 +288,7 @@ const onUpdateSelectedKeys = (keys, options) => {
|
|||
server: props.server,
|
||||
db,
|
||||
key: redisKey,
|
||||
clearValue: true,
|
||||
})
|
||||
}
|
||||
return
|
||||
|
|
|
@ -33,11 +33,7 @@ const filterPattern = ref('')
|
|||
stroke-width="4"
|
||||
t-tooltip="interface.new_group"
|
||||
@click="dialogStore.openNewGroupDialog()" />
|
||||
<n-input
|
||||
v-model:value="filterPattern"
|
||||
:input-props="{ spellcheck: 'false' }"
|
||||
:placeholder="$t('interface.filter')"
|
||||
clearable>
|
||||
<n-input v-model:value="filterPattern" :placeholder="$t('interface.filter')" clearable>
|
||||
<template #prefix>
|
||||
<n-icon :component="Filter" size="20" />
|
||||
</template>
|
||||
|
|
|
@ -413,9 +413,10 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {string} server
|
||||
* @param {number} db
|
||||
* @param {string|number[]} [key] null or blank indicate that update tab to display normal content (blank content or server status)
|
||||
* @param {boolean} [clearValue]
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async loadKeySummary({ server, db, key }) {
|
||||
async loadKeySummary({ server, db, key, clearValue }) {
|
||||
try {
|
||||
const tab = useTabStore()
|
||||
if (!isEmpty(key)) {
|
||||
|
@ -438,6 +439,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
key: k,
|
||||
size,
|
||||
length,
|
||||
clearValue,
|
||||
})
|
||||
return
|
||||
} else {
|
||||
|
@ -458,9 +460,9 @@ const useBrowserStore = defineStore('browser', {
|
|||
ttl: -1,
|
||||
key: null,
|
||||
keyCode: null,
|
||||
value: null,
|
||||
size: 0,
|
||||
length: 0,
|
||||
clearValue,
|
||||
})
|
||||
} catch (e) {
|
||||
$message.error('')
|
||||
|
@ -511,7 +513,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
const tab = useTabStore()
|
||||
try {
|
||||
tab.updateLoading({ server, db, loading: true })
|
||||
await this.loadKeySummary({ server, db, key })
|
||||
await this.loadKeySummary({ server, db, key, clearValue: true })
|
||||
await this.loadKeyDetail({ server, db, key, decode, format, matchPattern, reset: true })
|
||||
} finally {
|
||||
tab.updateLoading({ server, db, loading: false })
|
||||
|
@ -1065,6 +1067,8 @@ const useBrowserStore = defineStore('browser', {
|
|||
}
|
||||
const tab = useTabStore()
|
||||
tab.updateValue({ server, db, key, value })
|
||||
|
||||
this.loadKeySummary({ server, db, key })
|
||||
return {
|
||||
success,
|
||||
nodeKey: `${server}/db${db}#${ConnectionType.RedisValue}/${key}`,
|
||||
|
@ -1096,6 +1100,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {formatTypes} [retFormat]
|
||||
* @param {boolean} [refresh]
|
||||
* @param {number} [index] index for retrieve affect entries quickly
|
||||
* @param {boolean} [reload]
|
||||
* @returns {Promise<{[msg]: string, success: boolean, [updated]: {}}>}
|
||||
*/
|
||||
async setHash({
|
||||
|
@ -1110,6 +1115,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
retDecode,
|
||||
retFormat,
|
||||
index,
|
||||
reload,
|
||||
}) {
|
||||
try {
|
||||
const { data, success, msg } = await SetHashValue({
|
||||
|
@ -1150,6 +1156,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
index: [index],
|
||||
})
|
||||
}
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
return { success, updated }
|
||||
} else {
|
||||
return { success, msg }
|
||||
|
@ -1166,9 +1178,10 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {string|number[]} key
|
||||
* @param {number }action 0:ignore duplicated fields 1:overwrite duplicated fields
|
||||
* @param {string[]} fieldItems field1, value1, filed2, value2...
|
||||
* @param {boolean} [reload]
|
||||
* @returns {Promise<{[msg]: string, success: boolean, [updated]: [], [added]: []}>}
|
||||
*/
|
||||
async addHashField(server, db, key, action, fieldItems) {
|
||||
async addHashField({ server, db, key, action, fieldItems, reload }) {
|
||||
try {
|
||||
const { data, success, msg } = await AddHashField(server, db, key, action, fieldItems)
|
||||
if (success) {
|
||||
|
@ -1180,6 +1193,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
if (!isEmpty(added)) {
|
||||
tab.insertValueEntries({ server, db, key, type: 'hash', entries: added })
|
||||
}
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
return { success, updated, added }
|
||||
} else {
|
||||
return { success: false, msg }
|
||||
|
@ -1195,9 +1214,10 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {number} db
|
||||
* @param {string|number[]} key
|
||||
* @param {string} field
|
||||
* @param {boolean} reload
|
||||
* @returns {Promise<{[msg]: {}, success: boolean, [removed]: string[]}>}
|
||||
*/
|
||||
async removeHashField(server, db, key, field) {
|
||||
async removeHashField({ server, db, key, field, reload }) {
|
||||
try {
|
||||
const { data, success, msg } = await SetHashValue({ server, db, key, field, newField: '' })
|
||||
if (success) {
|
||||
|
@ -1206,6 +1226,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
// const tab = useTabStore()
|
||||
// tab.removeValueEntries({ server, db, key, type: 'hash', entries: removed })
|
||||
// }
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
return { success, removed }
|
||||
} else {
|
||||
return { success, msg }
|
||||
|
@ -1215,32 +1241,16 @@ const useBrowserStore = defineStore('browser', {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* insert list item
|
||||
* @param {string} connName
|
||||
* @param {number} db
|
||||
* @param {string|number[]} key
|
||||
* @param {int} action 0: push to head, 1: push to tail
|
||||
* @param {string[]}values
|
||||
* @returns {Promise<*|{msg, success: boolean}>}
|
||||
*/
|
||||
async addListItem(connName, db, key, action, values) {
|
||||
try {
|
||||
return AddListItem(connName, db, key, action, values)
|
||||
} catch (e) {
|
||||
return { success: false, msg: e.message }
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* prepend item to head of list
|
||||
* @param {string} server
|
||||
* @param {number} db
|
||||
* @param {string|number[]} key
|
||||
* @param {string[]} values
|
||||
* @param {boolean} reload
|
||||
* @returns {Promise<{[msg]: string, success: boolean, [item]: []}>}
|
||||
*/
|
||||
async prependListItem({ server, db, key, values }) {
|
||||
async prependListItem({ server, db, key, values, reload }) {
|
||||
try {
|
||||
const { data, success, msg } = await AddListItem(server, db, key, 0, values)
|
||||
if (success) {
|
||||
|
@ -1255,6 +1265,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
entries: left,
|
||||
prepend: true,
|
||||
})
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
}
|
||||
return { success, item: left }
|
||||
} else {
|
||||
|
@ -1271,9 +1287,10 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {number} db
|
||||
* @param {string|number[]} key
|
||||
* @param {string[]} values
|
||||
* @param {boolean} [reload]
|
||||
* @returns {Promise<{[msg]: string, success: boolean, [item]: any[]}>}
|
||||
*/
|
||||
async appendListItem({ server, db, key, values }) {
|
||||
async appendListItem({ server, db, key, values, reload }) {
|
||||
try {
|
||||
const { data, success, msg } = await AddListItem(server, db, key, 1, values)
|
||||
if (success) {
|
||||
|
@ -1289,6 +1306,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
entries: right,
|
||||
prepend: false,
|
||||
})
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
}
|
||||
return { success, item: right }
|
||||
} else {
|
||||
|
@ -1310,6 +1333,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {formatTypes} format
|
||||
* @param {decodeTypes} [retDecode]
|
||||
* @param {formatTypes} [retFormat]
|
||||
* @param {boolean} [reload]
|
||||
* @returns {Promise<{[msg]: string, success: boolean}>}
|
||||
*/
|
||||
async updateListItem({
|
||||
|
@ -1322,6 +1346,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
format = formatTypes.RAW,
|
||||
retDecode,
|
||||
retFormat,
|
||||
reload,
|
||||
}) {
|
||||
try {
|
||||
const { data, success, msg } = await SetListItem({
|
||||
|
@ -1358,6 +1383,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
entries: removedIndex,
|
||||
})
|
||||
}
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
return { success }
|
||||
} else {
|
||||
return { success, msg }
|
||||
|
@ -1373,9 +1404,10 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {number} db
|
||||
* @param {string|number[]} key
|
||||
* @param {number} index
|
||||
* @param {boolean} [reload]
|
||||
* @returns {Promise<{[msg]: string, success: boolean, [removed]: string[]}>}
|
||||
*/
|
||||
async removeListItem(server, db, key, index) {
|
||||
async removeListItem({ server, db, key, index, reload }) {
|
||||
try {
|
||||
const { data, success, msg } = await SetListItem({ server, db, key, index })
|
||||
if (success) {
|
||||
|
@ -1390,6 +1422,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
type: 'list',
|
||||
entries: removedIndexes,
|
||||
})
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
}
|
||||
return { success, removed }
|
||||
} else {
|
||||
|
@ -1406,9 +1444,10 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {number} db
|
||||
* @param {string|number} key
|
||||
* @param {string|string[]} value
|
||||
* @param {boolean} [reload]
|
||||
* @returns {Promise<{[msg]: string, success: boolean}>}
|
||||
*/
|
||||
async addSetItem(server, db, key, value) {
|
||||
async addSetItem({ server, db, key, value, reload }) {
|
||||
try {
|
||||
if ((!value) instanceof Array) {
|
||||
value = [value]
|
||||
|
@ -1420,6 +1459,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
const tab = useTabStore()
|
||||
tab.insertValueEntries({ server, db, key, type: 'set', entries: added })
|
||||
}
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
return { success }
|
||||
} else {
|
||||
return { success, msg }
|
||||
|
@ -1440,6 +1485,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {formatTypes} [format]
|
||||
* @param {decodeTypes} [retDecode]
|
||||
* @param {formatTypes} [retFormat]
|
||||
* @param {boolean} [reload]
|
||||
* @returns {Promise<{[msg]: string, success: boolean}>}
|
||||
*/
|
||||
async updateSetItem({
|
||||
|
@ -1452,6 +1498,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
format = formatTypes.RAW,
|
||||
retDecode,
|
||||
retFormat,
|
||||
reload,
|
||||
}) {
|
||||
try {
|
||||
const { data, success, msg } = await UpdateSetItem({
|
||||
|
@ -1475,6 +1522,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
if (!isEmpty(added)) {
|
||||
tab.insertValueEntries({ server, db, key, type: 'set', entries: added })
|
||||
}
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
return { success }
|
||||
} else {
|
||||
return { success: false, msg }
|
||||
|
@ -1490,9 +1543,10 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {number} db
|
||||
* @param {string|number[]} key
|
||||
* @param {string} value
|
||||
* @param {boolean} [reload]
|
||||
* @returns {Promise<{[msg]: string, success: boolean}>}
|
||||
*/
|
||||
async removeSetItem(server, db, key, value) {
|
||||
async removeSetItem({ server, db, key, value, reload }) {
|
||||
try {
|
||||
const { data, success, msg } = await SetSetItem(server, db, key, true, [value])
|
||||
if (success) {
|
||||
|
@ -1502,6 +1556,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
const removedValues = map(removed, 'v')
|
||||
tab.removeValueEntries({ server, db, key, type: 'set', entries: removedValues })
|
||||
}
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
return { success }
|
||||
} else {
|
||||
return { success, msg }
|
||||
|
@ -1518,9 +1578,10 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {string|number[]} key
|
||||
* @param {number} action
|
||||
* @param {Object.<string, number>} vs value: score
|
||||
* @param {boolean} [reload]
|
||||
* @returns {Promise<{[msg]: string, success: boolean}>}
|
||||
*/
|
||||
async addZSetItem(server, db, key, action, vs) {
|
||||
async addZSetItem({ server, db, key, action, vs, reload }) {
|
||||
try {
|
||||
const { data, success, msg } = await AddZSetValue(server, db, key, action, vs)
|
||||
if (success) {
|
||||
|
@ -1532,6 +1593,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
if (!isEmpty(updated)) {
|
||||
tab.updateValueEntries({ server, db, key, type: 'zset', entries: updated })
|
||||
}
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
return { success }
|
||||
} else {
|
||||
return { success, msg }
|
||||
|
@ -1554,6 +1621,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {decodeTypes} [retDecode]
|
||||
* @param {formatTypes} [retFormat]
|
||||
* @param {number} [index] index for retrieve affect entries quickly
|
||||
* @param {boolean} [reload]
|
||||
* @returns {Promise<{[msg]: string, success: boolean}>}
|
||||
*/
|
||||
async updateZSetItem({
|
||||
|
@ -1568,6 +1636,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
retDecode,
|
||||
retFormat,
|
||||
index,
|
||||
reload,
|
||||
}) {
|
||||
try {
|
||||
const { data, success, msg } = await UpdateZSetValue({
|
||||
|
@ -1598,6 +1667,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
if (!isEmpty(replaced)) {
|
||||
tab.replaceValueEntries({ server, db, key, type: 'zset', entries: replaced, index: [index] })
|
||||
}
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
return { success, updated, removed }
|
||||
} else {
|
||||
return { success, msg }
|
||||
|
@ -1613,9 +1688,10 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {number} db
|
||||
* @param {string|number[]} key
|
||||
* @param {string} value
|
||||
* @param {boolean} [reload]
|
||||
* @returns {Promise<{[msg]: string, success: boolean, [removed]: []}>}
|
||||
*/
|
||||
async removeZSetItem(server, db, key, value) {
|
||||
async removeZSetItem({ server, db, key, value, reload }) {
|
||||
try {
|
||||
const { data, success, msg } = await UpdateZSetValue({ server, db, key, value, newValue: '', score: 0 })
|
||||
if (success) {
|
||||
|
@ -1625,6 +1701,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
const removeValues = map(removed, 'v')
|
||||
tab.removeValueEntries({ server, db, key, type: 'zset', entries: removeValues })
|
||||
}
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
return { success, removed }
|
||||
} else {
|
||||
return { success, msg }
|
||||
|
@ -1641,9 +1723,10 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {string|number[]} key
|
||||
* @param {string} id
|
||||
* @param {string[]} values field1, value1, filed2, value2...
|
||||
* @param {boolean} [reload]
|
||||
* @returns {Promise<{[msg]: string, success: boolean}>}
|
||||
*/
|
||||
async addStreamValue(server, db, key, id, values) {
|
||||
async addStreamValue({ server, db, key, id, values, reload }) {
|
||||
try {
|
||||
const { data = {}, success, msg } = await AddStreamValue(server, db, key, id, values)
|
||||
if (success) {
|
||||
|
@ -1657,6 +1740,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
type: 'stream',
|
||||
entries: added,
|
||||
})
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
}
|
||||
return { success }
|
||||
} else {
|
||||
|
@ -1669,21 +1758,28 @@ const useBrowserStore = defineStore('browser', {
|
|||
|
||||
/**
|
||||
* remove stream field
|
||||
* @param {string} connName
|
||||
* @param {string} server
|
||||
* @param {number} db
|
||||
* @param {string|number[]} key
|
||||
* @param {string[]|string} ids
|
||||
* @param {boolean} [reload]
|
||||
* @returns {Promise<{[msg]: {}, success: boolean}>}
|
||||
*/
|
||||
async removeStreamValues(connName, db, key, ids) {
|
||||
async removeStreamValues({ server, db, key, ids, reload }) {
|
||||
if (typeof ids === 'string') {
|
||||
ids = [ids]
|
||||
}
|
||||
try {
|
||||
const { data = {}, success, msg } = await RemoveStreamValues(connName, db, key, ids)
|
||||
const { data = {}, success, msg } = await RemoveStreamValues(server, db, key, ids)
|
||||
if (success) {
|
||||
const tab = useTabStore()
|
||||
tab.removeValueEntries({ server: connName, db, key, type: 'stream', entries: ids })
|
||||
tab.removeValueEntries({ server, db, key, type: 'stream', entries: ids })
|
||||
if (reload === true) {
|
||||
this.reloadKey({ server, db, key })
|
||||
} else {
|
||||
// reload summary only
|
||||
this.loadKeySummary({ server, db, key })
|
||||
}
|
||||
return { success }
|
||||
} else {
|
||||
return { success, msg }
|
||||
|
|
|
@ -162,7 +162,7 @@ const useTabStore = defineStore('tab', {
|
|||
},
|
||||
|
||||
openBlank(server) {
|
||||
this.upsertTab({ server })
|
||||
this.upsertTab({ server, clearValue: true })
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -177,9 +177,10 @@ const useTabStore = defineStore('tab', {
|
|||
* @param {number} [size]
|
||||
* @param {number} [length]
|
||||
* @param {string} [matchPattern]
|
||||
* @param {boolean} [clearValue]
|
||||
* @param {*} [value]
|
||||
*/
|
||||
upsertTab({ subTab, server, db, type, ttl, key, keyCode, size, length, matchPattern = '' }) {
|
||||
upsertTab({ subTab, server, db, type, ttl, key, keyCode, size, length, matchPattern = '', clearValue }) {
|
||||
let tabIndex = findIndex(this.tabList, { name: server })
|
||||
if (tabIndex === -1) {
|
||||
this.tabList.push({
|
||||
|
@ -213,7 +214,9 @@ const useTabStore = defineStore('tab', {
|
|||
tab.size = size
|
||||
tab.length = length
|
||||
tab.matchPattern = matchPattern
|
||||
tab.value = undefined
|
||||
if (clearValue === true) {
|
||||
tab.value = undefined
|
||||
}
|
||||
}
|
||||
this._setActivatedIndex(tabIndex, true, subTab)
|
||||
// this.activatedTab = tab.name
|
||||
|
@ -224,14 +227,16 @@ const useTabStore = defineStore('tab', {
|
|||
* @param {string} server
|
||||
* @param {number} db
|
||||
* @param {string} key
|
||||
* @param {*} value
|
||||
* @param {*} [value]
|
||||
* @param {string} [format]
|
||||
* @param {string] [decode]
|
||||
* @param {string} [matchPattern]
|
||||
* @param {boolean} [reset]
|
||||
* @param {boolean} [end] keep end status if not set
|
||||
* @param {number} [size]
|
||||
* @param {number} [length]
|
||||
*/
|
||||
updateValue({ server, db, key, value, format, decode, matchPattern, reset, end }) {
|
||||
updateValue({ server, db, key, value, format, decode, matchPattern, reset, end, size = -1, length = -1 }) {
|
||||
const tabData = find(this.tabList, { name: server, db, key })
|
||||
if (tabData == null) {
|
||||
return
|
||||
|
@ -240,6 +245,12 @@ const useTabStore = defineStore('tab', {
|
|||
tabData.format = format || tabData.format
|
||||
tabData.decode = decode || tabData.decode
|
||||
tabData.matchPattern = matchPattern || ''
|
||||
if (size >= 0) {
|
||||
tabData.size = size
|
||||
}
|
||||
if (length >= 0) {
|
||||
tabData.length = length
|
||||
}
|
||||
if (typeof end === 'boolean') {
|
||||
tabData.end = end
|
||||
}
|
||||
|
|
|
@ -15,3 +15,9 @@
|
|||
|
||||
.tab-content {
|
||||
}
|
||||
|
||||
:deep(.cmd-line) {
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
|
7
main.go
7
main.go
|
@ -73,9 +73,14 @@ func main() {
|
|||
services.GA().Startup(version)
|
||||
},
|
||||
OnDomReady: func(ctx context.Context) {
|
||||
runtime2.WindowShow(ctx)
|
||||
x, y := prefSvc.GetWindowPosition(ctx)
|
||||
runtime2.WindowSetPosition(ctx, x, y)
|
||||
runtime2.WindowShow(ctx)
|
||||
},
|
||||
OnBeforeClose: func(ctx context.Context) (prevent bool) {
|
||||
x, y := runtime2.WindowGetPosition(ctx)
|
||||
prefSvc.SaveWindowPosition(x, y)
|
||||
return false
|
||||
},
|
||||
OnShutdown: func(ctx context.Context) {
|
||||
browserSvc.Stop()
|
||||
|
|
Loading…
Reference in New Issue