Compare commits
No commits in common. "7f2fac7fe8d4b0ac77c4d02aac119f8a40035445" and "23087a53745ae2b9d54afdc01326b02f3e913f88" have entirely different histories.
7f2fac7fe8
...
23087a5374
|
@ -483,8 +483,8 @@ func (b *browserService) scanKeys(ctx context.Context, client redis.UniversalCli
|
|||
}
|
||||
|
||||
// LoadNextKeys load next key from saved cursor
|
||||
func (b *browserService) LoadNextKeys(server string, db int, match, keyType string) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(server, db)
|
||||
func (b *browserService) LoadNextKeys(connName string, db int, match, keyType string) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(connName, db)
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
@ -497,7 +497,7 @@ func (b *browserService) LoadNextKeys(server string, db int, match, keyType stri
|
|||
resp.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
b.setClientCursor(server, db, cursor)
|
||||
b.setClientCursor(connName, db, cursor)
|
||||
maxKeys := b.loadDBSize(ctx, client)
|
||||
|
||||
resp.Success = true
|
||||
|
@ -510,8 +510,8 @@ func (b *browserService) LoadNextKeys(server string, db int, match, keyType stri
|
|||
}
|
||||
|
||||
// LoadNextAllKeys load next all keys
|
||||
func (b *browserService) LoadNextAllKeys(server string, db int, match, keyType string) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(server, db)
|
||||
func (b *browserService) LoadNextAllKeys(connName string, db int, match, keyType string) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(connName, db)
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
@ -524,7 +524,7 @@ func (b *browserService) LoadNextAllKeys(server string, db int, match, keyType s
|
|||
resp.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
b.setClientCursor(server, db, 0)
|
||||
b.setClientCursor(connName, db, 0)
|
||||
maxKeys := b.loadDBSize(ctx, client)
|
||||
|
||||
resp.Success = true
|
||||
|
@ -536,8 +536,8 @@ func (b *browserService) LoadNextAllKeys(server string, db int, match, keyType s
|
|||
}
|
||||
|
||||
// LoadAllKeys load all keys
|
||||
func (b *browserService) LoadAllKeys(server string, db int, match, keyType string) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(server, db)
|
||||
func (b *browserService) LoadAllKeys(connName string, db int, match, keyType string) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(connName, db)
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
@ -1320,8 +1320,8 @@ func (b *browserService) SetHashValue(param types.SetHashParam) (resp types.JSRe
|
|||
}
|
||||
|
||||
// AddHashField add or update hash field
|
||||
func (b *browserService) AddHashField(server string, db int, k any, action int, fieldItems []any) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(server, db)
|
||||
func (b *browserService) AddHashField(connName string, db int, k any, action int, fieldItems []any) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(connName, db)
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
@ -1383,8 +1383,8 @@ func (b *browserService) AddHashField(server string, db int, k any, action int,
|
|||
}
|
||||
|
||||
// AddListItem add item to list or remove from it
|
||||
func (b *browserService) AddListItem(server string, db int, k any, action int, items []any) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(server, db)
|
||||
func (b *browserService) AddListItem(connName string, db int, k any, action int, items []any) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(connName, db)
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
@ -1699,8 +1699,8 @@ func (b *browserService) UpdateZSetValue(param types.SetZSetParam) (resp types.J
|
|||
}
|
||||
|
||||
// AddZSetValue add item to sorted set
|
||||
func (b *browserService) AddZSetValue(server string, db int, k any, action int, valueScore map[string]float64) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(server, db)
|
||||
func (b *browserService) AddZSetValue(connName string, db int, k any, action int, valueScore map[string]float64) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(connName, db)
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
@ -1757,8 +1757,8 @@ func (b *browserService) AddZSetValue(server string, db int, k any, action int,
|
|||
}
|
||||
|
||||
// AddStreamValue add stream field
|
||||
func (b *browserService) AddStreamValue(server string, db int, k any, ID string, fieldItems []any) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(server, db)
|
||||
func (b *browserService) AddStreamValue(connName string, db int, k any, ID string, fieldItems []any) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(connName, db)
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
@ -1800,8 +1800,8 @@ func (b *browserService) AddStreamValue(server string, db int, k any, ID string,
|
|||
}
|
||||
|
||||
// RemoveStreamValues remove stream values by id
|
||||
func (b *browserService) RemoveStreamValues(server string, db int, k any, IDs []string) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(server, db)
|
||||
func (b *browserService) RemoveStreamValues(connName string, db int, k any, IDs []string) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(connName, db)
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
@ -1827,8 +1827,8 @@ func (b *browserService) RemoveStreamValues(server string, db int, k any, IDs []
|
|||
}
|
||||
|
||||
// SetKeyTTL set ttl of key
|
||||
func (b *browserService) SetKeyTTL(server string, db int, k any, ttl int64) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(server, db)
|
||||
func (b *browserService) SetKeyTTL(connName string, db int, k any, ttl int64) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(connName, db)
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
@ -1836,13 +1836,14 @@ func (b *browserService) SetKeyTTL(server string, db int, k any, ttl int64) (res
|
|||
|
||||
client, ctx := item.client, item.ctx
|
||||
key := strutil.DecodeRedisKey(k)
|
||||
var expiration time.Duration
|
||||
if ttl < 0 {
|
||||
if err = client.Persist(ctx, key).Err(); err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
} else {
|
||||
expiration := time.Duration(ttl) * time.Second
|
||||
expiration = time.Duration(ttl) * time.Second
|
||||
if err = client.Expire(ctx, key, expiration).Err(); err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
@ -1853,95 +1854,6 @@ func (b *browserService) SetKeyTTL(server string, db int, k any, ttl int64) (res
|
|||
return
|
||||
}
|
||||
|
||||
// BatchSetTTL batch set ttl
|
||||
func (b *browserService) BatchSetTTL(server string, db int, ks []any, ttl int64, serialNo string) (resp types.JSResp) {
|
||||
conf := Connection().getConnection(server)
|
||||
if conf == nil {
|
||||
resp.Msg = fmt.Sprintf("no connection profile named: %s", server)
|
||||
return
|
||||
}
|
||||
var client redis.UniversalClient
|
||||
var err error
|
||||
var connConfig = conf.ConnectionConfig
|
||||
connConfig.LastDB = db
|
||||
if client, err = b.createRedisClient(connConfig); err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
ctx, cancelFunc := context.WithCancel(b.ctx)
|
||||
defer client.Close()
|
||||
defer cancelFunc()
|
||||
|
||||
//cancelEvent := "ttling:stop:" + serialNo
|
||||
//runtime.EventsOnce(ctx, cancelEvent, func(data ...any) {
|
||||
// cancelFunc()
|
||||
//})
|
||||
//processEvent := "ttling:" + serialNo
|
||||
total := len(ks)
|
||||
var failed, updated atomic.Int64
|
||||
var canceled bool
|
||||
|
||||
expiration := time.Now().Add(time.Duration(ttl) * time.Second)
|
||||
del := func(ctx context.Context, cli redis.UniversalClient) error {
|
||||
startTime := time.Now().Add(-10 * time.Second)
|
||||
for i, k := range ks {
|
||||
// emit progress per second
|
||||
//param := map[string]any{
|
||||
// "total": total,
|
||||
// "progress": i + 1,
|
||||
// "processing": k,
|
||||
//}
|
||||
if i >= total-1 || time.Now().Sub(startTime).Milliseconds() > 100 {
|
||||
startTime = time.Now()
|
||||
//runtime.EventsEmit(b.ctx, processEvent, param)
|
||||
// do some sleep to prevent blocking the Redis server
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
}
|
||||
|
||||
key := strutil.DecodeRedisKey(k)
|
||||
var expErr error
|
||||
if ttl < 0 {
|
||||
expErr = cli.Persist(ctx, key).Err()
|
||||
} else {
|
||||
expErr = cli.ExpireAt(ctx, key, expiration).Err()
|
||||
}
|
||||
if err != nil {
|
||||
failed.Add(1)
|
||||
} else {
|
||||
// save deleted key
|
||||
updated.Add(1)
|
||||
}
|
||||
if errors.Is(expErr, context.Canceled) || canceled {
|
||||
canceled = true
|
||||
break
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if cluster, ok := client.(*redis.ClusterClient); ok {
|
||||
// cluster mode
|
||||
err = cluster.ForEachMaster(ctx, func(ctx context.Context, cli *redis.Client) error {
|
||||
return del(ctx, cli)
|
||||
})
|
||||
} else {
|
||||
err = del(ctx, client)
|
||||
}
|
||||
|
||||
//runtime.EventsOff(ctx, cancelEvent)
|
||||
resp.Success = true
|
||||
resp.Data = struct {
|
||||
Canceled bool `json:"canceled"`
|
||||
Updated int64 `json:"updated"`
|
||||
Failed int64 `json:"failed"`
|
||||
}{
|
||||
Canceled: canceled,
|
||||
Updated: updated.Load(),
|
||||
Failed: failed.Load(),
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteKey remove redis key
|
||||
func (b *browserService) DeleteKey(server string, db int, k any, async bool) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(server, db)
|
||||
|
@ -2095,13 +2007,13 @@ func (b *browserService) DeleteKeys(server string, db int, ks []any, serialNo st
|
|||
startTime := time.Now().Add(-10 * time.Second)
|
||||
for i, k := range ks {
|
||||
// emit progress per second
|
||||
param := map[string]any{
|
||||
"total": total,
|
||||
"progress": i + 1,
|
||||
"processing": k,
|
||||
}
|
||||
if i >= total-1 || time.Now().Sub(startTime).Milliseconds() > 100 {
|
||||
startTime = time.Now()
|
||||
param := map[string]any{
|
||||
"total": total,
|
||||
"progress": i + 1,
|
||||
"processing": k,
|
||||
}
|
||||
runtime.EventsEmit(b.ctx, processEvent, param)
|
||||
// do some sleep to prevent blocking the Redis server
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
|
@ -2234,7 +2146,7 @@ func (b *browserService) ExportKey(server string, db int, ks []any, path string,
|
|||
}
|
||||
|
||||
// ImportCSV import data from csv file
|
||||
func (b *browserService) ImportCSV(server string, db int, path string, conflict int, ttl int64) (resp types.JSResp) {
|
||||
func (b *browserService) ImportCSV(server string, db int, path string, conflict int, includeExpire bool) (resp types.JSResp) {
|
||||
// connect a new connection to export keys
|
||||
conf := Connection().getConnection(server)
|
||||
if conf == nil {
|
||||
|
@ -2270,14 +2182,14 @@ func (b *browserService) ImportCSV(server string, db int, path string, conflict
|
|||
var line []string
|
||||
var readErr error
|
||||
var key, value []byte
|
||||
var ttlValue time.Duration
|
||||
var ttl time.Duration
|
||||
var imported, ignored int64
|
||||
var canceled bool
|
||||
startTime := time.Now().Add(-10 * time.Second)
|
||||
for {
|
||||
readErr = nil
|
||||
|
||||
ttlValue = redis.KeepTTL
|
||||
ttl = redis.KeepTTL
|
||||
line, readErr = reader.Read()
|
||||
if readErr != nil {
|
||||
break
|
||||
|
@ -2293,25 +2205,21 @@ func (b *browserService) ImportCSV(server string, db int, path string, conflict
|
|||
continue
|
||||
}
|
||||
// get ttl
|
||||
if ttl < 0 {
|
||||
// use previous
|
||||
if includeExpire && len(line) > 2 {
|
||||
if expire, ttlErr := strconv.ParseInt(line[2], 10, 64); ttlErr == nil && expire > 0 {
|
||||
ttlValue = time.UnixMilli(expire).Sub(time.Now())
|
||||
ttl = time.UnixMilli(expire).Sub(time.Now())
|
||||
}
|
||||
} else if ttl > 0 {
|
||||
// custom ttl
|
||||
ttlValue = time.Duration(ttl) * time.Second
|
||||
}
|
||||
if conflict == 0 {
|
||||
readErr = client.RestoreReplace(ctx, string(key), ttlValue, string(value)).Err()
|
||||
readErr = client.RestoreReplace(ctx, string(key), ttl, string(value)).Err()
|
||||
} else {
|
||||
keyStr := string(key)
|
||||
// go-redis may crash when batch calling restore
|
||||
// use "exists" to filter first
|
||||
if n, _ := client.Exists(ctx, keyStr).Result(); n <= 0 {
|
||||
readErr = client.Restore(ctx, keyStr, ttlValue, string(value)).Err()
|
||||
readErr = client.Restore(ctx, keyStr, ttl, string(value)).Err()
|
||||
} else {
|
||||
readErr = errors.New("key already existed")
|
||||
readErr = errors.New("key existed")
|
||||
}
|
||||
}
|
||||
if readErr != nil {
|
||||
|
@ -2353,8 +2261,8 @@ func (b *browserService) ImportCSV(server string, db int, path string, conflict
|
|||
}
|
||||
|
||||
// FlushDB flush database
|
||||
func (b *browserService) FlushDB(server string, db int, async bool) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(server, db)
|
||||
func (b *browserService) FlushDB(connName string, db int, async bool) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(connName, db)
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
@ -2401,8 +2309,8 @@ func (b *browserService) FlushDB(server string, db int, async bool) (resp types.
|
|||
}
|
||||
|
||||
// RenameKey rename key
|
||||
func (b *browserService) RenameKey(server string, db int, key, newKey string) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(server, db)
|
||||
func (b *browserService) RenameKey(connName string, db int, key, newKey string) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(connName, db)
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
@ -2454,8 +2362,8 @@ func (b *browserService) CleanCmdHistory() (resp types.JSResp) {
|
|||
}
|
||||
|
||||
// GetSlowLogs get slow log list
|
||||
func (b *browserService) GetSlowLogs(server string, db int, num int64) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(server, db)
|
||||
func (b *browserService) GetSlowLogs(connName string, db int, num int64) (resp types.JSResp) {
|
||||
item, err := b.getRedisClient(connName, db)
|
||||
if err != nil {
|
||||
resp.Msg = err.Error()
|
||||
return
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
type monitorItem struct {
|
||||
client *redis.Client
|
||||
cmd *redis.MonitorCmd
|
||||
mutex sync.Mutex
|
||||
ch chan string
|
||||
closeCh chan struct{}
|
||||
eventName string
|
||||
|
@ -89,7 +88,7 @@ func (c *monitorService) StartMonitor(server string) (resp types.JSResp) {
|
|||
item.cmd = item.client.Monitor(c.ctx, item.ch)
|
||||
item.cmd.Start()
|
||||
|
||||
go c.processMonitor(&item.mutex, item.ch, item.closeCh, item.eventName)
|
||||
go c.processMonitor(item.ch, item.closeCh, item.eventName)
|
||||
resp.Success = true
|
||||
resp.Data = struct {
|
||||
EventName string `json:"eventName"`
|
||||
|
@ -99,23 +98,12 @@ func (c *monitorService) StartMonitor(server string) (resp types.JSResp) {
|
|||
return
|
||||
}
|
||||
|
||||
func (c *monitorService) processMonitor(mutex *sync.Mutex, ch <-chan string, closeCh <-chan struct{}, eventName string) {
|
||||
lastEmitTime := time.Now().Add(-1 * time.Minute)
|
||||
cache := make([]string, 0, 1000)
|
||||
func (c *monitorService) processMonitor(ch <-chan string, closeCh <-chan struct{}, eventName string) {
|
||||
for {
|
||||
select {
|
||||
case data := <-ch:
|
||||
if data != "OK" {
|
||||
go func() {
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
cache = append(cache, data)
|
||||
if time.Now().Sub(lastEmitTime) > 1*time.Second || len(cache) > 300 {
|
||||
runtime.EventsEmit(c.ctx, eventName, cache)
|
||||
cache = cache[:0:cap(cache)]
|
||||
lastEmitTime = time.Now()
|
||||
}
|
||||
}()
|
||||
runtime.EventsEmit(c.ctx, eventName, data)
|
||||
}
|
||||
|
||||
case <-closeCh:
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
value: {
|
||||
type: Number,
|
||||
default: -1,
|
||||
},
|
||||
unit: {
|
||||
type: Number,
|
||||
default: 1,
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:value', 'update:unit'])
|
||||
|
||||
const i18n = useI18n()
|
||||
const unit = computed(() => [
|
||||
{ value: 1, label: i18n.t('common.second') },
|
||||
{
|
||||
value: 60,
|
||||
label: i18n.t('common.minute'),
|
||||
},
|
||||
{
|
||||
value: 3600,
|
||||
label: i18n.t('common.hour'),
|
||||
},
|
||||
{
|
||||
value: 86400,
|
||||
label: i18n.t('common.day'),
|
||||
},
|
||||
])
|
||||
|
||||
const unitValue = computed(() => {
|
||||
switch (props.unit) {
|
||||
case 60:
|
||||
return 60
|
||||
case 3600:
|
||||
return 3600
|
||||
case 86400:
|
||||
return 86400
|
||||
default:
|
||||
return 1
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<n-input-group>
|
||||
<n-input-number
|
||||
:max="Number.MAX_SAFE_INTEGER"
|
||||
:min="-1"
|
||||
:show-button="false"
|
||||
:value="props.value"
|
||||
class="flex-item-expand"
|
||||
@update:value="(val) => emit('update:value', val)" />
|
||||
<n-select
|
||||
:options="unit"
|
||||
:value="unitValue"
|
||||
style="max-width: 150px"
|
||||
@update:value="(val) => emit('update:unit', val)" />
|
||||
</n-input-group>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped></style>
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import { computed, nextTick, onMounted, onUnmounted, reactive, ref } from 'vue'
|
||||
import { debounce, filter, get, includes, isEmpty, join } from 'lodash'
|
||||
import { filter, get, includes, isEmpty, join } from 'lodash'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useThemeVars } from 'naive-ui'
|
||||
import useBrowserStore from 'stores/browser.js'
|
||||
|
@ -53,13 +53,6 @@ const displayList = computed(() => {
|
|||
return data.list
|
||||
})
|
||||
|
||||
const _scrollToBottom = () => {
|
||||
nextTick(() => {
|
||||
listRef.value?.scrollTo({ position: 'bottom' })
|
||||
})
|
||||
}
|
||||
const scrollToBottom = debounce(_scrollToBottom, 1000, { leading: true, trailing: true })
|
||||
|
||||
const onStartMonitor = async () => {
|
||||
if (isMonitoring.value) {
|
||||
return
|
||||
|
@ -72,13 +65,11 @@ const onStartMonitor = async () => {
|
|||
}
|
||||
data.monitorEvent = get(ret, 'eventName')
|
||||
EventsOn(data.monitorEvent, (content) => {
|
||||
if (content instanceof Array) {
|
||||
data.list.push(...content)
|
||||
} else {
|
||||
data.list.push(content)
|
||||
}
|
||||
data.list.push(content)
|
||||
if (data.autoShowLast) {
|
||||
scrollToBottom()
|
||||
nextTick(() => {
|
||||
listRef.value.scrollTo({ position: 'bottom' })
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -117,7 +108,7 @@ const onCleanLog = () => {
|
|||
<template>
|
||||
<div class="content-log content-container fill-height flex-box-v">
|
||||
<n-form class="flex-item" label-align="left" label-placement="left" label-width="auto" size="small">
|
||||
<n-form-item :feedback="$t('monitor.warning')" :label="$t('monitor.actions')">
|
||||
<n-form-item :label="$t('monitor.actions')">
|
||||
<n-space>
|
||||
<n-button
|
||||
v-if="!isMonitoring"
|
||||
|
|
|
@ -72,15 +72,6 @@ const onCopyKey = () => {
|
|||
$message.error(e.message)
|
||||
})
|
||||
}
|
||||
|
||||
const onTTL = () => {
|
||||
dialogStore.openTTLDialog({
|
||||
server: props.server,
|
||||
db: props.db,
|
||||
key: binaryKey.value ? props.keyCode : props.keyPath,
|
||||
ttl: props.ttl,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -102,7 +93,7 @@ const onTTL = () => {
|
|||
<n-button-group>
|
||||
<n-tooltip>
|
||||
<template #trigger>
|
||||
<n-button :focusable="false" @click="onTTL">
|
||||
<n-button :focusable="false" @click="dialogStore.openTTLDialog(props.ttl)">
|
||||
<template #icon>
|
||||
<n-icon :component="Timer" size="18" />
|
||||
</template>
|
||||
|
|
|
@ -222,7 +222,7 @@ const actionColumn = {
|
|||
})
|
||||
if (success) {
|
||||
props.value.splice(index, 1)
|
||||
$message.success(i18n.t('dialogue.delete.success', { key: row.k }))
|
||||
$message.success(i18n.t('dialogue.delete_key_succ', { key: row.k }))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ const actionColumn = {
|
|||
index,
|
||||
})
|
||||
if (success) {
|
||||
$message.success(i18n.t('dialogue.delete.success', { key: `#${index + 1}` }))
|
||||
$message.success(i18n.t('dialogue.delete_key_succ', { key: `#${index + 1}` }))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ const actionColumn = {
|
|||
value: row.v,
|
||||
})
|
||||
if (success) {
|
||||
$message.success(i18n.t('dialogue.delete.success', { key: row.v }))
|
||||
$message.success(i18n.t('dialogue.delete_key_succ', { key: row.v }))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ const actionColumn = {
|
|||
ids: row.id,
|
||||
})
|
||||
if (success) {
|
||||
$message.success(i18n.t('dialogue.delete.success', { key: row.id }))
|
||||
$message.success(i18n.t('dialogue.delete_key_succ', { key: row.id }))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ const onDelete = () => {
|
|||
const { name, db } = data.value
|
||||
browserStore.deleteKey(name, db, keyName.value).then((success) => {
|
||||
if (success) {
|
||||
$message.success(i18n.t('dialogue.delete.success', { key: data.value.keyPath }))
|
||||
$message.success(i18n.t('dialogue.delete_key_succ', { key: data.value.keyPath }))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -238,7 +238,7 @@ const actionColumn = {
|
|||
value: row.v,
|
||||
})
|
||||
if (success) {
|
||||
$message.success(i18n.t('dialogue.delete.success', { key: row.v }))
|
||||
$message.success(i18n.t('dialogue.delete_key_succ', { key: row.v }))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
|
|
|
@ -5,18 +5,15 @@ import { useI18n } from 'vue-i18n'
|
|||
import useBrowserStore from 'stores/browser.js'
|
||||
import { isEmpty } from 'lodash'
|
||||
import FileOpenInput from '@/components/common/FileOpenInput.vue'
|
||||
import TtlInput from '@/components/common/TtlInput.vue'
|
||||
|
||||
const importKeyForm = reactive({
|
||||
server: '',
|
||||
db: 0,
|
||||
expire: true,
|
||||
reload: true,
|
||||
file: '',
|
||||
type: 0,
|
||||
conflict: 0,
|
||||
ttlType: 0,
|
||||
ttl: -1,
|
||||
ttlUnit: 1,
|
||||
})
|
||||
|
||||
const dialogStore = useDialog()
|
||||
|
@ -28,12 +25,11 @@ watchEffect(() => {
|
|||
const { server, db } = dialogStore.importKeyParam
|
||||
importKeyForm.server = server
|
||||
importKeyForm.db = db
|
||||
importKeyForm.expire = true
|
||||
importKeyForm.reload = true
|
||||
importKeyForm.file = ''
|
||||
importKeyForm.type = 0
|
||||
importKeyForm.conflict = 0
|
||||
importKeyForm.ttlType = 0
|
||||
importKeyForm.ttl = -1
|
||||
importing.value = false
|
||||
}
|
||||
})
|
||||
|
@ -50,21 +46,6 @@ const conflictOption = computed(() => [
|
|||
},
|
||||
])
|
||||
|
||||
const ttlOption = computed(() => [
|
||||
{
|
||||
value: 0,
|
||||
label: i18n.t('dialogue.import.ttl_include'),
|
||||
},
|
||||
{
|
||||
value: 1,
|
||||
label: i18n.t('dialogue.import.ttl_ignore'),
|
||||
},
|
||||
{
|
||||
value: 2,
|
||||
label: i18n.t('dialogue.import.ttl_custom'),
|
||||
},
|
||||
])
|
||||
|
||||
const importEnable = computed(() => {
|
||||
return !isEmpty(importKeyForm.file)
|
||||
})
|
||||
|
@ -72,19 +53,8 @@ const importEnable = computed(() => {
|
|||
const onConfirmImport = async () => {
|
||||
try {
|
||||
importing.value = true
|
||||
const { server, db, file, conflict, ttlType, ttl, ttlUnit, reload } = importKeyForm
|
||||
let ttlVal = 0
|
||||
switch (ttlType) {
|
||||
case 0:
|
||||
ttlVal = -1
|
||||
break
|
||||
case 1:
|
||||
ttlVal = 0
|
||||
break
|
||||
default:
|
||||
ttlVal = ttl * (ttlUnit || 1)
|
||||
}
|
||||
browserStore.importKeysFromCSVFile(server, db, file, conflict, ttlVal, reload).catch((e) => {})
|
||||
const { server, db, file, conflict, expire, reload } = importKeyForm
|
||||
browserStore.importKeysFromCSVFile(server, db, file, conflict, expire, reload).catch((e) => {})
|
||||
} catch (e) {
|
||||
$message.error(e.message)
|
||||
return
|
||||
|
@ -134,21 +104,15 @@ const onClose = () => {
|
|||
:value="op.value" />
|
||||
</n-radio-group>
|
||||
</n-form-item>
|
||||
<n-form-item :label="$t('dialogue.import.import_expire_title')">
|
||||
<n-space :wrap-item="false">
|
||||
<n-radio-group v-model:value="importKeyForm.ttlType">
|
||||
<n-radio-button v-for="(op, i) in ttlOption" :key="i" :label="op.label" :value="op.value" />
|
||||
</n-radio-group>
|
||||
<ttl-input
|
||||
v-if="importKeyForm.ttlType === 2"
|
||||
v-model:unit="importKeyForm.ttlUnit"
|
||||
v-model:value="importKeyForm.ttl" />
|
||||
</n-space>
|
||||
</n-form-item>
|
||||
<n-form-item :label="$t('dialogue.import.import_expire_title')" :show-label="false">
|
||||
<n-checkbox v-model:checked="importKeyForm.reload" :autofocus="false">
|
||||
{{ $t('dialogue.import.reload') }}
|
||||
</n-checkbox>
|
||||
<n-space :wrap-item="false">
|
||||
<n-checkbox v-model:checked="importKeyForm.expire" :autofocus="false">
|
||||
{{ $t('dialogue.import.import_expire') }}
|
||||
</n-checkbox>
|
||||
<n-checkbox v-model:checked="importKeyForm.reload" :autofocus="false">
|
||||
{{ $t('dialogue.import.reload') }}
|
||||
</n-checkbox>
|
||||
</n-space>
|
||||
</n-form-item>
|
||||
</n-form>
|
||||
</n-spin>
|
||||
|
|
|
@ -214,7 +214,7 @@ const onClose = () => {
|
|||
</template>
|
||||
</n-input-number>
|
||||
<n-button :focusable="false" secondary type="primary" @click="() => (newForm.ttl = -1)">
|
||||
{{ $t('interface.forever') }}
|
||||
{{ $t('dialogue.key.persist_key') }}
|
||||
</n-button>
|
||||
</n-input-group>
|
||||
</n-form-item>
|
||||
|
|
|
@ -1,48 +1,62 @@
|
|||
<script setup>
|
||||
import { computed, reactive, ref, watchEffect } from 'vue'
|
||||
import { computed, reactive, watchEffect } from 'vue'
|
||||
import useDialog from 'stores/dialog'
|
||||
import useTabStore from 'stores/tab.js'
|
||||
import Binary from '@/components/icons/Binary.vue'
|
||||
import { isEmpty } from 'lodash'
|
||||
import useBrowserStore from 'stores/browser.js'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { isEmpty, size } from 'lodash'
|
||||
import TtlInput from '@/components/common/TtlInput.vue'
|
||||
|
||||
const ttlForm = reactive({
|
||||
server: '',
|
||||
db: 0,
|
||||
key: '',
|
||||
keys: [],
|
||||
keyCode: null,
|
||||
ttl: -1,
|
||||
unit: 1,
|
||||
})
|
||||
|
||||
const dialogStore = useDialog()
|
||||
const browserStore = useBrowserStore()
|
||||
const tabStore = useTabStore()
|
||||
|
||||
watchEffect(() => {
|
||||
if (dialogStore.ttlDialogVisible) {
|
||||
// get ttl from current tab
|
||||
const { server, db, key, keys, ttl } = dialogStore.ttlParam
|
||||
ttlForm.server = server
|
||||
ttlForm.db = db
|
||||
ttlForm.key = key
|
||||
ttlForm.keys = keys
|
||||
ttlForm.unit = 1
|
||||
if (ttl < 0) {
|
||||
// forever
|
||||
ttlForm.ttl = -1
|
||||
} else {
|
||||
ttlForm.ttl = ttl
|
||||
const tab = tabStore.currentTab
|
||||
if (tab != null) {
|
||||
ttlForm.server = tab.name
|
||||
ttlForm.db = tab.db
|
||||
ttlForm.key = tab.key
|
||||
ttlForm.keyCode = tab.keyCode
|
||||
ttlForm.unit = 1
|
||||
if (tab.ttl < 0) {
|
||||
// forever
|
||||
ttlForm.ttl = -1
|
||||
} else {
|
||||
ttlForm.ttl = tab.ttl
|
||||
}
|
||||
}
|
||||
procssing.value = false
|
||||
}
|
||||
})
|
||||
|
||||
const procssing = ref(false)
|
||||
const isBatchAction = computed(() => {
|
||||
return !isEmpty(ttlForm.keys)
|
||||
})
|
||||
|
||||
const i18n = useI18n()
|
||||
const unit = computed(() => [
|
||||
{ value: 1, label: i18n.t('common.second') },
|
||||
{
|
||||
value: 60,
|
||||
label: i18n.t('common.minute'),
|
||||
},
|
||||
{
|
||||
value: 3600,
|
||||
label: i18n.t('common.hour'),
|
||||
},
|
||||
{
|
||||
value: 86400,
|
||||
label: i18n.t('common.day'),
|
||||
},
|
||||
])
|
||||
|
||||
const quickOption = computed(() => [
|
||||
{ value: -1, unit: 1, label: i18n.t('interface.forever') },
|
||||
{ value: 10, unit: 1, label: `10 ${i18n.t('common.second')}` },
|
||||
|
@ -62,20 +76,24 @@ const onClose = () => {
|
|||
|
||||
const onConfirm = async () => {
|
||||
try {
|
||||
procssing.value = true
|
||||
const ttl = ttlForm.ttl * (ttlForm.unit || 1)
|
||||
let success = false
|
||||
if (isBatchAction.value) {
|
||||
success = await browserStore.setTTLs(ttlForm.server, ttlForm.db, ttlForm.keys, ttl)
|
||||
} else {
|
||||
success = await browserStore.setTTL(ttlForm.server, ttlForm.db, ttlForm.key, ttl)
|
||||
const tab = tabStore.currentTab
|
||||
if (tab == null) {
|
||||
return
|
||||
}
|
||||
const key = isEmpty(ttlForm.keyCode) ? ttlForm.key : ttlForm.keyCode
|
||||
const ttl = ttlForm.ttl * (ttlForm.unit || 1)
|
||||
const success = await browserStore.setTTL(tab.name, tab.db, key, ttl)
|
||||
if (success) {
|
||||
tabStore.updateTTL({
|
||||
server: ttlForm.server,
|
||||
db: ttlForm.db,
|
||||
key: ttlForm.key,
|
||||
ttl: ttl,
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
$message.error(e.message || 'set ttl fail')
|
||||
} finally {
|
||||
procssing.value = false
|
||||
dialogStore.closeTTLDialog()
|
||||
}
|
||||
}
|
||||
|
@ -91,20 +109,30 @@ const onConfirm = async () => {
|
|||
:negative-text="$t('common.cancel')"
|
||||
:on-negative-click="onClose"
|
||||
:on-positive-click="onConfirm"
|
||||
:positive-button-props="{ focusable: false, size: 'medium', loading: procssing }"
|
||||
:positive-button-props="{ focusable: false, size: 'medium' }"
|
||||
:positive-text="$t('common.save')"
|
||||
:show-icon="false"
|
||||
:title="
|
||||
isBatchAction ? $t('dialogue.ttl.title_batch', { count: size(ttlForm.keys) }) : $t('dialogue.ttl.title')
|
||||
"
|
||||
:title="$t('dialogue.ttl.title')"
|
||||
preset="dialog"
|
||||
transform-origin="center">
|
||||
<n-form :model="ttlForm" :show-require-mark="false" label-placement="top">
|
||||
<n-form-item v-if="!isBatchAction" :label="$t('common.key')">
|
||||
<n-input :value="ttlForm.key" readonly />
|
||||
<n-form-item :label="$t('common.key')">
|
||||
<n-input :value="ttlForm.key" readonly>
|
||||
<template #prefix>
|
||||
<n-icon v-if="!!ttlForm.keyCode" :component="Binary" size="20" />
|
||||
</template>
|
||||
</n-input>
|
||||
</n-form-item>
|
||||
<n-form-item :label="$t('interface.ttl')" required>
|
||||
<ttl-input v-model:unit="ttlForm.unit" v-model:value="ttlForm.ttl" />
|
||||
<n-input-group>
|
||||
<n-input-number
|
||||
v-model:value="ttlForm.ttl"
|
||||
:max="Number.MAX_SAFE_INTEGER"
|
||||
:min="-1"
|
||||
:show-button="false"
|
||||
class="flex-item-expand" />
|
||||
<n-select v-model:value="ttlForm.unit" :options="unit" style="max-width: 150px" />
|
||||
</n-input-group>
|
||||
</n-form-item>
|
||||
<n-form-item :label="$t('dialogue.ttl.quick_set')" :show-feedback="false">
|
||||
<n-space :wrap="true" :wrap-item="false">
|
||||
|
|
|
@ -27,7 +27,6 @@ import { ConnectionType } from '@/consts/connection_type.js'
|
|||
import Import from '@/components/icons/Import.vue'
|
||||
import Down from '@/components/icons/Down.vue'
|
||||
import Checkbox from '@/components/icons/Checkbox.vue'
|
||||
import Timer from '@/components/icons/Timer.vue'
|
||||
|
||||
const props = defineProps({
|
||||
server: String,
|
||||
|
@ -128,13 +127,11 @@ const onAddKey = () => {
|
|||
const selectedKey = get(browserTreeRef.value?.getSelectedKey(), 0)
|
||||
if (selectedKey != null) {
|
||||
const node = browserStore.getNode(selectedKey)
|
||||
if (node != null) {
|
||||
const { type = ConnectionType.RedisValue, redisKey } = node
|
||||
if (type === ConnectionType.RedisKey) {
|
||||
// has prefix
|
||||
dialogStore.openNewKeyDialog(redisKey, props.server, props.db)
|
||||
return
|
||||
}
|
||||
const { type = ConnectionType.RedisValue, redisKey } = node
|
||||
if (type === ConnectionType.RedisKey) {
|
||||
// has prefix
|
||||
dialogStore.openNewKeyDialog(redisKey, props.server, props.db)
|
||||
return
|
||||
}
|
||||
}
|
||||
dialogStore.openNewKeyDialog('', props.server, props.db)
|
||||
|
@ -171,10 +168,6 @@ const onExportChecked = () => {
|
|||
browserTreeRef.value?.exportCheckedItems()
|
||||
}
|
||||
|
||||
const onUpdateTTLChecked = () => {
|
||||
browserTreeRef.value?.updateTTLCheckedItems()
|
||||
}
|
||||
|
||||
const onImportData = () => {
|
||||
dialogStore.openImportKeyDialog(props.server, props.db)
|
||||
}
|
||||
|
@ -353,7 +346,7 @@ watch(
|
|||
:icon="LoadList"
|
||||
:loading="loading"
|
||||
:stroke-width="3.5"
|
||||
size="21"
|
||||
size="20"
|
||||
t-tooltip="interface.load_more"
|
||||
@click="onLoadMore" />
|
||||
<icon-button
|
||||
|
@ -362,7 +355,7 @@ watch(
|
|||
:icon="LoadAll"
|
||||
:loading="loading"
|
||||
:stroke-width="3.5"
|
||||
size="21"
|
||||
size="20"
|
||||
t-tooltip="interface.load_all"
|
||||
@click="onLoadAll" />
|
||||
<div class="flex-item-expand" style="min-width: 10px" />
|
||||
|
@ -370,7 +363,7 @@ watch(
|
|||
:button-class="['nav-pane-func-btn']"
|
||||
:icon="Checkbox"
|
||||
:stroke-width="3.5"
|
||||
size="19"
|
||||
size="20"
|
||||
t-tooltip="interface.check_mode"
|
||||
@click="inCheckState = true" />
|
||||
<n-dropdown
|
||||
|
@ -392,14 +385,6 @@ watch(
|
|||
size="20"
|
||||
t-tooltip="interface.export_checked"
|
||||
@click="onExportChecked" />
|
||||
<icon-button
|
||||
:button-class="['nav-pane-func-btn']"
|
||||
:disabled="checkedCount <= 0"
|
||||
:icon="Timer"
|
||||
:stroke-width="3.5"
|
||||
size="20"
|
||||
t-tooltip="interface.ttl_checked"
|
||||
@click="onUpdateTTLChecked" />
|
||||
<icon-button
|
||||
:button-class="['nav-pane-func-btn']"
|
||||
:disabled="checkedCount <= 0"
|
||||
|
|
|
@ -233,7 +233,7 @@ const handleSelectContextMenu = (key) => {
|
|||
$dialog.warning(i18n.t('dialogue.remove_tip', { name: redisKeyName }), () => {
|
||||
browserStore.deleteKey(props.server, db, redisKey).then((success) => {
|
||||
if (success) {
|
||||
$message.success(i18n.t('dialogue.delete.success', { key: redisKeyName }))
|
||||
$message.success(i18n.t('dialogue.delete_key_succ', { key: redisKeyName }))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -469,7 +469,7 @@ const calcLayerMenu = (loading) => {
|
|||
return [
|
||||
// reload layer enable only full loaded
|
||||
h(IconButton, {
|
||||
tTooltip: props.fullLoaded ? 'interface.reload' : 'interface.reload_disable',
|
||||
tTooltip: props.fullLoaded ? 'interface.reload' : 'interface.reload',
|
||||
icon: Refresh,
|
||||
loading: loading === true,
|
||||
disabled: !props.fullLoaded,
|
||||
|
@ -565,7 +565,7 @@ watchEffect(
|
|||
)
|
||||
|
||||
// the NTree node may get incorrect height after change data
|
||||
// add key property for force refresh the component so that everything back to normal
|
||||
// add key property to force refresh the component and then everything back to normal
|
||||
const treeKey = ref(0)
|
||||
defineExpose({
|
||||
handleSelectContextMenu,
|
||||
|
@ -589,17 +589,6 @@ defineExpose({
|
|||
dialogStore.openExportKeyDialog(props.server, props.db, redisKeys)
|
||||
}
|
||||
},
|
||||
updateTTLCheckedItems: () => {
|
||||
const checkedKeys = tabStore.currentCheckedKeys
|
||||
const redisKeys = map(checkedKeys, 'redisKey')
|
||||
if (!isEmpty(redisKeys)) {
|
||||
dialogStore.openTTLDialog({
|
||||
server: props.server,
|
||||
db: props.db,
|
||||
keys: redisKeys,
|
||||
})
|
||||
}
|
||||
},
|
||||
getSelectedKey: () => {
|
||||
return selectedKeys.value || []
|
||||
},
|
||||
|
|
|
@ -33,7 +33,6 @@ const filterPattern = ref('')
|
|||
stroke-width="4"
|
||||
t-tooltip="interface.new_group"
|
||||
@click="dialogStore.openNewGroupDialog()" />
|
||||
<n-divider vertical />
|
||||
<n-input v-model:value="filterPattern" :placeholder="$t('interface.filter')" clearable>
|
||||
<template #prefix>
|
||||
<n-icon :component="Filter" size="20" />
|
||||
|
|
|
@ -447,9 +447,6 @@ const handleDrop = ({ node, dragNode, dropPosition }) => {
|
|||
if (dragNodeSiblings === null || dragNodeIndex === null) {
|
||||
return
|
||||
}
|
||||
if (node.type === ConnectionType.Group && dragNode.type === ConnectionType.Group) {
|
||||
return
|
||||
}
|
||||
dragNodeSiblings.splice(dragNodeIndex, 1)
|
||||
if (dropPosition === 'inside') {
|
||||
if (node.children) {
|
||||
|
|
|
@ -84,7 +84,6 @@
|
|||
"quit_check_mode": "Quit Check Mode",
|
||||
"delete_checked": "Delete Checked Items",
|
||||
"export_checked": "Export Checked Items",
|
||||
"ttl_checked": "Update TTL for Checked Items",
|
||||
"copy_value": "Copy Value",
|
||||
"edit_value": "Edit Value",
|
||||
"save_update": "Save Update",
|
||||
|
@ -107,7 +106,6 @@
|
|||
"view_as": "View As",
|
||||
"decode_with": "Decode / Decompression",
|
||||
"reload": "Reload",
|
||||
"reload_disable": "Reload will enable after full loaded",
|
||||
"open_connection": "Open Connection",
|
||||
"copy_path": "Copy Path",
|
||||
"copy_key": "Copy Key",
|
||||
|
@ -148,6 +146,9 @@
|
|||
"interrupt_connection": "Cancel",
|
||||
"remove_tip": "{type} \"{name}\" will be deleted",
|
||||
"remove_group_tip": "Group \"{name}\" and all connections in it will be deleted",
|
||||
"delete_key_succ": "\"{key}\" has been deleted",
|
||||
"deleting_key": "Deleting key({index}/{count})",
|
||||
"delete_completed": "Deletion process has been completed, {success} successed, {fail} failed",
|
||||
"rename_binary_key_fail": "Rename binary key name is unsupported",
|
||||
"handle_succ": "Success!",
|
||||
"handle_cancel": "The operation has been canceled.",
|
||||
|
@ -239,6 +240,7 @@
|
|||
"key": {
|
||||
"new": "New Key",
|
||||
"new_name": "New Key Name",
|
||||
"persist_key": "Persist Key",
|
||||
"server": "Connection",
|
||||
"db_index": "Database Index",
|
||||
"key_expression": "Key Expression",
|
||||
|
@ -250,11 +252,6 @@
|
|||
"confirm_flush": "I know what I'm doing!",
|
||||
"confirm_flush_db": "Confirm Flush Database"
|
||||
},
|
||||
"delete": {
|
||||
"success": "\"{key}\" has been deleted",
|
||||
"doing": "Deleting key({index}/{count})",
|
||||
"completed": "Deletion process has been completed, {success} successed, {fail} failed"
|
||||
},
|
||||
"field": {
|
||||
"new": "Add New Field",
|
||||
"new_item": "Add New Item",
|
||||
|
@ -291,6 +288,7 @@
|
|||
"import": {
|
||||
"name": "Import Data",
|
||||
"import_expire_title": "Expiration",
|
||||
"import_expire": "Import Expiration Time",
|
||||
"import": "Import",
|
||||
"reload": "Reload Keys After Imported",
|
||||
"open_csv_file": "Import File",
|
||||
|
@ -298,20 +296,17 @@
|
|||
"conflict_handle": "Key Conflict Resolution",
|
||||
"conflict_overwrite": "Overwrite",
|
||||
"conflict_ignore": "Ignore",
|
||||
"ttl_include": "Import From File",
|
||||
"ttl_ignore": "Do Not Set",
|
||||
"ttl_custom": "Custom",
|
||||
"importing": "Importing Keys imported/overwrite:{imported} conflict/fail:{conflict}",
|
||||
"import_completed": "Import completed, {success} successes, {ignored} failed"
|
||||
},
|
||||
"ttl": {
|
||||
"title": "Update TTL",
|
||||
"title_batch": "Batch Update TTL({count})",
|
||||
"quick_set": "Quick Settings",
|
||||
"success": "All TTL of keys have been updated"
|
||||
"title": "Set Key TTL",
|
||||
"quick_set": "Quick Settings"
|
||||
},
|
||||
"upgrade": {
|
||||
"title": "New Version Available",
|
||||
"import_expire_title": "Expiration",
|
||||
"import_expire": "Include Expiration Time",
|
||||
"new_version_tip": "A new version({ver}) is available. Download now?",
|
||||
"no_update": "You're update to date",
|
||||
"download_now": "Download",
|
||||
|
@ -369,7 +364,6 @@
|
|||
"monitor": {
|
||||
"title": "Monitor Commands",
|
||||
"actions": "Actions",
|
||||
"warning": "Monitor command may lead to server congestion. Please use it cautiously on production servers.",
|
||||
"start": "Start",
|
||||
"stop": "Stop",
|
||||
"search": "Search",
|
||||
|
|
|
@ -215,6 +215,7 @@
|
|||
"key": {
|
||||
"new": "Nova Chave",
|
||||
"new_name": "Novo Nome da Chave",
|
||||
"persist_key": "Persistir Chave",
|
||||
"server": "Conexão",
|
||||
"db_index": "Índice do Banco de Dados",
|
||||
"key_expression": "Expressão da Chave",
|
||||
|
|
|
@ -84,7 +84,6 @@
|
|||
"quit_check_mode": "退出勾选模式",
|
||||
"delete_checked": "删除所选项",
|
||||
"export_checked": "导出所选项",
|
||||
"ttl_checked": "为所选项更新TTL",
|
||||
"copy_value": "复制值",
|
||||
"edit_value": "修改值",
|
||||
"save_update": "保存修改",
|
||||
|
@ -107,7 +106,6 @@
|
|||
"view_as": "查看方式",
|
||||
"decode_with": "解码/解压方式",
|
||||
"reload": "重新载入",
|
||||
"reload_disable": "全量加载后可重新载入",
|
||||
"open_connection": "打开连接",
|
||||
"copy_path": "复制路径",
|
||||
"copy_key": "复制键名",
|
||||
|
@ -148,6 +146,9 @@
|
|||
"interrupt_connection": "中断连接",
|
||||
"remove_tip": "{type} \"{name}\" 将会被删除",
|
||||
"remove_group_tip": "分组 \"{name}\"及其所有连接将会被删除",
|
||||
"delete_key_succ": "{key} 已被删除",
|
||||
"deleting_key": "正在删除键({index}/{count})",
|
||||
"delete_completed": "已完成删除操作,成功{success}个,失败{fail}个",
|
||||
"rename_binary_key_fail": "不支持重命名二进制键名",
|
||||
"handle_succ": "操作成功",
|
||||
"handle_cancel": "操作已取消",
|
||||
|
@ -239,6 +240,7 @@
|
|||
"key": {
|
||||
"new": "添加新键",
|
||||
"new_name": "新键名",
|
||||
"persist_key": "持久化键",
|
||||
"server": "所属连接",
|
||||
"db_index": "数据库编号",
|
||||
"key_expression": "键名表达式",
|
||||
|
@ -250,11 +252,6 @@
|
|||
"confirm_flush": "我知道我正在执行的操作!",
|
||||
"confirm_flush_db": "确认清空数据库"
|
||||
},
|
||||
"delete": {
|
||||
"success": "{key} 已被删除",
|
||||
"doing": "正在删除键({index}/{count})",
|
||||
"completed": "已完成删除操作,成功{success}个,失败{fail}个"
|
||||
},
|
||||
"field": {
|
||||
"new": "添加新字段",
|
||||
"new_item": "添加新元素",
|
||||
|
@ -291,6 +288,7 @@
|
|||
"import": {
|
||||
"name": "导入数据",
|
||||
"import_expire_title": "过期时间",
|
||||
"import_expire": "包含键过期时间",
|
||||
"reload": "导入完成后重新载入",
|
||||
"import": "确认导入",
|
||||
"open_csv_file": "导入文件路径",
|
||||
|
@ -298,17 +296,12 @@
|
|||
"conflict_handle": "键冲突处理",
|
||||
"conflict_overwrite": "覆盖",
|
||||
"conflict_ignore": "忽略",
|
||||
"ttl_include": "尝试导入",
|
||||
"ttl_ignore": "不设置",
|
||||
"ttl_custom": "自定义",
|
||||
"importing": "正在导入数据 已导入/覆盖:{imported} 冲突/失败:{conflict}",
|
||||
"import_completed": "已完成导入操作,成功{success}个,忽略{ignored}个"
|
||||
},
|
||||
"ttl": {
|
||||
"title": "设置键存活时间",
|
||||
"title_batch": "批量设置键存活时间({count})",
|
||||
"quick_set": "快捷设置",
|
||||
"success": "已全部更新TTL"
|
||||
"quick_set": "快捷设置"
|
||||
},
|
||||
"upgrade": {
|
||||
"title": "有可用新版本",
|
||||
|
@ -369,7 +362,6 @@
|
|||
"monitor": {
|
||||
"title": "监控命令",
|
||||
"actions": "操作",
|
||||
"warning": "命令监控可能会造成服务端堵塞,请谨慎在生产环境的服务器使用",
|
||||
"start": "开启监控",
|
||||
"stop": "停止监控",
|
||||
"search": "搜索",
|
||||
|
|
|
@ -5,7 +5,6 @@ import {
|
|||
AddListItem,
|
||||
AddStreamValue,
|
||||
AddZSetValue,
|
||||
BatchSetTTL,
|
||||
CleanCmdHistory,
|
||||
CloseConnection,
|
||||
ConvertValue,
|
||||
|
@ -1485,81 +1484,19 @@ const useBrowserStore = defineStore('browser', {
|
|||
* reset key's ttl
|
||||
* @param {string} server
|
||||
* @param {number} db
|
||||
* @param {string|number[]} key
|
||||
* @param {string} key
|
||||
* @param {number} ttl
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async setTTL(server, db, key, ttl) {
|
||||
try {
|
||||
const { success, msg } = await SetKeyTTL(server, db, key, ttl)
|
||||
if (success) {
|
||||
const tabStore = useTabStore()
|
||||
tabStore.updateTTL({
|
||||
server,
|
||||
db,
|
||||
key,
|
||||
ttl,
|
||||
})
|
||||
}
|
||||
return success === true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
async setTTLs(server, db, keys, ttl) {
|
||||
// const msgRef = $message.loading('', { duration: 0, closable: true })
|
||||
// let updated = []
|
||||
// let failCount = 0
|
||||
// let canceled = false
|
||||
const serialNo = Date.now().valueOf().toString()
|
||||
// const eventName = 'ttling:' + serialNo
|
||||
// const cancelEvent = 'ttling:stop:' + serialNo
|
||||
try {
|
||||
// let maxProgress = 0
|
||||
// EventsOn(eventName, ({ total, progress, processing }) => {
|
||||
// // update delete progress
|
||||
// if (progress > maxProgress) {
|
||||
// maxProgress = progress
|
||||
// }
|
||||
// const k = decodeRedisKey(processing)
|
||||
// msgRef.content = i18nGlobal.t('dialogue.delete.doing', {
|
||||
// key: k,
|
||||
// index: maxProgress,
|
||||
// count: total,
|
||||
// })
|
||||
// })
|
||||
// msgRef.onClose = () => {
|
||||
// EventsEmit(cancelEvent)
|
||||
// }
|
||||
const { data, success, msg } = await BatchSetTTL(server, db, keys, ttl, serialNo)
|
||||
if (success) {
|
||||
// canceled = get(data, 'canceled', false)
|
||||
// updated = get(data, 'updated', [])
|
||||
// failCount = get(data, 'failed', 0)
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
} finally {
|
||||
// msgRef.destroy()
|
||||
// EventsOff(eventName)
|
||||
}
|
||||
$message.success(i18nGlobal.t('dialogue.ttl.success'))
|
||||
// const deletedCount = size(updated)
|
||||
// if (canceled) {
|
||||
// $message.info(i18nGlobal.t('dialogue.handle_cancel'))
|
||||
// } else if (failCount <= 0) {
|
||||
// // no fail
|
||||
// $message.success(i18nGlobal.t('dialogue.delete.completed', { success: deletedCount, fail: failCount }))
|
||||
// } else if (failCount >= deletedCount) {
|
||||
// // all fail
|
||||
// $message.error(i18nGlobal.t('dialogue.delete.completed', { success: deletedCount, fail: failCount }))
|
||||
// } else {
|
||||
// // some fail
|
||||
// $message.warn(i18nGlobal.t('dialogue.delete.completed', { success: deletedCount, fail: failCount }))
|
||||
// }
|
||||
},
|
||||
|
||||
/**
|
||||
* delete redis key
|
||||
* @param {string} server
|
||||
|
@ -1589,8 +1526,6 @@ const useBrowserStore = defineStore('browser', {
|
|||
// set tab content empty
|
||||
const tab = useTabStore()
|
||||
tab.emptyTab(server)
|
||||
tab.setSelectedKeys(server)
|
||||
tab.setCheckedKeys(server)
|
||||
return true
|
||||
} finally {
|
||||
}
|
||||
|
@ -1620,7 +1555,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
maxProgress = progress
|
||||
}
|
||||
const k = decodeRedisKey(processing)
|
||||
msgRef.content = i18nGlobal.t('dialogue.delete.doing', {
|
||||
msgRef.content = i18nGlobal.t('dialogue.deleting_key', {
|
||||
key: k,
|
||||
index: maxProgress,
|
||||
count: total,
|
||||
|
@ -1650,13 +1585,13 @@ const useBrowserStore = defineStore('browser', {
|
|||
$message.info(i18nGlobal.t('dialogue.handle_cancel'))
|
||||
} else if (failCount <= 0) {
|
||||
// no fail
|
||||
$message.success(i18nGlobal.t('dialogue.delete.completed', { success: deletedCount, fail: failCount }))
|
||||
$message.success(i18nGlobal.t('dialogue.delete_completed', { success: deletedCount, fail: failCount }))
|
||||
} else if (failCount >= deletedCount) {
|
||||
// all fail
|
||||
$message.error(i18nGlobal.t('dialogue.delete.completed', { success: deletedCount, fail: failCount }))
|
||||
$message.error(i18nGlobal.t('dialogue.delete_completed', { success: deletedCount, fail: failCount }))
|
||||
} else {
|
||||
// some fail
|
||||
$message.warn(i18nGlobal.t('dialogue.delete.completed', { success: deletedCount, fail: failCount }))
|
||||
$message.warn(i18nGlobal.t('dialogue.delete_completed', { success: deletedCount, fail: failCount }))
|
||||
}
|
||||
// update ui
|
||||
timeout(100).then(async () => {
|
||||
|
@ -1738,11 +1673,11 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {number} db
|
||||
* @param {string} path
|
||||
* @param {number} conflict
|
||||
* @param {number} [ttl] <0:use previous; ==0: persist; >0: custom ttl
|
||||
* @param {boolean} [expire]
|
||||
* @param {boolean} [reload]
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async importKeysFromCSVFile(server, db, path, conflict, ttl, reload) {
|
||||
async importKeysFromCSVFile(server, db, path, conflict, expire, reload) {
|
||||
const msgRef = $message.loading('', { duration: 0, closable: true })
|
||||
let imported = 0
|
||||
let ignored = 0
|
||||
|
@ -1760,7 +1695,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
msgRef.onClose = () => {
|
||||
EventsEmit('import:stop:' + path)
|
||||
}
|
||||
const { data, success, msg } = await ImportCSV(server, db, path, conflict, ttl)
|
||||
const { data, success, msg } = await ImportCSV(server, db, path, conflict, expire)
|
||||
if (success) {
|
||||
canceled = get(data, 'canceled', false)
|
||||
imported = get(data, 'imported', 0)
|
||||
|
@ -1785,9 +1720,9 @@ const useBrowserStore = defineStore('browser', {
|
|||
|
||||
/**
|
||||
* flush database
|
||||
* @param {string} server
|
||||
* @param {number} db
|
||||
* @param {boolean} async
|
||||
* @param server
|
||||
* @param db
|
||||
* @param async
|
||||
* @return {Promise<boolean>}
|
||||
*/
|
||||
async flushDatabase(server, db, async) {
|
||||
|
|
|
@ -82,14 +82,8 @@ const useDialogStore = defineStore('dialog', {
|
|||
},
|
||||
flushDBDialogVisible: false,
|
||||
|
||||
selectTTL: -1,
|
||||
ttlDialogVisible: false,
|
||||
ttlParam: {
|
||||
server: '',
|
||||
db: 0,
|
||||
key: '',
|
||||
keys: [],
|
||||
ttl: 0,
|
||||
},
|
||||
|
||||
preferencesDialogVisible: false,
|
||||
aboutDialogVisible: false,
|
||||
|
@ -270,23 +264,12 @@ const useDialogStore = defineStore('dialog', {
|
|||
this.addFieldsDialogVisible = false
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} server
|
||||
* @param {number} db
|
||||
* @param {string|number[]} [key]
|
||||
* @param {string[]|number[][]} [keys]
|
||||
* @param {number} [ttl]
|
||||
*/
|
||||
openTTLDialog({ server, db, key, keys, ttl = -1 }) {
|
||||
openTTLDialog(ttl) {
|
||||
this.selectTTL = ttl
|
||||
this.ttlDialogVisible = true
|
||||
this.ttlParam.server = server
|
||||
this.ttlParam.db = db
|
||||
this.ttlParam.key = key
|
||||
this.ttlParam.keys = keys
|
||||
this.ttlParam.ttl = ttl
|
||||
},
|
||||
closeTTLDialog() {
|
||||
this.selectTTL = -1
|
||||
this.ttlDialogVisible = false
|
||||
},
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { assign, find, findIndex, get, 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', {
|
||||
/**
|
||||
|
@ -547,7 +546,7 @@ const useTabStore = defineStore('tab', {
|
|||
* @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
|
||||
}
|
||||
|
@ -674,7 +673,7 @@ const useTabStore = defineStore('tab', {
|
|||
* @param {string} server
|
||||
* @param {CheckedKey[]} [keys]
|
||||
*/
|
||||
setCheckedKeys(server, keys = null) {
|
||||
setCheckedKeys(server, keys) {
|
||||
let tab = find(this.tabList, { name: server })
|
||||
if (tab != null) {
|
||||
if (isEmpty(keys)) {
|
||||
|
|
Loading…
Reference in New Issue