UNPKG

p3x-redis-ui-material

Version:

💿 P3X Redis UI triple frontend — Angular + React/MUI + Vue/Vuetify with 54 languages, 7 themes, Socket.IO, desktop notifications, and full feature parity

1 lines • 13.6 kB
import{A as e,C as t,Ct as n,D as r,E as i,J as a,Kt as ee,M as o,R as s,T as c,Yt as l,at as te,ht as u,it as d,k as f,m as ne,nt as p,t as re,w as m,y as h,z as g}from"./i18n.store-B4krJCIS.js";import{lt as ie,o as _,t as v,x as y}from"./_plugin-vue_export-helper-67n0yneU.js";import{t as b}from"./VTooltip-UUcBbF8q.js";import{n as ae,t as oe}from"./redis-state.store-DPDs81ZS.js";import{t as se}from"./common.store-C_dWn4yG.js";import{t as ce}from"./overlay.store-CDszzlsU.js";import{i as x}from"./socket.service-B85kYQEM.js";import{u as le}from"./index-CBO402jT.js";import{a as ue,d as S,f as de,n as fe,o as pe,p as C,s as me}from"./key-type-base-LvSh6VCU.js";import{n as he,t as ge}from"./JsonEditorDialog-CdnlZOlI.js";import{t as _e}from"./JsonViewDialog-CF2ki0pj.js";import{t as ve}from"./HexMonitor-B8nJtZMF.js";import{t as ye}from"./redis-version-BOZyuHOZ.js";var be={key:0,class:`p3xr-key-type-actions`},xe={key:1,class:`p3xr-key-type-actions`},Se={class:`p3xr-key-type-content`},Ce={key:0,class:`p3xr-key-type-editor`},we={key:0,class:`p3xr-key-type-buffer-info`},Te={key:0,style:{opacity:`0.5`,"font-style":`italic`}},Ee={key:2,class:`p3xr-key-string-display`},De={key:0,style:{opacity:`0.5`}},w=v(o({__name:`KeyString`,props:{response:{},value:{},valueBuffer:{},keyName:{},valueFormat:{}},emits:[`refresh`],setup(o,{emit:v}){let w=o,T=v,Oe=re(),E=oe(),D=ae(),O=se(),k=ce(),{width:ke}=ie(),A=t(()=>Oe.strings),j=t(()=>ke.value>=960),M=t(()=>E.connection?.readonly===!0),N=u(!1),P=u(!1),F=u(!1),I=u(``),L=u(null),R=u(!1),z=u(!1),B=u(!1),V=u(``),H=u(``),U=null,W=u(),Ae=t(()=>C(pe(typeof w.value==`string`?w.value:``,w.valueFormat))),je=t(()=>C(typeof w.value==`string`?w.value:``)),Me=t(()=>me(w.value)),Ne=t(()=>ye(E.info?.server?.redis_version).isAtLeast(8,4));function G(){let e=W.value;e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)}p(N,e=>{e&&g(()=>g(G))}),p(I,()=>g(G));function K(){let e=w.value;typeof e==`string`&&e.length>=D.maxValueAsBuffer?(P.value=!0,L.value=structuredClone(w.valueBuffer),I.value=String(w.valueBuffer??``)):(P.value=!1,L.value=structuredClone(e),I.value=String(e??``)),N.value=!0,g(G)}function q(){N.value=!1,P.value=!1,I.value=``}async function Pe(e,t){return!D.showDiffBeforeSave||e===t?!0:(V.value=e,H.value=t,B.value=!0,new Promise(e=>{U=e}))}async function J(){try{if(F.value&&JSON.parse(I.value),L.value!=null&&!await Pe(String(L.value),I.value))return;k.show({message:S(A.value?.intention?.save)}),await x({action:`key/set`,payload:{type:w.response?.type,key:w.keyName,value:I.value}});let e=L.value;N.value=!1,P.value=!1,T(`refresh`),k.hide(),D.undoEnabled&&e!==void 0&&String(e)!==I.value&&await O.toastWithUndo(S(A.value?.status?.saved))&&(k.show({message:`Undo...`}),await x({action:`key/set`,payload:{type:w.response?.type,key:w.keyName,value:String(e)}}),T(`refresh`),k.hide(),O.toast(S(A.value?.status?.reverted)))}catch(e){O.generalHandleError(e),k.hide()}}function Y(){let e=document.createElement(`input`);e.type=`file`,e.onchange=async()=>{let t=e.files?.[0];if(!t)return;let n=new FileReader;n.onerror=e=>O.generalHandleError(e),n.onload=async e=>{let t=e.target.result;try{if(N.value){await O.confirm({message:S(A.value?.confirm?.uploadBuffer)}),I.value=new TextDecoder().decode(t),O.toast(S(A.value?.confirm?.uploadBufferDone)),g(G);return}await O.confirm({message:S(A.value?.confirm?.uploadBuffer)}),k.show(),await x({action:`key/set`,payload:{type:w.response?.type,value:t,key:w.keyName}}),O.toast(S(A.value?.confirm?.uploadBufferDoneAndSave)),T(`refresh`)}catch(e){e!==void 0&&O.generalHandleError(e)}finally{k.hide()}},n.readAsArrayBuffer(t)},e.click()}async function X(){try{let e=JSON.stringify(JSON.parse(w.value),null,D.jsonFormat||2);k.show({message:S(A.value?.intention?.save)}),await x({action:`key/set`,payload:{type:w.response?.type,key:w.keyName,value:e}}),T(`refresh`)}catch{O.toast(S(A.value?.label?.jsonViewNotParsable))}finally{k.hide()}}async function Z(){try{let e=await x({action:`key/string-digest`,payload:{key:w.keyName}});O.toast(e.digest)}catch(e){O.generalHandleError(e)}}function Q(){fe(String(w.value??``))}function $(){ue(w.valueBuffer||de(String(w.value??``)),w.keyName)}function Fe(){return w.valueBuffer?.byteLength===void 0?``:`(`+D.prettyBytes(w.valueBuffer.byteLength)+`)`}async function Ie(e){if(z.value=!1,!e?.obj)return;let t=String(w.value??``);k.show({message:S(A.value?.intention?.save)});try{await x({action:`key/set`,payload:{type:w.response?.type,key:w.keyName,value:e.obj}}),T(`refresh`),k.hide(),D.undoEnabled&&t!==e.obj&&await O.toastWithUndo(S(A.value?.status?.saved))&&(k.show({message:`Undo...`}),await x({action:`key/set`,payload:{type:w.response?.type,key:w.keyName,value:t}}),T(`refresh`),k.hide(),O.toast(S(A.value?.status?.reverted)))}catch(e){O.generalHandleError(e),k.hide()}}return(t,u)=>(a(),r(`div`,null,[N.value?(a(),r(`div`,xe,[M.value?i(``,!0):(a(),c(le,{key:0,modelValue:F.value,"onUpdate:modelValue":u[16]||=e=>F.value=e,label:n(S)(A.value?.label?.validateJson),color:`secondary`,density:`compact`,"hide-details":``,style:{"margin-right":`8px`}},null,8,[`modelValue`,`label`])),j.value?(a(),c(_,{key:1,variant:`flat`,color:`error`,onClick:u[17]||=e=>q(),style:{gap:`3px`}},{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[46]||=[f(`mdi-close-circle`,-1)]]),_:1}),m(`span`,null,l(n(S)(A.value?.intention?.cancel)),1)]),_:1})):(a(),c(b,{key:2,text:n(S)(A.value?.intention?.cancel),location:`top`},{activator:d(({props:t})=>[e(_,s(t,{variant:`flat`,color:`error`,onClick:u[18]||=e=>q(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[47]||=[f(`mdi-close-circle`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`])),M.value?i(``,!0):(a(),r(h,{key:3},[j.value?(a(),c(_,{key:0,variant:`flat`,color:`primary`,onClick:u[19]||=e=>Y(),style:{gap:`3px`}},{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[48]||=[f(`mdi-upload`,-1)]]),_:1}),m(`span`,null,l(n(S)(A.value?.intention?.setBuffer)),1)]),_:1})):(a(),c(b,{key:1,text:n(S)(A.value?.intention?.setBuffer),location:`top`},{activator:d(({props:t})=>[e(_,s(t,{variant:`flat`,color:`primary`,onClick:u[20]||=e=>Y(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[49]||=[f(`mdi-upload`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`])),j.value?(a(),c(_,{key:2,variant:`flat`,color:`primary`,onClick:u[21]||=e=>J(),style:{gap:`3px`}},{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[50]||=[f(`mdi-check`,-1)]]),_:1}),m(`span`,null,l(n(S)(A.value?.intention?.save)),1)]),_:1})):(a(),c(b,{key:3,text:n(S)(A.value?.intention?.save),location:`top`},{activator:d(({props:t})=>[e(_,s(t,{variant:`flat`,color:`primary`,onClick:u[22]||=e=>J(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[51]||=[f(`mdi-check`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`]))],64))])):(a(),r(`div`,be,[M.value?i(``,!0):(a(),r(h,{key:0},[j.value?(a(),c(_,{key:0,variant:`flat`,color:`primary`,onClick:u[0]||=e=>Y(),style:{gap:`3px`}},{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[29]||=[f(`mdi-upload`,-1)]]),_:1}),m(`span`,null,l(n(S)(A.value?.intention?.setBuffer)),1)]),_:1})):(a(),c(b,{key:1,text:n(S)(A.value?.intention?.setBuffer),location:`top`},{activator:d(({props:t})=>[e(_,s(t,{variant:`flat`,color:`primary`,onClick:u[1]||=e=>Y(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[30]||=[f(`mdi-upload`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`]))],64)),j.value?(a(),c(_,{key:1,variant:`flat`,color:`secondary`,onClick:u[2]||=e=>$(),style:{gap:`3px`}},{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[31]||=[f(`mdi-download`,-1)]]),_:1}),m(`span`,null,l(n(S)(A.value?.intention?.downloadBuffer)),1)]),_:1})):(a(),c(b,{key:2,text:n(S)(A.value?.intention?.downloadBuffer),location:`top`},{activator:d(({props:t})=>[e(_,s(t,{variant:`flat`,color:`secondary`,onClick:u[3]||=e=>$(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[32]||=[f(`mdi-download`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`])),j.value?(a(),c(_,{key:3,variant:`flat`,color:`secondary`,onClick:u[4]||=e=>R.value=!0,style:{gap:`3px`}},{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[33]||=[f(`mdi-file-tree`,-1)]]),_:1}),m(`span`,null,l(n(S)(A.value?.intention?.jsonViewShow)),1)]),_:1})):(a(),c(b,{key:4,text:n(S)(A.value?.intention?.jsonViewShow),location:`top`},{activator:d(({props:t})=>[e(_,s(t,{variant:`flat`,color:`secondary`,onClick:u[5]||=e=>R.value=!0,style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[34]||=[f(`mdi-file-tree`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`])),j.value?(a(),c(_,{key:5,variant:`flat`,color:`secondary`,onClick:u[6]||=e=>Q(),style:{gap:`3px`}},{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[35]||=[f(`mdi-content-copy`,-1)]]),_:1}),m(`span`,null,l(n(S)(A.value?.intention?.copy)),1)]),_:1})):(a(),c(b,{key:6,text:n(S)(A.value?.intention?.copy),location:`top`},{activator:d(({props:t})=>[e(_,s(t,{variant:`flat`,color:`secondary`,onClick:u[7]||=e=>Q(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[36]||=[f(`mdi-content-copy`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`])),M.value?i(``,!0):(a(),r(h,{key:7},[j.value?(a(),c(_,{key:0,variant:`flat`,color:`primary`,onClick:u[8]||=e=>X(),style:{gap:`3px`}},{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[37]||=[f(`mdi-format-line-spacing`,-1)]]),_:1}),m(`span`,null,l(n(S)(A.value?.intention?.formatJson)),1)]),_:1})):(a(),c(b,{key:1,text:n(S)(A.value?.intention?.formatJson),location:`top`},{activator:d(({props:t})=>[e(_,s(t,{variant:`flat`,color:`primary`,onClick:u[9]||=e=>X(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[38]||=[f(`mdi-format-line-spacing`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`]))],64)),j.value?(a(),c(_,{key:8,variant:`flat`,color:`primary`,onClick:u[10]||=e=>z.value=!0,style:{gap:`3px`}},{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[39]||=[f(`mdi-file-document-outline`,-1)]]),_:1}),m(`span`,null,l(n(S)(A.value?.intention?.jsonViewEditor)),1)]),_:1})):(a(),c(b,{key:9,text:n(S)(A.value?.intention?.jsonViewEditor),location:`top`},{activator:d(({props:t})=>[e(_,s(t,{variant:`flat`,color:`primary`,onClick:u[11]||=e=>z.value=!0,style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[40]||=[f(`mdi-file-document-outline`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`])),Ne.value?(a(),r(h,{key:10},[j.value?(a(),c(_,{key:0,variant:`flat`,color:`secondary`,onClick:u[12]||=e=>Z(),style:{gap:`3px`}},{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[41]||=[f(`mdi-pound`,-1)]]),_:1}),u[42]||=m(`span`,null,`Digest`,-1)]),_:1})):(a(),c(b,{key:1,text:`Digest`,location:`top`},{activator:d(({props:t})=>[e(_,s(t,{variant:`flat`,color:`secondary`,onClick:u[13]||=e=>Z(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[43]||=[f(`mdi-pound`,-1)]]),_:1})]),_:1},16)]),_:1}))],64)):i(``,!0),M.value?i(``,!0):(a(),r(h,{key:11},[j.value?(a(),c(_,{key:0,variant:`flat`,color:`primary`,onClick:u[14]||=e=>K(),style:{gap:`3px`}},{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[44]||=[f(`mdi-pencil`,-1)]]),_:1}),m(`span`,null,l(n(S)(A.value?.intention?.edit)),1)]),_:1})):(a(),c(b,{key:1,text:n(S)(A.value?.intention?.edit),location:`top`},{activator:d(({props:t})=>[e(_,s(t,{variant:`flat`,color:`primary`,onClick:u[15]||=e=>K(),style:{"min-width":`40px`,width:`40px`,height:`40px`,padding:`0`,"border-radius":`4px`}}),{default:d(()=>[e(y,{size:`small`},{default:d(()=>[...u[45]||=[f(`mdi-pencil`,-1)]]),_:1})]),_:1},16)]),_:1},8,[`text`]))],64))])),m(`div`,Se,[N.value?(a(),r(`div`,Ce,[P.value||String(o.value)===`[object ArrayBuffer]`?(a(),r(`div`,we,l(typeof A.value?.label?.isBuffer==`function`?A.value.label.isBuffer({maxValueAsBuffer:n(D).prettyBytes(n(D).maxValueAsBuffer)}):``)+` `+l(Fe()),1)):i(``,!0),te(m(`textarea`,{ref_key:`textareaRef`,ref:W,"onUpdate:modelValue":u[23]||=e=>I.value=e,class:`p3xr-key-string-textarea`,onInput:u[24]||=e=>G()},null,544),[[ne,I.value]])])):(a(),r(`div`,{key:1,class:`p3xr-key-type-display`,style:ee({cursor:M.value?`default`:`pointer`,overflow:o.valueFormat===`hex`?`visible`:`auto`}),onClick:u[25]||=e=>!M.value&&K()},[n(D).maxValueDisplay===-1?(a(),r(`div`,Te,l(n(S)(A.value?.label?.hiddenUntilEdit)),1)):o.valueFormat===`hex`?(a(),c(ve,{key:1,value:je.value},null,8,[`value`])):(a(),r(`span`,Ee,[f(l(Ae.value),1),Me.value?(a(),r(`span`,De,`...`)):i(``,!0)]))],4))]),e(_e,{open:R.value,value:String(o.value??``),onClose:u[26]||=e=>R.value=!1},null,8,[`open`,`value`]),e(ge,{open:z.value,value:String(o.value??``),onClose:Ie},null,8,[`open`,`value`]),e(he,{open:B.value,"key-name":o.keyName,"old-value":V.value,"new-value":H.value,onConfirm:u[27]||=e=>{B.value=!1,n(U)?.(!0)},onCancel:u[28]||=e=>{B.value=!1,n(U)?.(!1)}},null,8,[`open`,`key-name`,`old-value`,`new-value`])]))}}),[[`__scopeId`,`data-v-7bdffae3`]]);export{w as default};