diff --git a/backend/services/browser_service.go b/backend/services/browser_service.go index c47ad47..80b59e0 100644 --- a/backend/services/browser_service.go +++ b/backend/services/browser_service.go @@ -591,7 +591,12 @@ func (b *browserService) GetKeyType(param types.KeySummaryParam) (resp types.JSR } var data types.KeySummary - data.Type = strings.ToLower(keyType) + switch keyType { + case "ReJSON-RL": + data.Type = "JSON" + default: + data.Type = strings.ToLower(keyType) + } resp.Success = true resp.Data = data @@ -624,7 +629,7 @@ func (b *browserService) GetKeySummary(param types.KeySummaryParam) (resp types. } size, _ := client.MemoryUsage(ctx, key, 0).Result() data := types.KeySummary{ - Type: strings.ToLower(typeVal.Val()), + Type: typeVal.Val(), Size: size, } if data.Type == "none" { @@ -655,6 +660,9 @@ func (b *browserService) GetKeySummary(param types.KeySummaryParam) (resp types. data.Length, err = client.ZCard(ctx, key).Result() case "stream": data.Length, err = client.XLen(ctx, key).Result() + case "ReJSON-RL": + data.Type = "JSON" + data.Length = 0 default: err = errors.New("unknown key type") } @@ -1091,6 +1099,12 @@ func (b *browserService) GetKeyDetail(param types.KeyDetailParam) (resp types.JS resp.Msg = err.Error() return } + + case "rejson-rl": + var jsonStr string + data.KeyType = "JSON" + jsonStr, err = client.JSONGet(ctx, key).Result() + data.Value, data.Decode, data.Format = convutil.ConvertTo(jsonStr, types.DECODE_NONE, types.FORMAT_JSON, nil) } if err != nil { resp.Msg = err.Error() @@ -1235,6 +1249,11 @@ func (b *browserService) SetKeyValue(param types.SetKeyParam) (resp types.JSResp } } } + case "json": + err = client.JSONSet(ctx, key, ".", param.Value).Err() + if err == nil && expiration > 0 { + client.Expire(ctx, key, expiration) + } } if err != nil { diff --git a/frontend/src/components/content_value/ContentValueJson.vue b/frontend/src/components/content_value/ContentValueJson.vue new file mode 100644 index 0000000..978f5d7 --- /dev/null +++ b/frontend/src/components/content_value/ContentValueJson.vue @@ -0,0 +1,177 @@ + + + + + diff --git a/frontend/src/components/content_value/ContentValueWrapper.vue b/frontend/src/components/content_value/ContentValueWrapper.vue index d08ed59..80185fb 100644 --- a/frontend/src/components/content_value/ContentValueWrapper.vue +++ b/frontend/src/components/content_value/ContentValueWrapper.vue @@ -14,6 +14,7 @@ import useDialogStore from 'stores/dialog.js' import { decodeTypes, formatTypes } from '@/consts/value_view_type.js' import { useI18n } from 'vue-i18n' import ContentToolbar from '@/components/content_value/ContentToolbar.vue' +import ContentValueJson from '@/components/content_value/ContentValueJson.vue' const themeVars = useThemeVars() const browserStore = useBrowserStore() @@ -66,6 +67,7 @@ const valueComponents = { [redisTypes.SET]: ContentValueSet, [redisTypes.ZSET]: ContentValueZset, [redisTypes.STREAM]: ContentValueStream, + [redisTypes.JSON]: ContentValueJson, } const keyName = computed(() => { diff --git a/frontend/src/components/dialogs/NewKeyDialog.vue b/frontend/src/components/dialogs/NewKeyDialog.vue index 3e05f24..97c2fea 100644 --- a/frontend/src/components/dialogs/NewKeyDialog.vue +++ b/frontend/src/components/dialogs/NewKeyDialog.vue @@ -14,6 +14,7 @@ import useTabStore from 'stores/tab.js' import NewStreamValue from '@/components/new_value/NewStreamValue.vue' import useBrowserStore from 'stores/browser.js' import Import from '@/components/icons/Import.vue' +import NewJsonValue from '@/components/new_value/NewJsonValue.vue' const i18n = useI18n() const newForm = reactive({ @@ -54,6 +55,7 @@ const newValueComponent = { [types.SET]: NewSetValue, [types.ZSET]: NewZSetValue, [types.STREAM]: NewStreamValue, + [types.JSON]: NewJsonValue, } const defaultValue = { [types.STRING]: '', @@ -62,6 +64,7 @@ const defaultValue = { [types.SET]: [], [types.ZSET]: [], [types.STREAM]: [], + [types.JSON]: '{}', } const dialogStore = useDialog() diff --git a/frontend/src/components/new_value/NewJsonValue.vue b/frontend/src/components/new_value/NewJsonValue.vue new file mode 100644 index 0000000..e62ed1f --- /dev/null +++ b/frontend/src/components/new_value/NewJsonValue.vue @@ -0,0 +1,20 @@ + + + + + diff --git a/frontend/src/consts/support_redis_type.js b/frontend/src/consts/support_redis_type.js index 82c869f..00b1f0b 100644 --- a/frontend/src/consts/support_redis_type.js +++ b/frontend/src/consts/support_redis_type.js @@ -9,6 +9,7 @@ export const types = { SET: 'SET', ZSET: 'ZSET', STREAM: 'STREAM', + JSON: 'JSON', } export const typesShortName = { @@ -18,6 +19,7 @@ export const typesShortName = { SET: 'E', ZSET: 'Z', STREAM: 'X', + JSON: 'J', } /** @@ -31,6 +33,7 @@ export const typesColor = { [types.SET]: '#F59E0B', [types.ZSET]: '#EF4444', [types.STREAM]: '#EC4899', + [types.JSON]: '#374254', } /** @@ -44,6 +47,7 @@ export const typesBgColor = { [types.SET]: '#FDF1DF', [types.ZSET]: '#FAEAED', [types.STREAM]: '#FDE6F1', + [types.JSON]: '#C1C1D3', } // export const typesName = Object.fromEntries(Object.entries(types).map(([key, value]) => [key, value.name]))